mangopay 3.0.27 → 3.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/lib/mangopay.rb +16 -0
- data/lib/mangopay/report.rb +8 -1
- data/lib/mangopay/version.rb +1 -1
- data/spec/mangopay/report_spec.rb +2 -1
- data/spec/mangopay/report_wallets_spec.rb +40 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 879da1ad5c54a140ae4e9b9349ad40d72e44e8af
|
4
|
+
data.tar.gz: 774607d7039aff485fa77244f1d932eebfb5d32e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c4ae1839b1b35a570d22f92cc1eea8453623dc28f946a09836ab2e90cd95744c3d89d7dd8b42f9df60aec6749586c3fad5ea677a491d748a119dcb9106417ea
|
7
|
+
data.tar.gz: 192a9df0d3376c343b7fa85ebae21e710f0d59b2307e99f8d4864f0335a7f12535106565d80caa7873d6ed273c1ed97ae9d822928b57ed8185d53dd287c3e005
|
data/README.md
CHANGED
@@ -84,6 +84,25 @@ rescue MangoPay::ResponseError => ex
|
|
84
84
|
end
|
85
85
|
```
|
86
86
|
|
87
|
+
### Accessing RateLimit Headers
|
88
|
+
Along with each request, the rate limiting headers are automatically updated in MangoPay object:
|
89
|
+
|
90
|
+
* X-RateLimit-Limit
|
91
|
+
* X-RateLimit-Remaining
|
92
|
+
* X-RateLimit-Reset
|
93
|
+
|
94
|
+
```
|
95
|
+
MangoPay.ratelimit
|
96
|
+
|
97
|
+
{
|
98
|
+
:limit=>["74", "74", "75", "908"],
|
99
|
+
:remaining=>["2226", "4426", "8725", "104692"],
|
100
|
+
:reset=>["1495615620", "1495616520", "1495618320", "1495701060"]
|
101
|
+
}
|
102
|
+
```
|
103
|
+
|
104
|
+
Read more about rate limiting on [our documetiation](https://docs.mangopay.com/guide/rate-limiting).
|
105
|
+
|
87
106
|
### Log requests and responses
|
88
107
|
You can easily enable logs by setting the ```log_file``` configuration option (see the section **configuration** above). If you don't want logs, remove the ```log_file``` line.
|
89
108
|
|
data/lib/mangopay.rb
CHANGED
@@ -99,6 +99,14 @@ module MangoPay
|
|
99
99
|
MangoPay.configuration = original_config
|
100
100
|
end
|
101
101
|
|
102
|
+
def ratelimit
|
103
|
+
@ratelimit
|
104
|
+
end
|
105
|
+
|
106
|
+
def ratelimit=(obj)
|
107
|
+
@ratelimit = obj
|
108
|
+
end
|
109
|
+
|
102
110
|
#
|
103
111
|
# - +method+: HTTP method; lowercase symbol, e.g. :get, :post etc.
|
104
112
|
# - +url+: the part after Configuration#root_url
|
@@ -139,6 +147,14 @@ module MangoPay
|
|
139
147
|
filters[k.gsub('x-number-of-', 'total_')] = res[k].to_i if res[k]
|
140
148
|
}
|
141
149
|
|
150
|
+
if res['x-ratelimit']
|
151
|
+
self.ratelimit = {
|
152
|
+
limit: res['x-ratelimit'].split(", "),
|
153
|
+
remaining: res['x-ratelimit-remaining'].split(", "),
|
154
|
+
reset: res['x-ratelimit-reset'].split(", ")
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
142
158
|
data
|
143
159
|
end
|
144
160
|
|
data/lib/mangopay/report.rb
CHANGED
@@ -8,7 +8,14 @@ module MangoPay
|
|
8
8
|
|
9
9
|
# +params+: hash; see https://docs.mangopay.com/endpoints/v2.01/reporting#e825_create-a-transaction-report
|
10
10
|
def create(params, idempotency_key = nil)
|
11
|
-
|
11
|
+
if params[:ReportType] == 'transactions'
|
12
|
+
url = url() + '/transactions/'
|
13
|
+
elsif params[:ReportType] == 'wallets'
|
14
|
+
url = url() + '/wallets/'
|
15
|
+
else
|
16
|
+
raise 'When creating a report, ReportType is required. Ex: ("transactions", "wallets")'
|
17
|
+
end
|
18
|
+
|
12
19
|
MangoPay.request(:post, url, params, {}, idempotency_key)
|
13
20
|
end
|
14
21
|
|
data/lib/mangopay/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
describe MangoPay::Report do
|
2
|
+
|
3
|
+
def create
|
4
|
+
params = {
|
5
|
+
Tag: 'custom meta',
|
6
|
+
CallbackURL: 'http://www.my-site.com/callbackURL/',
|
7
|
+
DownloadFormat: 'CSV',
|
8
|
+
Sort: 'CreationDate:DESC',
|
9
|
+
Preview: false,
|
10
|
+
Filters: {},
|
11
|
+
Columns: [ 'Id', 'CreationDate' ],
|
12
|
+
ReportType: 'wallets'
|
13
|
+
}
|
14
|
+
MangoPay::Report.create(params)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'CREATE' do
|
18
|
+
it 'creates a report' do
|
19
|
+
created = create
|
20
|
+
expect(created['Id']).to_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'FETCH' do
|
25
|
+
|
26
|
+
it 'fetches a report' do
|
27
|
+
created = create
|
28
|
+
fetched = MangoPay::Report.fetch(created['Id'])
|
29
|
+
expect(fetched['Id']).to eq(created['Id'])
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'fetches all the reports' do
|
33
|
+
reports = MangoPay::Report.fetch()
|
34
|
+
expect(reports).to be_kind_of(Array)
|
35
|
+
expect(reports).not_to be_empty
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mangopay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffroy Lorieux
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-05-
|
12
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- spec/mangopay/preauthorization_spec.rb
|
132
132
|
- spec/mangopay/refund_spec.rb
|
133
133
|
- spec/mangopay/report_spec.rb
|
134
|
+
- spec/mangopay/report_wallets_spec.rb
|
134
135
|
- spec/mangopay/shared_resources.rb
|
135
136
|
- spec/mangopay/transaction_spec.rb
|
136
137
|
- spec/mangopay/transfer_spec.rb
|
@@ -191,6 +192,7 @@ test_files:
|
|
191
192
|
- spec/mangopay/preauthorization_spec.rb
|
192
193
|
- spec/mangopay/refund_spec.rb
|
193
194
|
- spec/mangopay/report_spec.rb
|
195
|
+
- spec/mangopay/report_wallets_spec.rb
|
194
196
|
- spec/mangopay/shared_resources.rb
|
195
197
|
- spec/mangopay/transaction_spec.rb
|
196
198
|
- spec/mangopay/transfer_spec.rb
|