eps-rapid 1.1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e74a7d9580ae563ef8d367ce748691c80fdde1ec01e7849466d8fdc2d7fcb3e
4
- data.tar.gz: 4aa354de65648601c5eca059b1429d2ef8ced7e3299ba8b006f1eda1a63f0610
3
+ metadata.gz: 3b7954810099c42c3f5afa0cbf1149e03cffa77fa461663ad1cc31e1a9c23fee
4
+ data.tar.gz: 226f6e7d9cd8f080da039b04b13e56fe7ee5cb952aef350514c4c60a25597406
5
5
  SHA512:
6
- metadata.gz: 86d9efda010d3c6cd963b50cef0e7bd5ff50e9361e78f028a5a19885e64aee977bf5b5b2494a87274d861e979f909fe912ce838ca6aa509e6bf5cb7ee49488b5
7
- data.tar.gz: bde4281965bd918dd31ca578edd4a3f017cc2cb3c3895365589df8a6d6435356499e0b679030e3ff91dda0908af2f7ff8a656c00e7d521c637f1fd5032dc3340
6
+ metadata.gz: ca1ea0705b9dd8f8ff46135096102035940ce75c8df5fc42a6f3c99481276042117909667a0b36b52b957190713997b950e8da83aeb9558e9f1343a9ab71916e
7
+ data.tar.gz: a75e69ad91e8d1fc1a4c0a0d714ef200f482ffe66b80af000b20e1430ac8d0feed0ae114a9a958964567487582be6464f37d23302a4ecf599c150af85d53437a
data/CHANGELOG.MD CHANGED
@@ -28,3 +28,9 @@
28
28
  ### Version 1.1.1
29
29
  # Patched
30
30
  - support for multi-value params, i.e. `property_id: [1234, 2345]` is translated to `property_id=1234&property_id=2345`
31
+ ### Version 1.1.3
32
+ # Patched
33
+ - support 202 response
34
+ ### Version 1.2.0
35
+ # Changed
36
+ - configuration: language -> language_resolver
data/README.md CHANGED
@@ -19,7 +19,7 @@ EpsRapid.configure do |c|
19
19
  c.api_key = 'YOUR_API_KEY'
20
20
  c.secret_key = 'YOUR_SECRET_KEY'
21
21
  c.base_path = 'BASE_PATH'
22
- c.language = 'en-US'
22
+ c.language_resolver = proc { 'en-US' }
23
23
  c.logger = Logger.new(nil)
24
24
  end
25
25
  ```
@@ -46,7 +46,7 @@ module EpsRapid
46
46
 
47
47
  def generate_uri(path, params)
48
48
  uri = URI("#{EpsRapid.base_path}/#{path}")
49
- params.merge!({ language: EpsRapid.language })
49
+ params.merge!({ language: language })
50
50
  transformed_params = transform_params(params)
51
51
  transformed_params.reject { |k,_| k == :customer_ip }
52
52
  uri.query = URI.encode_www_form(transformed_params) unless path.include?('token')
@@ -54,6 +54,10 @@ module EpsRapid
54
54
  uri
55
55
  end
56
56
 
57
+ def language
58
+ EpsRapid.language_resolver.call
59
+ end
60
+
57
61
  def transform_params(params)
58
62
  params.each do |k, v|
59
63
  params[k] =
@@ -88,9 +92,13 @@ module EpsRapid
88
92
  case response.code.to_i
89
93
  when HttpStatusCodes::HTTP_OK_CODE, HttpStatusCodes::HTTP_CREATED_CODE
90
94
  JSON.parse(response.body)
95
+ when HttpStatusCodes::HTTP_ACCEPTED_CODE
96
+ { 'status' => 202 }
91
97
  when HttpStatusCodes::HTTP_NO_CONTENT_CODE
92
98
  { 'status' => 204 }
93
99
  else
100
+ logger.warn("Request with error: #{uri} headers=(#{req.to_hash}): body=(#{req.body})")
101
+ logger.warn("Response with error: #{response.code} headers=(#{response.to_hash}): body=(#{response.body})")
94
102
  raise error_class(response.code), "Code: #{response.code}, Error: #{map_error_messages(response.body)}"
95
103
  end
96
104
  end
@@ -4,6 +4,7 @@ module EpsRapid
4
4
  module HttpStatusCodes
5
5
  HTTP_OK_CODE = 200
6
6
  HTTP_CREATED_CODE = 201
7
+ HTTP_ACCEPTED_CODE = 202
7
8
  HTTP_NO_CONTENT_CODE = 204
8
9
  HTTP_BAD_REQUEST_CODE = 400
9
10
  HTTP_UNAUTHORIZED_CODE = 401
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EpsRapid
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.1'
5
5
  end
data/lib/eps-rapid.rb CHANGED
@@ -16,7 +16,7 @@ require 'logger'
16
16
 
17
17
  module EpsRapid
18
18
  class << self
19
- attr_accessor :api_key, :secret_key, :base_path, :language, :logger
19
+ attr_accessor :api_key, :secret_key, :base_path, :language_resolver, :logger
20
20
 
21
21
  def configure
22
22
  yield(self)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eps-rapid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Leonenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-08 00:00:00.000000000 Z
11
+ date: 2022-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec