/** * TODO: type endpoint description here * @param string address parameter: Required * @return Returns the *models.Address response from the API call */ func (me *DIGIBYTE_IMPL) GetAddress( address string) (*models.Address, error) { //the base uri for api requests queryBuilder := ribbitrewardswalletandblockchainapi.BASEURI //prepare query string for API call queryBuilder = queryBuilder + "/api/digibyte/api/addr" //variable to hold errors var err error = nil //process optional query parameters queryBuilder, err = apihelper.AppendUrlWithQueryParameters(queryBuilder, map[string]interface{}{ "address": address, }) if err != nil { //error in query param handling return nil, err } //validate and preprocess url queryBuilder, err = apihelper.CleanUrl(queryBuilder) if err != nil { //error in url validation or cleaning return nil, err } //prepare headers for the outgoing request headers := map[string]interface{}{ "user-agent": "APIMATIC 2.0", } //prepare API request request := unirest.Get(queryBuilder, headers) //and invoke the API call request to fetch the response response, err := unirest.AsString(request) if err != nil { //error in API invocation return nil, err } //error handling using HTTP status codes if (response.Code < 200) || (response.Code > 206) { //[200,206] = HTTP OK err = apihelper.NewAPIError("HTTP Response Not OK", response.Code, response.RawBody) } if err != nil { //error detected in status code validation return nil, err } //returning the response var retVal *models.Address = &models.Address{} err = json.Unmarshal(response.RawBody, &retVal) if err != nil { //error in parsing return nil, err } return retVal, nil }
/** * TODO: type endpoint description here * @return Returns the *models.BroadcastTransactionResponse response from the API call */ func (me *RIBBITREWARDS_IMPL) CreateBroadcastTransaction() (*models.BroadcastTransactionResponse, error) { //the base uri for api requests queryBuilder := ribbitrewardswalletandblockchainapi.BASEURI //prepare query string for API call queryBuilder = queryBuilder + "/api/ribbit/api/tx" //variable to hold errors var err error = nil //validate and preprocess url queryBuilder, err = apihelper.CleanUrl(queryBuilder) if err != nil { //error in url validation or cleaning return nil, err } //prepare headers for the outgoing request headers := map[string]interface{}{ "user-agent": "APIMATIC 2.0", } //prepare API request request := unirest.Post(queryBuilder, headers) //and invoke the API call request to fetch the response response, err := unirest.AsString(request) if err != nil { //error in API invocation return nil, err } //error handling using HTTP status codes if (response.Code < 200) || (response.Code > 206) { //[200,206] = HTTP OK err = apihelper.NewAPIError("HTTP Response Not OK", response.Code, response.RawBody) } if err != nil { //error detected in status code validation return nil, err } //returning the response var retVal *models.BroadcastTransactionResponse = &models.BroadcastTransactionResponse{} err = json.Unmarshal(response.RawBody, &retVal) if err != nil { //error in parsing return nil, err } return retVal, nil }