lib/mangopay.rb in mangopay-3.0.27 vs lib/mangopay.rb in mangopay-3.0.28

- old
+ new

@@ -97,10 +97,18 @@ yield ensure MangoPay.configuration = original_config end + def ratelimit + @ratelimit + end + + def ratelimit=(obj) + @ratelimit = obj + end + # # - +method+: HTTP method; lowercase symbol, e.g. :get, :post etc. # - +url+: the part after Configuration#root_url # - +params+: hash; entity data for creation, update etc.; will dump it by JSON and assign to Net::HTTPRequest#body # - +filters+: hash; pagination params etc.; will encode it by URI and assign to URI#query @@ -136,9 +144,17 @@ # copy pagination info if any ['x-number-of-pages', 'x-number-of-items'].each { |k| filters[k.gsub('x-number-of-', 'total_')] = res[k].to_i if res[k] } + + if res['x-ratelimit'] + self.ratelimit = { + limit: res['x-ratelimit'].split(", "), + remaining: res['x-ratelimit-remaining'].split(", "), + reset: res['x-ratelimit-reset'].split(", ") + } + end data end # Retrieve a previous response by idempotency_key