amazon-pay-api-sdk-ruby 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +161 -27
- data/lib/amazon_pay/client.rb +89 -1
- data/lib/amazon_pay/constants.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 428da5a80e49d6cf400205eea58757174f259abce2bb6cc7a83aecd0c1554f5f
|
4
|
+
data.tar.gz: b809960b865a226d7796e506d1712759c0db90119cd886942b5aa9d6ed125681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70c5fb962cf91183aca482ad024752e41a11e398cc666bc87aae026cfbef0efa813b0e36d3b5352f184638efe633f6811927db2a29607b115e59fb1af05836a4
|
7
|
+
data.tar.gz: 4f62e310db2e153b5c3110a36498e66a81f0f99d9bed70de7c8722feb1c076392b510233df447f37663e23634a5d567b118806beadc01749947de3817efda2df
|
data/README.md
CHANGED
@@ -86,35 +86,17 @@ createMerchantAccountPayload = {
|
|
86
86
|
}
|
87
87
|
}
|
88
88
|
},
|
89
|
-
|
90
|
-
|
91
|
-
"personId": "BO1",
|
92
|
-
"personFullName": "ABC ABC",
|
89
|
+
"beneficiaryOwners": [{
|
90
|
+
"personFullName": "Rufus Rufus",
|
93
91
|
"residentialAddress": {
|
94
|
-
"addressLine1": "
|
95
|
-
"addressLine2": "
|
96
|
-
"city": "
|
97
|
-
"stateOrRegion": "
|
98
|
-
"postalCode": "
|
92
|
+
"addressLine1": "4-7, Sunny Mansion 203",
|
93
|
+
"addressLine2": "Boren Ave",
|
94
|
+
"city": "Chiryushi",
|
95
|
+
"stateOrRegion": "AICHI",
|
96
|
+
"postalCode": "4720021",
|
99
97
|
"countryCode": "JP",
|
100
98
|
"phoneNumber": {
|
101
|
-
"countryCode": "
|
102
|
-
"number": "2062062061"
|
103
|
-
}
|
104
|
-
}
|
105
|
-
},
|
106
|
-
{
|
107
|
-
"personId": "BO2",
|
108
|
-
"personFullName": "ABC ABC",
|
109
|
-
"residentialAddress": {
|
110
|
-
"addressLine1": "122, ABC XYZ",
|
111
|
-
"addressLine2": "XYZ",
|
112
|
-
"city": "XYZ",
|
113
|
-
"stateOrRegion": "XYZ",
|
114
|
-
"postalCode": "123456",
|
115
|
-
"countryCode": "JP",
|
116
|
-
"phoneNumber": {
|
117
|
-
"countryCode": "123",
|
99
|
+
"countryCode": "81",
|
118
100
|
"number": "2062062061"
|
119
101
|
}
|
120
102
|
}
|
@@ -205,9 +187,11 @@ merchantAccountClaimPayload = {
|
|
205
187
|
}
|
206
188
|
|
207
189
|
response = client.merchant_account_claim('XXXXXXXXX', merchantAccountClaimPayload, headers: {})
|
208
|
-
if response.code.to_i == 303
|
190
|
+
if response.code.to_i == 303 || response.code.to_i == 200
|
209
191
|
puts "Merchant Account Claim API Response:"
|
210
192
|
puts response.body
|
193
|
+
puts "Headers:"
|
194
|
+
puts response.to_hash.to_json
|
211
195
|
else
|
212
196
|
puts "Error: Merchant Account Claim API"
|
213
197
|
puts "Status: #{response.code}"
|
@@ -610,4 +594,154 @@ else
|
|
610
594
|
puts "Status: #{response.code}"
|
611
595
|
puts response.body
|
612
596
|
end
|
597
|
+
```
|
598
|
+
|
599
|
+
### Get Reports
|
600
|
+
|
601
|
+
```ruby
|
602
|
+
response = client.get_reports(query_params: {})
|
603
|
+
if response.code.to_i == 200
|
604
|
+
puts "Get Reports Response:"
|
605
|
+
puts response.body
|
606
|
+
else
|
607
|
+
puts "Error: Get Reports API"
|
608
|
+
puts "Status: #{response.code}"
|
609
|
+
puts response.body
|
610
|
+
end
|
611
|
+
```
|
612
|
+
|
613
|
+
### Get Report By Id
|
614
|
+
|
615
|
+
```ruby
|
616
|
+
def report_id = "123456789"
|
617
|
+
response = client.get_report_by_id(report_id, headers: {})
|
618
|
+
if response.code.to_i == 200
|
619
|
+
puts "Get Report By Id Response:"
|
620
|
+
puts response.body
|
621
|
+
else
|
622
|
+
puts "Error: Get Report By Id API"
|
623
|
+
puts "Status: #{response.code}"
|
624
|
+
puts response.body
|
625
|
+
end
|
626
|
+
```
|
627
|
+
|
628
|
+
### Create Report
|
629
|
+
|
630
|
+
```ruby
|
631
|
+
def create_report_payload = {
|
632
|
+
"reportType": "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_",
|
633
|
+
"startTime": "20240810T000000Z",
|
634
|
+
"endTime": "20240815T000000Z"
|
635
|
+
}
|
636
|
+
response = client.create_report(create_report_payload, headers: {"x-amz-pay-Idempotency-Key": SecureRandom.uuid})
|
637
|
+
if response.code.to_i == 201
|
638
|
+
puts "Create Report Response:"
|
639
|
+
puts response.body
|
640
|
+
else
|
641
|
+
puts "Error: Create Report API"
|
642
|
+
puts "Status: #{response.code}"
|
643
|
+
puts response.body
|
644
|
+
end
|
645
|
+
```
|
646
|
+
|
647
|
+
### Get Report Document
|
648
|
+
|
649
|
+
|
650
|
+
```ruby
|
651
|
+
def report_document_id = "123456789"
|
652
|
+
response = client.get_report_document(report_document_id, headers: {})
|
653
|
+
if response.code.to_i == 200
|
654
|
+
puts "Get Report Document Response:"
|
655
|
+
puts response.body
|
656
|
+
else
|
657
|
+
puts "Error: Get Report Document API"
|
658
|
+
puts "Status: #{response.code}"
|
659
|
+
puts response.body
|
660
|
+
end
|
661
|
+
```
|
662
|
+
|
663
|
+
### Get Report Schedules
|
664
|
+
|
665
|
+
```ruby
|
666
|
+
def query_params = {
|
667
|
+
"reportType": "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_",
|
668
|
+
}
|
669
|
+
response = client.get_report_schedules(query_params: query_params, headers: {})
|
670
|
+
if response.code.to_i == 200
|
671
|
+
puts "Get Report Schedules Response:"
|
672
|
+
puts response.body
|
673
|
+
else
|
674
|
+
puts "Error: Get Report Schedules API"
|
675
|
+
puts "Status: #{response.code}"
|
676
|
+
puts response.body
|
677
|
+
end
|
678
|
+
```
|
679
|
+
|
680
|
+
### Get Report Schedule By ID
|
681
|
+
|
682
|
+
```ruby
|
683
|
+
def report_schedule_id = "123456789"
|
684
|
+
response = client.get_report_schedule_by_id(report_schedule_id, headers: {})
|
685
|
+
if response.code.to_i == 200
|
686
|
+
puts "Get Report Schedule By ID Response:"
|
687
|
+
puts response.body
|
688
|
+
else
|
689
|
+
puts "Error: Get Report Schedule By ID API"
|
690
|
+
puts "Status: #{response.code}"
|
691
|
+
puts response.body
|
692
|
+
end
|
693
|
+
```
|
694
|
+
|
695
|
+
### Create Report Schedule
|
696
|
+
|
697
|
+
```ruby
|
698
|
+
def create_report_schdule_payload = {
|
699
|
+
"reportType": "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SANDBOX_SETTLEMENT_DATA_",
|
700
|
+
"scheduleFrequency": "P1D",
|
701
|
+
"nextReportCreationTime": "20241001T000000Z"
|
702
|
+
}
|
703
|
+
response = client.create_report_schedule(create_report_schdule_payload, headers: {"x-amz-pay-Idempotency-Key": SecureRandom.uuid}, query_params: {})
|
704
|
+
if response.code.to_i == 201
|
705
|
+
puts "Create Report Schedule Response:"
|
706
|
+
puts response.body
|
707
|
+
else
|
708
|
+
puts "Error: Create Report Schedule API"
|
709
|
+
puts "Status: #{response.code}"
|
710
|
+
puts response.body
|
711
|
+
end
|
712
|
+
```
|
713
|
+
|
714
|
+
#### Cancel Report Schedule
|
715
|
+
|
716
|
+
```ruby
|
717
|
+
def report_schedule_id = "123456789"
|
718
|
+
response = client.cancel_report_schedule(report_schedule_id, headers: {})
|
719
|
+
if response.code.to_i == 200
|
720
|
+
puts "Cancel Report Schedule Schedule Response:"
|
721
|
+
puts response.body
|
722
|
+
else
|
723
|
+
puts "Error: Cancel Report Schedule Schedule API"
|
724
|
+
puts "Status: #{response.code}"
|
725
|
+
puts response.body
|
726
|
+
end
|
727
|
+
```
|
728
|
+
|
729
|
+
### Get Disbursements
|
730
|
+
|
731
|
+
```ruby
|
732
|
+
def query_params = {
|
733
|
+
"startTime": '20240810T000000Z',
|
734
|
+
"endTime": '20240815T000000Z'
|
735
|
+
"pageSize": "30",
|
736
|
+
"nextToken": ""
|
737
|
+
}
|
738
|
+
response = client.get_disbursements(query_params: {}, headers: {})
|
739
|
+
if response.code.to_i == 200
|
740
|
+
puts "Get Disbursements Response:"
|
741
|
+
puts response.body
|
742
|
+
else
|
743
|
+
puts "Error: Get Disbursements API"
|
744
|
+
puts "Status: #{response.code}"
|
745
|
+
puts response.body
|
746
|
+
end
|
613
747
|
```
|
data/lib/amazon_pay/client.rb
CHANGED
@@ -47,7 +47,6 @@ class AmazonPayClient
|
|
47
47
|
|
48
48
|
# Increment the retry counter
|
49
49
|
retries += 1
|
50
|
-
print "Retrying\n"
|
51
50
|
# Raise an exception to force a retry
|
52
51
|
raise "Transient error: #{response.code}" # Force retry
|
53
52
|
end
|
@@ -266,4 +265,93 @@ class AmazonPayClient
|
|
266
265
|
api_call("#{Constants::REFUNDS_URL}/#{refund_id}", Constants::GET, headers: headers)
|
267
266
|
end
|
268
267
|
|
268
|
+
# API to retrieve a list of reports
|
269
|
+
# Retrieves a list of reports based on the provided query parameters.
|
270
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#get-reports
|
271
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
272
|
+
# @param {Object} query_params - Query parameters to filter the reports, such as report type or processing status.
|
273
|
+
# @return [HTTPResponse] The response from the API call, which includes a list of reports matching the criteria.
|
274
|
+
def get_reports(headers: {}, query_params: {})
|
275
|
+
api_call(Constants::REPORTS, Constants::GET, headers: headers, query_params: query_params)
|
276
|
+
end
|
277
|
+
|
278
|
+
# API to retrieve a specific report by ID
|
279
|
+
# Retrieves details of a specific report using its unique report ID.
|
280
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#get-report-by-id
|
281
|
+
# @param {String} report_id - The unique ID of the report to retrieve.
|
282
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
283
|
+
# @return [HTTPResponse] The response from the API call, which includes details of the requested report.
|
284
|
+
def get_report_by_id(report_id, headers: {})
|
285
|
+
api_call("#{Constants::REPORTS}/#{report_id}", Constants::GET, headers: headers)
|
286
|
+
end
|
287
|
+
|
288
|
+
# API to create a new report
|
289
|
+
# Creates a new report based on the provided payload.
|
290
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#create-report
|
291
|
+
# @param {Object} payload - The payload containing data required to generate the report.
|
292
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
293
|
+
# @return [HTTPResponse] The response from the API call, which includes confirmation and details of the created report.
|
294
|
+
def create_report(payload, headers: {})
|
295
|
+
api_call(Constants::REPORTS, Constants::POST, payload: payload, headers: headers)
|
296
|
+
end
|
297
|
+
|
298
|
+
# API to retrieve a specific report document by ID
|
299
|
+
# Retrieves the content of a specific report document using its unique report document ID.
|
300
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#get-report-document
|
301
|
+
# @param {String} report_document_id - The unique ID of the report document to retrieve.
|
302
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
303
|
+
# @return [HTTPResponse] The response from the API call, which includes the content of the requested report document.
|
304
|
+
def get_report_document(report_document_id, headers: {})
|
305
|
+
api_call("#{Constants::REPORT_DOCUMENTS}/#{report_document_id}", Constants::GET, headers: headers)
|
306
|
+
end
|
307
|
+
|
308
|
+
# API to retrieve a list of report schedules
|
309
|
+
# Retrieves a list of report schedules based on the provided query parameters.
|
310
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#get-report-schedules
|
311
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
312
|
+
# @param {Object} query_params - Query parameters to filter the report schedules, such as schedule type or status.
|
313
|
+
# @return [HTTPResponse] The response from the API call, which includes a list of report schedules matching the criteria.
|
314
|
+
def get_report_schedules(headers: {}, query_params: {})
|
315
|
+
api_call(Constants::REPORT_SCHEDULES, Constants::GET, headers: headers, query_params: query_params)
|
316
|
+
end
|
317
|
+
|
318
|
+
# API to retrieve a specific report schedule by ID
|
319
|
+
# Retrieves details of a specific report schedule using its unique report schedule ID.
|
320
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#get-report-schedule-by-id
|
321
|
+
# @param {String} report_schedule_id - The unique ID of the report schedule to retrieve.
|
322
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
323
|
+
# @return [HTTPResponse] The response from the API call, which includes details of the requested report schedule.
|
324
|
+
def get_report_schedule_by_id(report_schedule_id, headers: {})
|
325
|
+
api_call("#{Constants::REPORT_SCHEDULES}/#{report_schedule_id}", Constants::GET, headers: headers)
|
326
|
+
end
|
327
|
+
|
328
|
+
# API to create a new report schedule
|
329
|
+
# Creates a new report schedule based on the provided payload.
|
330
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#create-report-schedule
|
331
|
+
# @param {Object} payload - The payload containing data required to set up the report schedule.
|
332
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
333
|
+
# @return [HTTPResponse] The response from the API call, which includes confirmation and details of the created report schedule.
|
334
|
+
def create_report_schedule(payload, headers: {}, query_params: {})
|
335
|
+
api_call(Constants::REPORT_SCHEDULES, Constants::POST, payload: payload, headers: headers, query_params: query_params)
|
336
|
+
end
|
337
|
+
|
338
|
+
# API to cancel an existing report schedule by ID
|
339
|
+
# Cancels a specific report schedule using its unique report schedule ID.
|
340
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#cancel-report-schedule
|
341
|
+
# @param {String} report_schedule_id - The unique ID of the report schedule to cancel.
|
342
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
343
|
+
# @return [HTTPResponse] The response from the API call, which includes confirmation of the cancellation.
|
344
|
+
def cancel_report_schedule(report_schedule_id, headers: {})
|
345
|
+
api_call("#{Constants::REPORT_SCHEDULES}/#{report_schedule_id}", Constants::DELETE, headers: headers)
|
346
|
+
end
|
347
|
+
|
348
|
+
# API to retrieve a list of disbursements
|
349
|
+
# Retrieves a list of disbursements based on the provided query parameters.
|
350
|
+
# @see https://developer.amazon.com/docs/amazon-pay-api-v2/reports.html#get-disbursements
|
351
|
+
# @param {Object} headers - Optional headers for the request, such as authorization tokens or custom headers.
|
352
|
+
# @param {Object} query_params - Query parameters to filter the disbursements, such as date range or status.
|
353
|
+
# @return [HTTPResponse] The response from the API call, which includes a list of disbursements matching the criteria.
|
354
|
+
def get_disbursements(headers: {}, query_params: {})
|
355
|
+
api_call(Constants::DISBURSEMENTS, Constants::GET, headers: headers, query_params: query_params)
|
356
|
+
end
|
269
357
|
end
|
data/lib/amazon_pay/constants.rb
CHANGED
@@ -2,7 +2,7 @@ require 'net/http'
|
|
2
2
|
|
3
3
|
module Constants
|
4
4
|
SDK_TYPE = "amazon-pay-api-sdk-ruby".freeze
|
5
|
-
SDK_VERSION = "1.
|
5
|
+
SDK_VERSION = "1.2.0".freeze
|
6
6
|
API_VERSION = "v2".freeze
|
7
7
|
API_ENDPOINTS = {
|
8
8
|
'na' => 'pay-api.amazon.com',
|
@@ -46,4 +46,8 @@ module Constants
|
|
46
46
|
CHARGE_PERMISSIONS_URL = 'chargePermissions'.freeze
|
47
47
|
CHARGES_URL = 'charges'.freeze
|
48
48
|
REFUNDS_URL = 'refunds'.freeze
|
49
|
+
REPORTS = 'reports'.freeze
|
50
|
+
REPORT_SCHEDULES = 'report-schedules'.freeze
|
51
|
+
REPORT_DOCUMENTS = 'report-documents'.freeze
|
52
|
+
DISBURSEMENTS = 'disbursements'.freeze
|
49
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-pay-api-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AmazonPay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|