-
Notifications
You must be signed in to change notification settings - Fork 1
/
merchant.go
executable file
·635 lines (551 loc) · 20.2 KB
/
merchant.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
// Code generated by `gogenitor`. DO NOT EDIT.
package sumup
import (
"context"
"encoding/json"
"fmt"
"net/http"
)
// Account is Profile information.
type Account struct {
// The role of the user.
Type *AccountType `json:"type,omitempty"`
// Username of the user profile.
Username *string `json:"username,omitempty"`
}
// The role of the user.
type AccountType string
const (
AccountTypeNormal AccountType = "normal"
AccountTypeOperator AccountType = "operator"
)
// AddressWithDetails is Details of the registered address.
type AddressWithDetails struct {
// Address line 1
AddressLine1 *string `json:"address_line1,omitempty"`
// Address line 2
AddressLine2 *string `json:"address_line2,omitempty"`
// City
City *string `json:"city,omitempty"`
// undefined
Company *string `json:"company,omitempty"`
// Country ISO 3166-1 code
Country *string `json:"country,omitempty"`
// Country Details
CountryDetails *CountryDetails `json:"country_details,omitempty"`
// undefined
FirstName *string `json:"first_name,omitempty"`
// Landline number
Landline *string `json:"landline,omitempty"`
// undefined
LastName *string `json:"last_name,omitempty"`
// Postal code
PostCode *string `json:"post_code,omitempty"`
// Region code
RegionCode *string `json:"region_code,omitempty"`
// Country region id
RegionId *float64 `json:"region_id,omitempty"`
// Region name
RegionName *string `json:"region_name,omitempty"`
// undefined
StateId *string `json:"state_id,omitempty"`
// TimeOffset Details
TimeoffsetDetails *TimeoffsetDetails `json:"timeoffset_details,omitempty"`
}
// AppSettings is Mobile app settings
type AppSettings struct {
// Advanced mode.
AdvancedMode *string `json:"advanced_mode,omitempty"`
// Barcode scanner.
BarcodeScanner *string `json:"barcode_scanner,omitempty"`
// Cash payment.
CashPayment *string `json:"cash_payment,omitempty"`
// Checkout preference
CheckoutPreference *string `json:"checkout_preference,omitempty"`
// Expected max transaction amount.
ExpectedMaxTransactionAmount *float64 `json:"expected_max_transaction_amount,omitempty"`
// Include vat.
IncludeVat *bool `json:"include_vat,omitempty"`
// Manual entry.
ManualEntry *string `json:"manual_entry,omitempty"`
// Manual entry tutorial.
ManualEntryTutorial *bool `json:"manual_entry_tutorial,omitempty"`
// Mobile payment.
MobilePayment *string `json:"mobile_payment,omitempty"`
// Mobile payment tutorial.
MobilePaymentTutorial *bool `json:"mobile_payment_tutorial,omitempty"`
// Reader payment.
ReaderPayment *string `json:"reader_payment,omitempty"`
// Referral.
Referral *string `json:"referral,omitempty"`
// Tax enabled.
TaxEnabled *bool `json:"tax_enabled,omitempty"`
// Terminal mode tutorial.
TerminalModeTutorial *bool `json:"terminal_mode_tutorial,omitempty"`
// Tip rates.
TipRates *[]float64 `json:"tip_rates,omitempty"`
// Tipping.
Tipping *string `json:"tipping,omitempty"`
}
// BankAccount is the type definition for a BankAccount.
type BankAccount struct {
// Account category - business or personal
AccountCategory *string `json:"account_category,omitempty"`
AccountHolderName *string `json:"account_holder_name,omitempty"`
// Account number
AccountNumber *string `json:"account_number,omitempty"`
// Type of the account
AccountType *string `json:"account_type,omitempty"`
// Bank code
BankCode *string `json:"bank_code,omitempty"`
// Bank name
BankName *string `json:"bank_name,omitempty"`
// Branch code
BranchCode *string `json:"branch_code,omitempty"`
// Creation date of the bank account
CreatedAt *string `json:"created_at,omitempty"`
// IBAN
Iban *string `json:"iban,omitempty"`
// The primary bank account is the one used for payouts
Primary *bool `json:"primary,omitempty"`
// Status in the verification process
Status *string `json:"status,omitempty"`
// SWIFT code
Swift *string `json:"swift,omitempty"`
}
// BusinessOwner is the type definition for a BusinessOwner.
type BusinessOwner struct {
// Date of birth
DateOfBirth *string `json:"date_of_birth,omitempty"`
// BO's first name
FirstName *string `json:"first_name,omitempty"`
// BO's Landline
Landline *string `json:"landline,omitempty"`
// BO's last name of the user
LastName *string `json:"last_name,omitempty"`
// Mobile phone number
MobilePhone *string `json:"mobile_phone,omitempty"`
// Ownership percentage
Ownership *float64 `json:"ownership,omitempty"`
}
// BusinessOwners is Business owners information.
type BusinessOwners []BusinessOwner
// CountryDetails is Country Details
type CountryDetails struct {
// Currency ISO 4217 code
Currency *string `json:"currency,omitempty"`
// Country EN name
EnName *string `json:"en_name,omitempty"`
// Country ISO code
IsoCode *string `json:"iso_code,omitempty"`
// Country native name
NativeName *string `json:"native_name,omitempty"`
}
// DoingBusinessAs is Doing Business As information
type DoingBusinessAs struct {
Address *DoingBusinessAsAddress `json:"address,omitempty"`
// Doing business as name
BusinessName *string `json:"business_name,omitempty"`
// Doing business as company registration number
CompanyRegistrationNumber *string `json:"company_registration_number,omitempty"`
// Doing business as email
Email *string `json:"email,omitempty"`
// Doing business as VAT ID
VatId *string `json:"vat_id,omitempty"`
// Doing business as website
Website *string `json:"website,omitempty"`
}
// DoingBusinessAsAddress is the type definition for a DoingBusinessAsAddress.
type DoingBusinessAsAddress struct {
// Address line 1
AddressLine1 *string `json:"address_line1,omitempty"`
// Address line 2
AddressLine2 *string `json:"address_line2,omitempty"`
// City
City *string `json:"city,omitempty"`
// Country ISO 3166-1 code
Country *string `json:"country,omitempty"`
// Postal code
PostCode *string `json:"post_code,omitempty"`
// Country region ID
RegionId *float64 `json:"region_id,omitempty"`
// Country region name
RegionName *string `json:"region_name,omitempty"`
}
// LegalType is Id of the legal type of the merchant profile
type LegalType struct {
// Legal type short description
Description *string `json:"description,omitempty"`
// Legal type description
FullDescription *string `json:"full_description,omitempty"`
// Unique id
Id *float64 `json:"id,omitempty"`
// Sole trader legal type if true
SoleTrader *bool `json:"sole_trader,omitempty"`
}
// MerchantAccount is Details of the merchant account.
type MerchantAccount struct {
// Profile information.
Account *Account `json:"account,omitempty"`
// Mobile app settings
AppSettings *AppSettings `json:"app_settings,omitempty"`
// Merchant comes from payleven BR migration
IsMigratedPaylevenBr *bool `json:"is_migrated_payleven_br,omitempty"`
// Account's merchant profile
MerchantProfile *MerchantProfile `json:"merchant_profile,omitempty"`
// User permissions
Permissions *Permissions `json:"permissions,omitempty"`
// Account's personal profile.
PersonalProfile *PersonalProfile `json:"personal_profile,omitempty"`
}
// MerchantProfile is Account's merchant profile
type MerchantProfile struct {
// Details of the registered address.
Address *AddressWithDetails `json:"address,omitempty"`
BankAccounts *[]BankAccount `json:"bank_accounts,omitempty"`
// Business owners information.
BusinessOwners *BusinessOwners `json:"business_owners,omitempty"`
// Company name
CompanyName *string `json:"company_name,omitempty"`
// Company registration number
CompanyRegistrationNumber *string `json:"company_registration_number,omitempty"`
// Merchant country code formatted according to [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) (for internal usage only)
Country *string `json:"country,omitempty"`
// Doing Business As information
DoingBusinessAs *DoingBusinessAs `json:"doing_business_as,omitempty"`
// True if the merchant is extdev
Extdev *bool `json:"extdev,omitempty"`
// Id of the legal type of the merchant profile
LegalType *LegalType `json:"legal_type,omitempty"`
// Merchant locale (for internal usage only)
Locale *string `json:"locale,omitempty"`
// Merchant category code
MerchantCategoryCode *string `json:"merchant_category_code,omitempty"`
// Unique identifying code of the merchant profile
MerchantCode *string `json:"merchant_code,omitempty"`
// Mobile phone number
MobilePhone *string `json:"mobile_phone,omitempty"`
// Nature and purpose of the business
NatureAndPurpose *string `json:"nature_and_purpose,omitempty"`
// True if the payout zone of this merchant is migrated
PayoutZoneMigrated *bool `json:"payout_zone_migrated,omitempty"`
// Permanent certificate access code (Portugal)
PermanentCertificateAccessCode *string `json:"permanent_certificate_access_code,omitempty"`
// Merchant settings (like \"payout_type\", \"payout_period\")
Settings *MerchantSettings `json:"settings,omitempty"`
// Vat ID
VatId *string `json:"vat_id,omitempty"`
// Merchant VAT rates
VatRates *VatRates `json:"vat_rates,omitempty"`
// Website
Website *string `json:"website,omitempty"`
}
// MerchantSettings is Merchant settings (like \"payout_type\", \"payout_period\")
type MerchantSettings struct {
// Whether merchant will receive daily payout emails
DailyPayoutEmail *bool `json:"daily_payout_email,omitempty"`
// Whether merchant has gross settlement enabled
GrossSettlement *bool `json:"gross_settlement,omitempty"`
// Whether merchant will receive monthly payout emails
MonthlyPayoutEmail *bool `json:"monthly_payout_email,omitempty"`
// Whether merchant can make MOTO payments
MotoPayment *MerchantSettingsMotoPayment `json:"moto_payment,omitempty"`
// Payout Instrument
PayoutInstrument *string `json:"payout_instrument,omitempty"`
// Whether merchant will receive payouts on demand
PayoutOnDemand *bool `json:"payout_on_demand,omitempty"`
// Whether merchant can edit payouts on demand
PayoutOnDemandAvailable *bool `json:"payout_on_demand_available,omitempty"`
// Payout frequency
PayoutPeriod *string `json:"payout_period,omitempty"`
// Payout type
PayoutType *string `json:"payout_type,omitempty"`
// Whether to show printers in mobile app
PrintersEnabled *bool `json:"printers_enabled,omitempty"`
// Stone merchant code
StoneMerchantCode *string `json:"stone_merchant_code,omitempty"`
// Whether to show tax in receipts (saved per transaction)
TaxEnabled *bool `json:"tax_enabled,omitempty"`
}
// Whether merchant can make MOTO payments
type MerchantSettingsMotoPayment string
const (
MerchantSettingsMotoPaymentEnforced MerchantSettingsMotoPayment = "ENFORCED"
MerchantSettingsMotoPaymentOff MerchantSettingsMotoPayment = "OFF"
MerchantSettingsMotoPaymentOn MerchantSettingsMotoPayment = "ON"
MerchantSettingsMotoPaymentUnavailable MerchantSettingsMotoPayment = "UNAVAILABLE"
)
// Permissions is User permissions
type Permissions struct {
// Create MOTO payments
CreateMotoPayments *bool `json:"create_moto_payments,omitempty"`
// Create referral
CreateReferral *bool `json:"create_referral,omitempty"`
// Can view full merchant transaction history
FullTransactionHistoryView *bool `json:"full_transaction_history_view,omitempty"`
// Refund transactions
RefundTransactions *bool `json:"refund_transactions,omitempty"`
}
// PersonalProfile is Account's personal profile.
type PersonalProfile struct {
// Details of the registered address.
Address *AddressWithDetails `json:"address,omitempty"`
Complete *bool `json:"complete,omitempty"`
// Date of birth
DateOfBirth *string `json:"date_of_birth,omitempty"`
// First name of the user
FirstName *string `json:"first_name,omitempty"`
// Last name of the user
LastName *string `json:"last_name,omitempty"`
// Mobile phone number
MobilePhone *string `json:"mobile_phone,omitempty"`
}
// TimeoffsetDetails is TimeOffset Details
type TimeoffsetDetails struct {
// Daylight Saving Time
Dst *bool `json:"dst,omitempty"`
// UTC offset
Offset *float64 `json:"offset,omitempty"`
// Postal code
PostCode *string `json:"post_code,omitempty"`
}
// VatRates is Merchant VAT rates
type VatRates struct {
// Country ISO code
Country *string `json:"country,omitempty"`
// Description
Description *string `json:"description,omitempty"`
// Internal ID
Id *float64 `json:"id,omitempty"`
// Ordering
Ordering *float64 `json:"ordering,omitempty"`
// Rate
Rate *float64 `json:"rate,omitempty"`
}
// ListBankAccountsParams are query parameters for ListBankAccounts
type ListBankAccountsParams struct {
Primary *bool `json:"primary,omitempty"`
}
// ListBankAccountsResponse is the type definition for a ListBankAccountsResponse.
type ListBankAccountsResponse []BankAccount
// GetAccountParams are query parameters for GetAccount
type GetAccountParams struct {
Include *[]string `json:"include[],omitempty"`
}
// ListBankAccountsV11Params are query parameters for ListBankAccountsV11
type ListBankAccountsV11Params struct {
Primary *bool `json:"primary,omitempty"`
}
// ListBankAccountsV11Response is the type definition for a ListBankAccountsV11Response.
type ListBankAccountsV11Response []BankAccount
type MerchantService service
// GetPersonalProfile: Retrieve a personal profile
// Retrieves personal profile data.
func (s *MerchantService) GetPersonalProfile(ctx context.Context) (*PersonalProfile, error) {
path := fmt.Sprintf("/v0.1/me/personal-profile")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v PersonalProfile
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// GetSettings: Get settings
// Retrieves merchant settings.
func (s *MerchantService) GetSettings(ctx context.Context) (*MerchantSettings, error) {
path := fmt.Sprintf("/v0.1/me/merchant-profile/settings")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v MerchantSettings
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// GetDoingBusinessAs: Retrieve DBA
// Retrieves Doing Business As profile.
func (s *MerchantService) GetDoingBusinessAs(ctx context.Context) (*DoingBusinessAs, error) {
path := fmt.Sprintf("/v0.1/me/merchant-profile/doing-business-as")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v DoingBusinessAs
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// ListBankAccountsDeprecated: List bank accounts (deprecated)
// Retrieves bank accounts of the merchant.
func (s *MerchantService) ListBankAccountsDeprecated(ctx context.Context, params ListBankAccountsParams) (*ListBankAccountsResponse, error) {
path := fmt.Sprintf("/v0.1/me/merchant-profile/bank-accounts")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v ListBankAccountsResponse
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// GetMerchantProfile: Retrieve a merchant profile
// Retrieves merchant profile data.
func (s *MerchantService) GetMerchantProfile(ctx context.Context) (*MerchantProfile, error) {
path := fmt.Sprintf("/v0.1/me/merchant-profile")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v MerchantProfile
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// Get: Retrieve a profile
// Returns user profile information.
func (s *MerchantService) Get(ctx context.Context, params GetAccountParams) (*MerchantAccount, error) {
path := fmt.Sprintf("/v0.1/me")
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v MerchantAccount
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}
// ListBankAccounts: List bank accounts
// Retrieves bank accounts of the merchant.
func (s *MerchantService) ListBankAccounts(ctx context.Context, merchantCode string, params ListBankAccountsV11Params) (*ListBankAccountsV11Response, error) {
path := fmt.Sprintf("/v1.1/merchants/%v/bank-accounts", merchantCode)
req, err := s.client.NewRequest(ctx, http.MethodGet, path, http.NoBody)
if err != nil {
return nil, fmt.Errorf("error building request: %v", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 500 {
return nil, fmt.Errorf("invalid response: %d - %s", resp.StatusCode, http.StatusText(resp.StatusCode))
}
dec := json.NewDecoder(resp.Body)
if resp.StatusCode >= 400 {
var apiErr APIError
if err := dec.Decode(&apiErr); err != nil {
return nil, fmt.Errorf("read error response: %s", err.Error())
}
return nil, &apiErr
}
var v ListBankAccountsV11Response
if err := dec.Decode(&v); err != nil {
return nil, fmt.Errorf("decode response: %s", err.Error())
}
return &v, nil
}