rpc.go
func (r rpc) Request(method string, endpoint string, params interface{}, holder interface{}) error {

	jsonParams, err := json.Marshal(params)
	if err != nil {
		return err
	}

	request, err := r.createRequest(method, endpoint, jsonParams)
	if err != nil {
		return err
	}

	var data []byte
	if r.mock == true { // Mock mode: Replace actual request with expected JSON from file
		data, err = r.simulateRequest(endpoint, method)
	} else {
		data, err = r.executeRequest(request)
	}
	if err != nil {
		return err
	}
	if err := json.Unmarshal(data, &holder); err != nil {
		return err
	}

	return nil
}
func (r rpc) Request(method string, endpoint string, params interface{}, holder interface{}) error {

	jsonParams, err := json.Marshal(params)
	if err != nil {
		return err
	}

	request, err := r.createRequest(method, endpoint, jsonParams)
	if err != nil {
		return err
	}

	var data []byte
	if r.mock == true { // Mock mode: Replace actual request with expected JSON from file
		data, err = r.simulateRequest(endpoint, method)
	} else {
		data, err = r.executeRequest(request)
	}
	if err != nil {
		return err
	}
	if err := json.Unmarshal(data, &holder); err != nil {
		return err
	}

	return nil
}
func ( r rpc ) Request ( method string , endpoint string , params interface { } , holder interface { } ) error { jsonParams , err := json . Marshal ( params ) if err != nil { return err } request , err := r . createRequest ( method , endpoint , jsonParams ) if err != nil { return err } var data [ ] byte if r . mock == true { // Mock mode: Replace actual request with expected JSON from file data , err = r . simulateRequest ( endpoint , method ) } else { data , err = r . executeRequest ( request ) } if err != nil { return err } if err := json . Unmarshal ( data , & holder ) ; err != nil { return err } return nil }
// Request sends a request with params marshaled into a JSON payload in the body
// The response value is marshaled from JSON into the specified holder struct
Request sends a request with params marshaled into a JSON payload in the body The response value is marshaled from JSON into the specified holder struct