github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/merchant/services/Client.go (about) 1 // This class was auto-generated from the API references found at 2 // https://epayments-api.developer-ingenico.com/ 3 4 package services 5 6 import ( 7 "github.com/Ingenico-ePayments/connect-sdk-go/communicator/communication" 8 "github.com/Ingenico-ePayments/connect-sdk-go/domain/errors" 9 "github.com/Ingenico-ePayments/connect-sdk-go/domain/services" 10 sdkErrors "github.com/Ingenico-ePayments/connect-sdk-go/errors" 11 "github.com/Ingenico-ePayments/connect-sdk-go/internal/apiresource" 12 ) 13 14 // Client represents a services client. Thread-safe. 15 type Client struct { 16 apiResource *apiresource.APIResource 17 } 18 19 // ConvertAmount represents the resource /{merchantId}/services/convert/amount - Convert amount 20 // Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/services/convertAmount.html 21 // 22 // Can return any of the following errors: 23 // * ValidationError if the request was not correct and couldn't be processed (HTTP status code 400) 24 // * AuthorizationError if the request was not allowed (HTTP status code 403) 25 // * IdempotenceError if an idempotent request caused a conflict (HTTP status code 409) 26 // * ReferenceError if an object was attempted to be referenced that doesn't exist or has been removed, 27 // or there was a conflict (HTTP status code 404, 409 or 410) 28 // * GlobalCollectError if something went wrong at the Ingenico ePayments platform, 29 // the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, 30 // or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503) 31 // * APIError if the Ingenico ePayments platform returned any other error 32 func (c *Client) ConvertAmount(query ConvertAmountParams, context communication.CallContext) (services.ConvertAmount, error) { 33 var resultObject services.ConvertAmount 34 35 uri, err := c.apiResource.InstantiateURIWithContext("/v1/{merchantId}/services/convert/amount", nil) 36 if err != nil { 37 return resultObject, err 38 } 39 40 clientHeaders := c.apiResource.ClientHeaders() 41 42 getErr := c.apiResource.Communicator().Get(uri, clientHeaders, &query, context, &resultObject) 43 if getErr != nil { 44 responseError, isResponseError := getErr.(*sdkErrors.ResponseError) 45 if isResponseError { 46 var errorObject interface{} 47 48 errorObject = &errors.ErrorResponse{} 49 err = c.apiResource.Communicator().Marshaller().Unmarshal(responseError.Body(), errorObject) 50 if err != nil { 51 return resultObject, err 52 } 53 54 err, createErr := sdkErrors.CreateAPIError(responseError.StatusCode(), responseError.Body(), errorObject, context) 55 if createErr != nil { 56 return resultObject, createErr 57 } 58 59 return resultObject, err 60 } 61 62 return resultObject, getErr 63 } 64 65 return resultObject, nil 66 } 67 68 // Bankaccount represents the resource /{merchantId}/services/convert/bankaccount - Convert bankaccount 69 // Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/services/bankaccount.html 70 // 71 // Can return any of the following errors: 72 // * ValidationError if the request was not correct and couldn't be processed (HTTP status code 400) 73 // * AuthorizationError if the request was not allowed (HTTP status code 403) 74 // * IdempotenceError if an idempotent request caused a conflict (HTTP status code 409) 75 // * ReferenceError if an object was attempted to be referenced that doesn't exist or has been removed, 76 // or there was a conflict (HTTP status code 404, 409 or 410) 77 // * GlobalCollectError if something went wrong at the Ingenico ePayments platform, 78 // the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, 79 // or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503) 80 // * APIError if the Ingenico ePayments platform returned any other error 81 func (c *Client) Bankaccount(body services.BankDetailsRequest, context communication.CallContext) (services.BankDetailsResponse, error) { 82 var resultObject services.BankDetailsResponse 83 84 uri, err := c.apiResource.InstantiateURIWithContext("/v1/{merchantId}/services/convert/bankaccount", nil) 85 if err != nil { 86 return resultObject, err 87 } 88 89 clientHeaders := c.apiResource.ClientHeaders() 90 91 postErr := c.apiResource.Communicator().Post(uri, clientHeaders, nil, body, context, &resultObject) 92 if postErr != nil { 93 responseError, isResponseError := postErr.(*sdkErrors.ResponseError) 94 if isResponseError { 95 var errorObject interface{} 96 97 errorObject = &errors.ErrorResponse{} 98 err = c.apiResource.Communicator().Marshaller().Unmarshal(responseError.Body(), errorObject) 99 if err != nil { 100 return resultObject, err 101 } 102 103 err, createErr := sdkErrors.CreateAPIError(responseError.StatusCode(), responseError.Body(), errorObject, context) 104 if createErr != nil { 105 return resultObject, createErr 106 } 107 108 return resultObject, err 109 } 110 111 return resultObject, postErr 112 } 113 114 return resultObject, nil 115 } 116 117 // GetIINdetails represents the resource /{merchantId}/services/getIINdetails - Get IIN details 118 // Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/services/getIINdetails.html 119 // 120 // Can return any of the following errors: 121 // * ValidationError if the request was not correct and couldn't be processed (HTTP status code 400) 122 // * AuthorizationError if the request was not allowed (HTTP status code 403) 123 // * IdempotenceError if an idempotent request caused a conflict (HTTP status code 409) 124 // * ReferenceError if an object was attempted to be referenced that doesn't exist or has been removed, 125 // or there was a conflict (HTTP status code 404, 409 or 410) 126 // * GlobalCollectError if something went wrong at the Ingenico ePayments platform, 127 // the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, 128 // or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503) 129 // * APIError if the Ingenico ePayments platform returned any other error 130 func (c *Client) GetIINdetails(body services.GetIINDetailsRequest, context communication.CallContext) (services.GetIINDetailsResponse, error) { 131 var resultObject services.GetIINDetailsResponse 132 133 uri, err := c.apiResource.InstantiateURIWithContext("/v1/{merchantId}/services/getIINdetails", nil) 134 if err != nil { 135 return resultObject, err 136 } 137 138 clientHeaders := c.apiResource.ClientHeaders() 139 140 postErr := c.apiResource.Communicator().Post(uri, clientHeaders, nil, body, context, &resultObject) 141 if postErr != nil { 142 responseError, isResponseError := postErr.(*sdkErrors.ResponseError) 143 if isResponseError { 144 var errorObject interface{} 145 146 errorObject = &errors.ErrorResponse{} 147 err = c.apiResource.Communicator().Marshaller().Unmarshal(responseError.Body(), errorObject) 148 if err != nil { 149 return resultObject, err 150 } 151 152 err, createErr := sdkErrors.CreateAPIError(responseError.StatusCode(), responseError.Body(), errorObject, context) 153 if createErr != nil { 154 return resultObject, createErr 155 } 156 157 return resultObject, err 158 } 159 160 return resultObject, postErr 161 } 162 163 return resultObject, nil 164 } 165 166 // Privacypolicy represents the resource /{merchantId}/services/privacypolicy - Get privacy policy 167 // Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/services/privacypolicy.html 168 // 169 // Can return any of the following errors: 170 // * ValidationError if the request was not correct and couldn't be processed (HTTP status code 400) 171 // * AuthorizationError if the request was not allowed (HTTP status code 403) 172 // * IdempotenceError if an idempotent request caused a conflict (HTTP status code 409) 173 // * ReferenceError if an object was attempted to be referenced that doesn't exist or has been removed, 174 // or there was a conflict (HTTP status code 404, 409 or 410) 175 // * GlobalCollectError if something went wrong at the Ingenico ePayments platform, 176 // the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, 177 // or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503) 178 // * APIError if the Ingenico ePayments platform returned any other error 179 func (c *Client) Privacypolicy(query PrivacypolicyParams, context communication.CallContext) (services.GetPrivacyPolicyResponse, error) { 180 var resultObject services.GetPrivacyPolicyResponse 181 182 uri, err := c.apiResource.InstantiateURIWithContext("/v1/{merchantId}/services/privacypolicy", nil) 183 if err != nil { 184 return resultObject, err 185 } 186 187 clientHeaders := c.apiResource.ClientHeaders() 188 189 getErr := c.apiResource.Communicator().Get(uri, clientHeaders, &query, context, &resultObject) 190 if getErr != nil { 191 responseError, isResponseError := getErr.(*sdkErrors.ResponseError) 192 if isResponseError { 193 var errorObject interface{} 194 195 errorObject = &errors.ErrorResponse{} 196 err = c.apiResource.Communicator().Marshaller().Unmarshal(responseError.Body(), errorObject) 197 if err != nil { 198 return resultObject, err 199 } 200 201 err, createErr := sdkErrors.CreateAPIError(responseError.StatusCode(), responseError.Body(), errorObject, context) 202 if createErr != nil { 203 return resultObject, createErr 204 } 205 206 return resultObject, err 207 } 208 209 return resultObject, getErr 210 } 211 212 return resultObject, nil 213 } 214 215 // Testconnection represents the resource /{merchantId}/services/testconnection - Test connection 216 // Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/services/testconnection.html 217 // 218 // Can return any of the following errors: 219 // * ValidationError if the request was not correct and couldn't be processed (HTTP status code 400) 220 // * AuthorizationError if the request was not allowed (HTTP status code 403) 221 // * IdempotenceError if an idempotent request caused a conflict (HTTP status code 409) 222 // * ReferenceError if an object was attempted to be referenced that doesn't exist or has been removed, 223 // or there was a conflict (HTTP status code 404, 409 or 410) 224 // * GlobalCollectError if something went wrong at the Ingenico ePayments platform, 225 // the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, 226 // or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503) 227 // * APIError if the Ingenico ePayments platform returned any other error 228 func (c *Client) Testconnection(context communication.CallContext) (services.TestConnection, error) { 229 var resultObject services.TestConnection 230 231 uri, err := c.apiResource.InstantiateURIWithContext("/v1/{merchantId}/services/testconnection", nil) 232 if err != nil { 233 return resultObject, err 234 } 235 236 clientHeaders := c.apiResource.ClientHeaders() 237 238 getErr := c.apiResource.Communicator().Get(uri, clientHeaders, nil, context, &resultObject) 239 if getErr != nil { 240 responseError, isResponseError := getErr.(*sdkErrors.ResponseError) 241 if isResponseError { 242 var errorObject interface{} 243 244 errorObject = &errors.ErrorResponse{} 245 err = c.apiResource.Communicator().Marshaller().Unmarshal(responseError.Body(), errorObject) 246 if err != nil { 247 return resultObject, err 248 } 249 250 err, createErr := sdkErrors.CreateAPIError(responseError.StatusCode(), responseError.Body(), errorObject, context) 251 if createErr != nil { 252 return resultObject, createErr 253 } 254 255 return resultObject, err 256 } 257 258 return resultObject, getErr 259 } 260 261 return resultObject, nil 262 } 263 264 // NewClient constructs a Services Client 265 // 266 // parent is the *apiresource.APIResource on top of which we want to build the new Services Client 267 func NewClient(parent *apiresource.APIResource, pathContext map[string]string) *Client { 268 apiResource := apiresource.NewAPIResourceWithParent(parent, pathContext) 269 270 return &Client{apiResource} 271 }