package mard2papi /** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.2-dev * User agent: apibuilder app.apibuilder.io/mard/mard2p-api/0.0.2-dev/go_1_5_client */ import ( "applications" "bytes" "encoding/json" "errors" "fmt" "io" "membership_requests" "memberships" "net/http" "net/url" "strconv" "strings" "versions" ) const BaseUrl = "https://api.apibuilder.io" const UserAgent = "apibuilder app.apibuilder.io/mard/mard2p-api/0.0.2-dev/go_1_5_client" const Version = "0.0.2-dev" const VersionMajor = 0 type Client struct { HttpClient *http.Client Username string Password string BaseUrl string Headers http.Header } type ClientRequestBody struct { contentType string bytes io.Reader } type AppSortBy string const ( AppSortByCreated AppSortBy = "created" AppSortByEdited = "edited" AppSortByUNDEFINED = "UNDEFINED" ) func AppSortByFromString(value string) AppSortBy { switch strings.TrimSpace(strings.ToLower(value)) { case "created": return AppSortByCreated case "edited": return AppSortByEdited default: return AppSortByUNDEFINED } } type OriginalType string const ( OriginalTypeApiJson OriginalType = "api_json" // The original is in the api.json format OriginalTypeUNDEFINED = "UNDEFINED" ) func OriginalTypeFromString(value string) OriginalType { switch strings.TrimSpace(strings.ToLower(value)) { case "api_json": return OriginalTypeApiJson default: return OriginalTypeUNDEFINED } } /** * A publication represents something that a user can subscribe to. An example * would be subscribing to an email alert whenever a new version of an application * is created. */ type Publication string const ( Publicationmembership_requests.Create Publication = "membership_requests.create" // For organizations for which I am an administrator, email me whenever a user applies to join the org. Publicationmemberships.Create = "memberships.create" // For organizations for which I am a member, email me whenever a user joins the org. Publicationapplications.Create = "applications.create" // For organizations for which I am a member, email me whenever an application is created. Publicationversions.Create = "versions.create" // For applications that I watch, email me whenever a version is created. PublicationUNDEFINED = "UNDEFINED" ) func PublicationFromString(value string) Publication { switch strings.TrimSpace(strings.ToLower(value)) { case "membership_requests.create": return Publicationmembership_requests.Create case "memberships.create": return Publicationmemberships.Create case "applications.create": return Publicationapplications.Create case "versions.create": return Publicationversions.Create default: return PublicationUNDEFINED } } type SortOrder string const ( SortOrderAsc SortOrder = "asc" SortOrderDesc = "desc" SortOrderUNDEFINED = "UNDEFINED" ) func SortOrderFromString(value string) SortOrder { switch strings.TrimSpace(strings.ToLower(value)) { case "asc": return SortOrderAsc case "desc": return SortOrderDesc default: return SortOrderUNDEFINED } } /** * Controls who is able to view this version */ type Visibility string const ( VisibilityPublic Visibility = "public" // Anybody, including non logged in users, can view this application VisibilityUNDEFINED = "UNDEFINED" ) func VisibilityFromString(value string) Visibility { switch strings.TrimSpace(strings.ToLower(value)) { case "public": return VisibilityPublic default: return VisibilityUNDEFINED } } /** * Account is defined by the app specifically to manage users transactions. */ type Account struct { Accountid int64 `json:"accountid"` Ownerid string `json:"ownerid"` TotalAmount float64 `json:"total_amount"` Currency string `json:"currency"` Sold float64 `json:"sold"` Debit float64 `json:"debit"` } func AccountFromMap(data interface{}) Account { b, err := json.Marshal(data) if err == nil { return AccountFromJson(bytes.NewReader(b)) } else { panic(err) } } func AccountFromJson(bytes io.Reader) Account { var account Account json.NewDecoder(bytes).Decode(&account) return account } type AccountForm struct { Accountid int64 `json:"accountid"` Ownerid string `json:"ownerid"` TotalAmount float64 `json:"total_amount,omitempty"` Sold float64 `json:"sold"` Debit float64 `json:"debit,omitempty"` Currency string `json:"currency"` } func AccountFormFromMap(data interface{}) AccountForm { b, err := json.Marshal(data) if err == nil { return AccountFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func AccountFormFromJson(bytes io.Reader) AccountForm { var accountForm AccountForm json.NewDecoder(bytes).Decode(&accountForm) return accountForm } /** * Deposit describes a way a payment is handled. It depends of Payment Resource */ type Deposit struct { Depid int64 `json:"depid"` Paymentid int64 `json:"paymentid"` } func DepositFromMap(data interface{}) Deposit { b, err := json.Marshal(data) if err == nil { return DepositFromJson(bytes.NewReader(b)) } else { panic(err) } } func DepositFromJson(bytes io.Reader) Deposit { var deposit Deposit json.NewDecoder(bytes).Decode(&deposit) return deposit } /** * Payment is defined by the app specifically to emit users transactions. */ type Payment struct { Payid int64 `json:"payid"` Actorid string `json:"actorid"` Amount float64 `json:"amount"` RefAccountid int64 `json:"ref_accountid"` PaymentMethod string `json:"payment_method"` Operatorid string `json:"operatorid"` Phone int64 `json:"phone"` Pin int32 `json:"pin"` Currency string `json:"currency"` PaymentContext string `json:"payment_context"` } func PaymentFromMap(data interface{}) Payment { b, err := json.Marshal(data) if err == nil { return PaymentFromJson(bytes.NewReader(b)) } else { panic(err) } } func PaymentFromJson(bytes io.Reader) Payment { var payment Payment json.NewDecoder(bytes).Decode(&payment) return payment } type PaymentForm struct { Payid int64 `json:"payid"` Actorid string `json:"actorid"` Amount float64 `json:"amount"` RefAccountid int64 `json:"ref_accountid"` PaymentMethod string `json:"payment_method"` Operatorid string `json:"operatorid"` Phone int64 `json:"phone"` Pin int32 `json:"pin"` Currency string `json:"currency"` PaymentContext string `json:"payment_context"` } func PaymentFormFromMap(data interface{}) PaymentForm { b, err := json.Marshal(data) if err == nil { return PaymentFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func PaymentFormFromJson(bytes io.Reader) PaymentForm { var paymentForm PaymentForm json.NewDecoder(bytes).Decode(&paymentForm) return paymentForm } /** * Transfer is defined by the app specifically to manage users transactions * (sending and receiving). */ type Transfer struct { Transferid int64 `json:"transferid"` Senderid string `json:"senderid"` Amount float64 `json:"amount"` RefAccountidReceiver int64 `json:"ref_accountid_receiver"` RefAccountidSender int64 `json:"ref_accountid_sender"` Currency string `json:"currency"` } func TransferFromMap(data interface{}) Transfer { b, err := json.Marshal(data) if err == nil { return TransferFromJson(bytes.NewReader(b)) } else { panic(err) } } func TransferFromJson(bytes io.Reader) Transfer { var transfer Transfer json.NewDecoder(bytes).Decode(&transfer) return transfer } type TransferForm struct { Transferid int64 `json:"transferid"` Senderid string `json:"senderid"` Amount float64 `json:"amount"` RefAccountidReceiver int64 `json:"ref_accountid_receiver"` RefAccountidSender int64 `json:"ref_accountid_sender"` Currency string `json:"currency"` } func TransferFormFromMap(data interface{}) TransferForm { b, err := json.Marshal(data) if err == nil { return TransferFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func TransferFormFromJson(bytes io.Reader) TransferForm { var transferForm TransferForm json.NewDecoder(bytes).Decode(&transferForm) return transferForm } /** * Used only to validate json files - used as a resource where http status code * defines success */ type Validation struct { Valid string `json:"valid"` Errors []string `json:"errors"` } func ValidationFromMap(data interface{}) Validation { b, err := json.Marshal(data) if err == nil { return ValidationFromJson(bytes.NewReader(b)) } else { panic(err) } } func ValidationFromJson(bytes io.Reader) Validation { var validation Validation json.NewDecoder(bytes).Decode(&validation) return validation } /** * Withdraw describes a way a payment is handled. It depends of Payment Resource */ type Withdraw struct { Wdwid int64 `json:"wdwid"` Paymentid int64 `json:"paymentid"` } func WithdrawFromMap(data interface{}) Withdraw { b, err := json.Marshal(data) if err == nil { return WithdrawFromJson(bytes.NewReader(b)) } else { panic(err) } } func WithdrawFromJson(bytes io.Reader) Withdraw { var withdraw Withdraw json.NewDecoder(bytes).Decode(&withdraw) return withdraw } type AccountsPostCreateParams struct { Accountid int64 Ownerid string TotalAmount float64 Sold float64 Debit float64 Currency string } type AccountsPostCreateResponse struct { StatusCode int Response *http.Response Error error Account Account } func AccountsPostCreate(client Client, params AccountsPostCreateParams) AccountsPostCreateResponse { requestUrl := fmt.Sprintf("%s/accounts/create", client.BaseUrl) urlValues := url.Values{} if 0 != params.Accountid { urlValues.Add("accountid", strconv.FormatInt(params.Accountid, 10)) } if "" != params.Ownerid { urlValues.Add("ownerid", params.Ownerid) } if 0 != params.TotalAmount { urlValues.Add("total_amount", strconv.FormatFloat(params.TotalAmount, 'E', -1, 64)) } if 0 != params.Sold { urlValues.Add("sold", strconv.FormatFloat(params.Sold, 'E', -1, 64)) } if 0 != params.Debit { urlValues.Add("debit", strconv.FormatFloat(params.Debit, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return AccountsPostCreateResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AccountsPostCreateResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AccountsPostCreateResponse{StatusCode: resp.StatusCode, Response: resp, Account: AccountFromJson(resp.Body)} case 409: return AccountsPostCreateResponse{StatusCode: resp.StatusCode, Response: resp} default: return AccountsPostCreateResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AccountsPutUpdateByAccountidParams struct { Ownerid string TotalAmount float64 Currency string Sold float64 Debit float64 } type AccountsPutUpdateByAccountidResponse struct { StatusCode int Response *http.Response Error error Account Account } func AccountsPutUpdateByAccountid(client Client, accountid int64, params AccountsPutUpdateByAccountidParams) AccountsPutUpdateByAccountidResponse { requestUrl := fmt.Sprintf("%s/accounts/update/%s", client.BaseUrl, strconv.FormatInt(accountid, 10)) urlValues := url.Values{} if "" != params.Ownerid { urlValues.Add("ownerid", params.Ownerid) } if 0 != params.TotalAmount { urlValues.Add("total_amount", strconv.FormatFloat(params.TotalAmount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.Sold { urlValues.Add("sold", strconv.FormatFloat(params.Sold, 'E', -1, 64)) } if 0 != params.Debit { urlValues.Add("debit", strconv.FormatFloat(params.Debit, 'E', -1, 64)) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return AccountsPutUpdateByAccountidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AccountsPutUpdateByAccountidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AccountsPutUpdateByAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Account: AccountFromJson(resp.Body)} case 409: return AccountsPutUpdateByAccountidResponse{StatusCode: resp.StatusCode, Response: resp} default: return AccountsPutUpdateByAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AccountsDeleteDeleteByAccountidResponse struct { StatusCode int Response *http.Response Error error } func AccountsDeleteDeleteByAccountid(client Client, accountid int64) AccountsDeleteDeleteByAccountidResponse { requestUrl := fmt.Sprintf("%s/accounts/delete/%s", client.BaseUrl, strconv.FormatInt(accountid, 10)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return AccountsDeleteDeleteByAccountidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AccountsDeleteDeleteByAccountidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return AccountsDeleteDeleteByAccountidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return AccountsDeleteDeleteByAccountidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return AccountsDeleteDeleteByAccountidResponse{StatusCode: resp.StatusCode, Response: resp} default: return AccountsDeleteDeleteByAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AccountsGetByAccountidParams struct { Ownerid string TotalAmount float64 Sold float64 Debit float64 Currency string } type AccountsGetByAccountidResponse struct { StatusCode int Response *http.Response Error error Account Account } func AccountsGetByAccountid(client Client, accountid int64, params AccountsGetByAccountidParams) AccountsGetByAccountidResponse { requestUrl := fmt.Sprintf("%s/accounts/%s", client.BaseUrl, strconv.FormatInt(accountid, 10)) urlValues := url.Values{} if "" != params.Ownerid { urlValues.Add("ownerid", params.Ownerid) } if 0 != params.TotalAmount { urlValues.Add("total_amount", strconv.FormatFloat(params.TotalAmount, 'E', -1, 64)) } if 0 != params.Sold { urlValues.Add("sold", strconv.FormatFloat(params.Sold, 'E', -1, 64)) } if 0 != params.Debit { urlValues.Add("debit", strconv.FormatFloat(params.Debit, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return AccountsGetByAccountidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AccountsGetByAccountidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AccountsGetByAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Account: AccountFromJson(resp.Body)} case 404: return AccountsGetByAccountidResponse{StatusCode: resp.StatusCode, Response: resp} default: return AccountsGetByAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AccountsGetListParams struct { Accountid int64 Ownerid string TotalAmount float64 Currency string Sold float64 Debit float64 } type AccountsGetListResponse struct { StatusCode int Response *http.Response Error error Accounts []Account } func AccountsGetList(client Client, params AccountsGetListParams) AccountsGetListResponse { requestUrl := fmt.Sprintf("%s/accounts/list", client.BaseUrl) urlValues := url.Values{} if 0 != params.Accountid { urlValues.Add("accountid", strconv.FormatInt(params.Accountid, 10)) } if "" != params.Ownerid { urlValues.Add("ownerid", params.Ownerid) } if 0 != params.TotalAmount { urlValues.Add("total_amount", strconv.FormatFloat(params.TotalAmount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.Sold { urlValues.Add("sold", strconv.FormatFloat(params.Sold, 'E', -1, 64)) } if 0 != params.Debit { urlValues.Add("debit", strconv.FormatFloat(params.Debit, 'E', -1, 64)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return AccountsGetListResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AccountsGetListResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AccountsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Accounts: func() []Account { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Account for _, el := range tmp { all = append(all, AccountFromMap(el)) } return all }()} case 404: return AccountsGetListResponse{StatusCode: resp.StatusCode, Response: resp} default: return AccountsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DepositsDeleteDeleteByDepidResponse struct { StatusCode int Response *http.Response Error error } func DepositsDeleteDeleteByDepid(client Client, depid int64) DepositsDeleteDeleteByDepidResponse { requestUrl := fmt.Sprintf("%s/deposits/delete/%s", client.BaseUrl, strconv.FormatInt(depid, 10)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return DepositsDeleteDeleteByDepidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DepositsDeleteDeleteByDepidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return DepositsDeleteDeleteByDepidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return DepositsDeleteDeleteByDepidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return DepositsDeleteDeleteByDepidResponse{StatusCode: resp.StatusCode, Response: resp} default: return DepositsDeleteDeleteByDepidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DepositsGetByDepidParams struct { PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int64 Currency string PaymentContext string } type DepositsGetByDepidResponse struct { StatusCode int Response *http.Response Error error Payment Payment } func DepositsGetByDepid(client Client, depid int64, params DepositsGetByDepidParams) DepositsGetByDepidResponse { requestUrl := fmt.Sprintf("%s/deposits/%s", client.BaseUrl, strconv.FormatInt(depid, 10)) urlValues := url.Values{} if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return DepositsGetByDepidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DepositsGetByDepidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return DepositsGetByDepidResponse{StatusCode: resp.StatusCode, Response: resp, Payment: PaymentFromJson(resp.Body)} case 404: return DepositsGetByDepidResponse{StatusCode: resp.StatusCode, Response: resp} default: return DepositsGetByDepidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DepositsGetListParams struct { Payid int64 PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int64 Currency string PaymentContext string } type DepositsGetListResponse struct { StatusCode int Response *http.Response Error error Payments []Payment } func DepositsGetList(client Client, params DepositsGetListParams) DepositsGetListResponse { requestUrl := fmt.Sprintf("%s/deposits/list", client.BaseUrl) urlValues := url.Values{} if 0 != params.Payid { urlValues.Add("payid", strconv.FormatInt(params.Payid, 10)) } if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return DepositsGetListResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DepositsGetListResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return DepositsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Payments: func() []Payment { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Payment for _, el := range tmp { all = append(all, PaymentFromMap(el)) } return all }()} case 404: return DepositsGetListResponse{StatusCode: resp.StatusCode, Response: resp} default: return DepositsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PaymentsPostCreateParams struct { Payid int64 PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Currency string Phone int64 Pin int32 PaymentContext string } type PaymentsPostCreateResponse struct { StatusCode int Response *http.Response Error error Payment Payment } func PaymentsPostCreate(client Client, params PaymentsPostCreateParams) PaymentsPostCreateResponse { requestUrl := fmt.Sprintf("%s/payments/create", client.BaseUrl) urlValues := url.Values{} if 0 != params.Payid { urlValues.Add("payid", strconv.FormatInt(params.Payid, 10)) } if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return PaymentsPostCreateResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PaymentsPostCreateResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PaymentsPostCreateResponse{StatusCode: resp.StatusCode, Response: resp, Payment: PaymentFromJson(resp.Body)} case 409: return PaymentsPostCreateResponse{StatusCode: resp.StatusCode, Response: resp} default: return PaymentsPostCreateResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PaymentsPutUpdateByPayidParams struct { PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int32 Currency string PaymentContext string } type PaymentsPutUpdateByPayidResponse struct { StatusCode int Response *http.Response Error error Payment Payment } func PaymentsPutUpdateByPayid(client Client, payid int64, params PaymentsPutUpdateByPayidParams) PaymentsPutUpdateByPayidResponse { requestUrl := fmt.Sprintf("%s/payments/update/%s", client.BaseUrl, strconv.FormatInt(payid, 10)) urlValues := url.Values{} if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return PaymentsPutUpdateByPayidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PaymentsPutUpdateByPayidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PaymentsPutUpdateByPayidResponse{StatusCode: resp.StatusCode, Response: resp, Payment: PaymentFromJson(resp.Body)} case 409: return PaymentsPutUpdateByPayidResponse{StatusCode: resp.StatusCode, Response: resp} default: return PaymentsPutUpdateByPayidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PaymentsDeleteDeleteByPayidResponse struct { StatusCode int Response *http.Response Error error } func PaymentsDeleteDeleteByPayid(client Client, payid int64) PaymentsDeleteDeleteByPayidResponse { requestUrl := fmt.Sprintf("%s/payments/delete/%s", client.BaseUrl, strconv.FormatInt(payid, 10)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return PaymentsDeleteDeleteByPayidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PaymentsDeleteDeleteByPayidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return PaymentsDeleteDeleteByPayidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return PaymentsDeleteDeleteByPayidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return PaymentsDeleteDeleteByPayidResponse{StatusCode: resp.StatusCode, Response: resp} default: return PaymentsDeleteDeleteByPayidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PaymentsGetByPayidParams struct { PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int64 Currency string PaymentContext string } type PaymentsGetByPayidResponse struct { StatusCode int Response *http.Response Error error Payment Payment } func PaymentsGetByPayid(client Client, payid int64, params PaymentsGetByPayidParams) PaymentsGetByPayidResponse { requestUrl := fmt.Sprintf("%s/payments/%s", client.BaseUrl, strconv.FormatInt(payid, 10)) urlValues := url.Values{} if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return PaymentsGetByPayidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PaymentsGetByPayidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PaymentsGetByPayidResponse{StatusCode: resp.StatusCode, Response: resp, Payment: PaymentFromJson(resp.Body)} case 404: return PaymentsGetByPayidResponse{StatusCode: resp.StatusCode, Response: resp} default: return PaymentsGetByPayidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PaymentsGetByRefAccountidParams struct { Payid int64 PaymentMethod string Actorid string Operatorid string Amount float64 Phone int64 Pin int32 Currency string PaymentContext string } type PaymentsGetByRefAccountidResponse struct { StatusCode int Response *http.Response Error error Payment Payment } func PaymentsGetByRefAccountid(client Client, refAccountid int64, params PaymentsGetByRefAccountidParams) PaymentsGetByRefAccountidResponse { requestUrl := fmt.Sprintf("%s/payments/%s", client.BaseUrl, strconv.FormatInt(refAccountid, 10)) urlValues := url.Values{} if 0 != params.Payid { urlValues.Add("payid", strconv.FormatInt(params.Payid, 10)) } if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return PaymentsGetByRefAccountidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PaymentsGetByRefAccountidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PaymentsGetByRefAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Payment: PaymentFromJson(resp.Body)} case 404: return PaymentsGetByRefAccountidResponse{StatusCode: resp.StatusCode, Response: resp} default: return PaymentsGetByRefAccountidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PaymentsGetListParams struct { Payid int64 PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int64 Currency string PaymentContext string } type PaymentsGetListResponse struct { StatusCode int Response *http.Response Error error Payments []Payment } func PaymentsGetList(client Client, params PaymentsGetListParams) PaymentsGetListResponse { requestUrl := fmt.Sprintf("%s/payments/list", client.BaseUrl) urlValues := url.Values{} if 0 != params.Payid { urlValues.Add("payid", strconv.FormatInt(params.Payid, 10)) } if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return PaymentsGetListResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PaymentsGetListResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PaymentsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Payments: func() []Payment { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Payment for _, el := range tmp { all = append(all, PaymentFromMap(el)) } return all }()} case 404: return PaymentsGetListResponse{StatusCode: resp.StatusCode, Response: resp} default: return PaymentsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TransfersPostCreateParams struct { Transferid int64 Senderid string Amount float64 Currency string RefAccountidReceiver int64 RefAccountidSender int64 } type TransfersPostCreateResponse struct { StatusCode int Response *http.Response Error error Transfer Transfer } func TransfersPostCreate(client Client, params TransfersPostCreateParams) TransfersPostCreateResponse { requestUrl := fmt.Sprintf("%s/transfers/create", client.BaseUrl) urlValues := url.Values{} if 0 != params.Transferid { urlValues.Add("transferid", strconv.FormatInt(params.Transferid, 10)) } if "" != params.Senderid { urlValues.Add("senderid", params.Senderid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.RefAccountidReceiver { urlValues.Add("ref_accountid_receiver", strconv.FormatInt(params.RefAccountidReceiver, 10)) } if 0 != params.RefAccountidSender { urlValues.Add("ref_accountid_sender", strconv.FormatInt(params.RefAccountidSender, 10)) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return TransfersPostCreateResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TransfersPostCreateResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TransfersPostCreateResponse{StatusCode: resp.StatusCode, Response: resp, Transfer: TransferFromJson(resp.Body)} case 409: return TransfersPostCreateResponse{StatusCode: resp.StatusCode, Response: resp} default: return TransfersPostCreateResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TransfersPutUpdateByTransferidParams struct { Senderid string Amount float64 Currency string RefAccountidReceiver int64 RefAccountidSender int64 } type TransfersPutUpdateByTransferidResponse struct { StatusCode int Response *http.Response Error error Transfer Transfer } func TransfersPutUpdateByTransferid(client Client, transferid int64, params TransfersPutUpdateByTransferidParams) TransfersPutUpdateByTransferidResponse { requestUrl := fmt.Sprintf("%s/transfers/update/%s", client.BaseUrl, strconv.FormatInt(transferid, 10)) urlValues := url.Values{} if "" != params.Senderid { urlValues.Add("senderid", params.Senderid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.RefAccountidReceiver { urlValues.Add("ref_accountid_receiver", strconv.FormatInt(params.RefAccountidReceiver, 10)) } if 0 != params.RefAccountidSender { urlValues.Add("ref_accountid_sender", strconv.FormatInt(params.RefAccountidSender, 10)) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return TransfersPutUpdateByTransferidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TransfersPutUpdateByTransferidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TransfersPutUpdateByTransferidResponse{StatusCode: resp.StatusCode, Response: resp, Transfer: TransferFromJson(resp.Body)} case 409: return TransfersPutUpdateByTransferidResponse{StatusCode: resp.StatusCode, Response: resp} default: return TransfersPutUpdateByTransferidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TransfersDeleteDeleteByTransferidResponse struct { StatusCode int Response *http.Response Error error } func TransfersDeleteDeleteByTransferid(client Client, transferid int64) TransfersDeleteDeleteByTransferidResponse { requestUrl := fmt.Sprintf("%s/transfers/delete/%s", client.BaseUrl, strconv.FormatInt(transferid, 10)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return TransfersDeleteDeleteByTransferidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TransfersDeleteDeleteByTransferidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return TransfersDeleteDeleteByTransferidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return TransfersDeleteDeleteByTransferidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return TransfersDeleteDeleteByTransferidResponse{StatusCode: resp.StatusCode, Response: resp} default: return TransfersDeleteDeleteByTransferidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TransfersGetByTransferidParams struct { Senderid string Amount float64 Currency string RefAccountidReceiver int64 RefAccountidSender int64 } type TransfersGetByTransferidResponse struct { StatusCode int Response *http.Response Error error Account Account } func TransfersGetByTransferid(client Client, transferid int64, params TransfersGetByTransferidParams) TransfersGetByTransferidResponse { requestUrl := fmt.Sprintf("%s/transfers/%s", client.BaseUrl, strconv.FormatInt(transferid, 10)) urlValues := url.Values{} if "" != params.Senderid { urlValues.Add("senderid", params.Senderid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.RefAccountidReceiver { urlValues.Add("ref_accountid_receiver", strconv.FormatInt(params.RefAccountidReceiver, 10)) } if 0 != params.RefAccountidSender { urlValues.Add("ref_accountid_sender", strconv.FormatInt(params.RefAccountidSender, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return TransfersGetByTransferidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TransfersGetByTransferidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TransfersGetByTransferidResponse{StatusCode: resp.StatusCode, Response: resp, Account: AccountFromJson(resp.Body)} case 404: return TransfersGetByTransferidResponse{StatusCode: resp.StatusCode, Response: resp} default: return TransfersGetByTransferidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TransfersGetListParams struct { Transferid int64 Senderid string Amount float64 Currency string RefAccountidReceiver int64 RefAccountidSender int64 } type TransfersGetListResponse struct { StatusCode int Response *http.Response Error error Accounts []Account } func TransfersGetList(client Client, params TransfersGetListParams) TransfersGetListResponse { requestUrl := fmt.Sprintf("%s/transfers/list", client.BaseUrl) urlValues := url.Values{} if 0 != params.Transferid { urlValues.Add("transferid", strconv.FormatInt(params.Transferid, 10)) } if "" != params.Senderid { urlValues.Add("senderid", params.Senderid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if 0 != params.RefAccountidReceiver { urlValues.Add("ref_accountid_receiver", strconv.FormatInt(params.RefAccountidReceiver, 10)) } if 0 != params.RefAccountidSender { urlValues.Add("ref_accountid_sender", strconv.FormatInt(params.RefAccountidSender, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return TransfersGetListResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TransfersGetListResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TransfersGetListResponse{StatusCode: resp.StatusCode, Response: resp, Accounts: func() []Account { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Account for _, el := range tmp { all = append(all, AccountFromMap(el)) } return all }()} case 404: return TransfersGetListResponse{StatusCode: resp.StatusCode, Response: resp} default: return TransfersGetListResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ValidationsPostResponse struct { StatusCode int Response *http.Response Error error Validation Validation } func ValidationsPost(client Client, string_ string) ValidationsPostResponse { requestUrl := fmt.Sprintf("%s/validations", client.BaseUrl) bodyDocument, err := json.Marshal(string_) if err != nil { return ValidationsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return ValidationsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ValidationsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ValidationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Validation: ValidationFromJson(resp.Body)} default: return ValidationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WithdrawsDeleteDeleteByWdwidResponse struct { StatusCode int Response *http.Response Error error } func WithdrawsDeleteDeleteByWdwid(client Client, wdwid int64) WithdrawsDeleteDeleteByWdwidResponse { requestUrl := fmt.Sprintf("%s/withdraws/delete/%s", client.BaseUrl, strconv.FormatInt(wdwid, 10)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return WithdrawsDeleteDeleteByWdwidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WithdrawsDeleteDeleteByWdwidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return WithdrawsDeleteDeleteByWdwidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return WithdrawsDeleteDeleteByWdwidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return WithdrawsDeleteDeleteByWdwidResponse{StatusCode: resp.StatusCode, Response: resp} default: return WithdrawsDeleteDeleteByWdwidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WithdrawsGetByWdwidParams struct { Depid int64 PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int64 Currency string PaymentContext string } type WithdrawsGetByWdwidResponse struct { StatusCode int Response *http.Response Error error Payment Payment } func WithdrawsGetByWdwid(client Client, wdwid int64, params WithdrawsGetByWdwidParams) WithdrawsGetByWdwidResponse { requestUrl := fmt.Sprintf("%s/withdraws/%s", client.BaseUrl, strconv.FormatInt(wdwid, 10)) urlValues := url.Values{} if 0 != params.Depid { urlValues.Add("depid", strconv.FormatInt(params.Depid, 10)) } if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return WithdrawsGetByWdwidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WithdrawsGetByWdwidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return WithdrawsGetByWdwidResponse{StatusCode: resp.StatusCode, Response: resp, Payment: PaymentFromJson(resp.Body)} case 404: return WithdrawsGetByWdwidResponse{StatusCode: resp.StatusCode, Response: resp} default: return WithdrawsGetByWdwidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WithdrawsGetListParams struct { Payid int64 PaymentMethod string Actorid string RefAccountid int64 Operatorid string Amount float64 Phone int64 Pin int64 Currency string PaymentContext string } type WithdrawsGetListResponse struct { StatusCode int Response *http.Response Error error Payments []Payment } func WithdrawsGetList(client Client, params WithdrawsGetListParams) WithdrawsGetListResponse { requestUrl := fmt.Sprintf("%s/withdraws/list", client.BaseUrl) urlValues := url.Values{} if 0 != params.Payid { urlValues.Add("payid", strconv.FormatInt(params.Payid, 10)) } if "" != params.PaymentMethod { urlValues.Add("payment_method", params.PaymentMethod) } if "" != params.Actorid { urlValues.Add("actorid", params.Actorid) } if 0 != params.RefAccountid { urlValues.Add("ref_accountid", strconv.FormatInt(params.RefAccountid, 10)) } if "" != params.Operatorid { urlValues.Add("operatorid", params.Operatorid) } if 0 != params.Amount { urlValues.Add("amount", strconv.FormatFloat(params.Amount, 'E', -1, 64)) } if 0 != params.Phone { urlValues.Add("phone", strconv.FormatInt(params.Phone, 10)) } if 0 != params.Pin { urlValues.Add("pin", strconv.FormatInt(params.Pin, 10)) } if "" != params.Currency { urlValues.Add("currency", params.Currency) } if "" != params.PaymentContext { urlValues.Add("payment_context", params.PaymentContext) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return WithdrawsGetListResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WithdrawsGetListResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return WithdrawsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Payments: func() []Payment { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Payment for _, el := range tmp { all = append(all, PaymentFromMap(el)) } return all }()} case 404: return WithdrawsGetListResponse{StatusCode: resp.StatusCode, Response: resp} default: return WithdrawsGetListResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } func buildRequest(client Client, method, urlStr string, body ClientRequestBody) (*http.Request, error) { request, err := http.NewRequest(method, urlStr, body.bytes) if err != nil { return nil, err } request.Header.Add("User-Agent", UserAgent) request.Header.Add("X-Apidoc-Version", Version) request.Header.Add("X-Apidoc-Version-Major", strconv.Itoa(VersionMajor)) if client.Headers != nil { for key, values := range client.Headers { for _, value := range values { request.Header.Add(key, value) } } } if body.contentType != "" { request.Header.Add("Content-Type", body.contentType) } if client.Username != "" { request.SetBasicAuth(client.Username, client.Password) } return request, nil }