eps-rapid 1.0.1 → 1.1.3

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: fd6b9fdb7c19bea18884ea30df65b97ed84880d783424dd10bf6c6cf60480a93
4
- data.tar.gz: daf9a328813667def4c5d0cac9ab990bf03e7aa65256334e4c7c93c675b44868
3
+ metadata.gz: 5976f85c0637aa878ffb789e799969ed55ecbad0f8980ecc97d8384c1d6e1995
4
+ data.tar.gz: ab27a49281db85e7ad70b54a393ed725635a0164dbab37955d518c6a92062320
5
5
  SHA512:
6
- metadata.gz: 7700ad552e2d7e7c78ead9eac6899c4f933992338c9ea9e6bfda538b493dfc1bfd6fd0e9b09e33493612fd9e45d5eeb921b6c68d2cba11141b322ad74b260305
7
- data.tar.gz: f253d0b98ab386f050fe2f6ee99db82c06b567020584745d6146d71d3541a10e28bf7a02cba0c796938a4011ac3587cfac28e625a37d6afe39318071d8a350fb
6
+ metadata.gz: dd64d892ec1f1402d2bdf5e0cada0afff49eab3ba76787a648af111a2fffe51be6a9c36c5897a6f55339f76a1d404aa376716e2aa2338df047225718593c4b10
7
+ data.tar.gz: c479486687957c8e5b1e28ab6f9d9efe0c9c198032965d2952b42cc221695062c6aad3d80831b3589526a59357a402496d63f2a4ced7a997452ccf6e05635b54
data/CHANGELOG.MD CHANGED
@@ -21,3 +21,13 @@
21
21
  ### Version 1.0.1
22
22
  # Changed
23
23
  - add compatibility with ruby 3.0.0
24
+ ### Version 1.1.0
25
+ # Added
26
+ - add request and response logging
27
+ - 204 responses returns hash
28
+ ### Version 1.1.1
29
+ # Patched
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
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # eps-rapid
2
- Ruby gem for the eps-rapid 2.4 API
2
+ Ruby gem for the eps-rapid 2.4 and 3 API
3
3
 
4
4
  ## Installation
5
5
 
@@ -20,6 +20,7 @@ EpsRapid.configure do |c|
20
20
  c.secret_key = 'YOUR_SECRET_KEY'
21
21
  c.base_path = 'BASE_PATH'
22
22
  c.language = 'en-US'
23
+ c.logger = Logger.new(nil)
23
24
  end
24
25
  ```
25
26
  Base path depends of environment and can be `https://test.ean.com/2.4` or `https://api.ean.com/2.4`
@@ -59,8 +59,10 @@ module EpsRapid
59
59
  params[k] =
60
60
  if k == :occupancy
61
61
  v.to_s.tr(' ', '').split(';')
62
- else
62
+ elsif v.is_a?(String) || v.is_a?(Symbol) || v.is_a?(Integer)
63
63
  v.to_s.tr(' ', '').split(',')
64
+ else
65
+ v
64
66
  end
65
67
  end
66
68
  end
@@ -79,13 +81,17 @@ module EpsRapid
79
81
  req['Customer-Ip'] = customer_ip if customer_ip != ''
80
82
  req['Test'] = test_header if test_header != ''
81
83
 
84
+ logger.debug("Request: #{uri} headers=(#{req.to_hash}): body=(#{req.body})")
82
85
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
86
+ logger.debug("Response: #{response.code.to_i} headers=(#{response.to_hash}): body=(#{response.body})")
83
87
 
84
88
  case response.code.to_i
85
89
  when HttpStatusCodes::HTTP_OK_CODE, HttpStatusCodes::HTTP_CREATED_CODE
86
90
  JSON.parse(response.body)
91
+ when HttpStatusCodes::HTTP_ACCEPTED_CODE
92
+ { 'status' => 202 }
87
93
  when HttpStatusCodes::HTTP_NO_CONTENT_CODE
88
- 'Code: 204, No content'
94
+ { 'status' => 204 }
89
95
  else
90
96
  raise error_class(response.code), "Code: #{response.code}, Error: #{map_error_messages(response.body)}"
91
97
  end
@@ -125,6 +131,10 @@ module EpsRapid
125
131
  parsed_errors['message']
126
132
  end
127
133
  end
134
+
135
+ def logger
136
+ EpsRapid.logger || Logger.new(nil)
137
+ end
128
138
  end
129
139
  end
130
140
  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.0.1'
4
+ VERSION = '1.1.3'
5
5
  end
data/lib/eps-rapid.rb CHANGED
@@ -12,10 +12,11 @@ require 'eps-rapid/manage_booking'
12
12
  require 'eps-rapid/recommendations'
13
13
  require 'eps-rapid/notifications'
14
14
  require 'digest'
15
+ require 'logger'
15
16
 
16
17
  module EpsRapid
17
18
  class << self
18
- attr_accessor :api_key, :secret_key, :base_path, :language
19
+ attr_accessor :api_key, :secret_key, :base_path, :language, :logger
19
20
 
20
21
  def configure
21
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.0.1
4
+ version: 1.1.3
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-06-01 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.0.3
94
+ rubygems_version: 3.2.22
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Ruby wrapper for the expediapartnersolutions.com api