http.go
func (client *Client) APICall(payload interface{}, method, route string, result interface{}, query url.Values) (interface{}, *CallSummary, error) {
	rawPayload := []byte{}
	var err error
	if reflect.ValueOf(payload).IsValid() && !reflect.ValueOf(payload).IsNil() {
		rawPayload, err = json.Marshal(payload)
		if err != nil {
			cs := &CallSummary{
				HTTPRequestObject: payload,
			}
			return result,
				cs,
				&APICallException{
					CallSummary: cs,
					RootCause:   err,
				}
		}
	}
	callSummary, err := client.Request(rawPayload, method, route, query)
	callSummary.HTTPRequestObject = payload
	if err != nil {
		// If context failed during this request, then we should just return that error
		if client.Context != nil && client.Context.Err() != nil {
			return result, callSummary, client.Context.Err()
		}
		return result,
			callSummary,
			&APICallException{
				CallSummary: callSummary,
				RootCause:   err,
			}
	}
	// if result is passed in as nil, it means the API defines no response body
	// json
	if reflect.ValueOf(result).IsValid() && !reflect.ValueOf(result).IsNil() {
		err = json.Unmarshal([]byte(callSummary.HTTPResponseBody), &result)
	}

	if err != nil {
		return result,
			callSummary,
			&APICallException{
				CallSummary: callSummary,
				RootCause:   err,
			}
	}
	return result, callSummary, nil
}
func (client *Client) APICall(payload interface{}, method, route string, result interface{}, query url.Values) (interface{}, *CallSummary, error) {
	rawPayload := []byte{}
	var err error
	if reflect.ValueOf(payload).IsValid() && !reflect.ValueOf(payload).IsNil() {
		rawPayload, err = json.Marshal(payload)
		if err != nil {
			cs := &CallSummary{
				HTTPRequestObject: payload,
			}
			return result,
				cs,
				&APICallException{
					CallSummary: cs,
					RootCause:   err,
				}
		}
	}
	callSummary, err := client.Request(rawPayload, method, route, query)
	callSummary.HTTPRequestObject = payload
	if err != nil {
		// If context failed during this request, then we should just return that error
		if client.Context != nil && client.Context.Err() != nil {
			return result, callSummary, client.Context.Err()
		}
		return result,
			callSummary,
			&APICallException{
				CallSummary: callSummary,
				RootCause:   err,
			}
	}
	// if result is passed in as nil, it means the API defines no response body
	// json
	if reflect.ValueOf(result).IsValid() && !reflect.ValueOf(result).IsNil() {
		err = json.Unmarshal([]byte(callSummary.HTTPResponseBody), &result)
	}

	if err != nil {
		return result,
			callSummary,
			&APICallException{
				CallSummary: callSummary,
				RootCause:   err,
			}
	}
	return result, callSummary, nil
}
// APICall is the generic REST API calling method which performs all REST API
// calls for this library.  Each auto-generated REST API method simply is a
// wrapper around this method, calling it with specific specific arguments.