eps-rapid 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcd0be2a6d1af3b238c2ec17798b45c5ad65d8ef70bdb191fcad9d18981646ae
4
- data.tar.gz: 509b3b7ddda1704f4ef624319caa554cf5cfc764d2863502447d62515509a216
3
+ metadata.gz: 0635d7fc795915ac4229d1968713e1f78ab615ec52bd59cb9a3fce51b421ce20
4
+ data.tar.gz: fb3aab1e962108feea5d465907fd680d5c312589b1a73b143d1e61be752d4129
5
5
  SHA512:
6
- metadata.gz: 6b687c4e03a0e12afd35605d2ab68c106acd5ffa5271a3f20c0ddf05bd7e9a1b4c1f1d9a06e1fe8c8751f87dd076a254715b12af3274940b5f43926c645e661e
7
- data.tar.gz: 48c5da42c39b792eaba211f574bac1d73a8ed1c318885fe37ba56ab1559897ddf6d5b85b1f3ed967dc0dd55bfbd5b2d3e10ea5e959aeb8791b7dd954fa849b51
6
+ metadata.gz: 2f7056cc0acbedbe619bdd81c4c0120d2866c6f9940b098417eeb40238a01505d0d9e34978d6e920db583dbbb5ee7cac6075e1b49ccb886f1eeefe7442542191
7
+ data.tar.gz: 9daa91af2bd45fdf330aa182a12da06c981114f5420b8ab3dcd603a16d6c3d42d1aac63b931389c39b2d1d71a17887f70e901cf0bdf3e35742e4f4cfe7294110
data/CHANGELOG.MD CHANGED
@@ -25,3 +25,12 @@
25
25
  # Added
26
26
  - add request and response logging
27
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
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,13 +54,19 @@ 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] =
60
64
  if k == :occupancy
61
65
  v.to_s.tr(' ', '').split(';')
62
- else
66
+ elsif v.is_a?(String) || v.is_a?(Symbol) || v.is_a?(Integer)
63
67
  v.to_s.tr(' ', '').split(',')
68
+ else
69
+ v
64
70
  end
65
71
  end
66
72
  end
@@ -79,13 +85,15 @@ module EpsRapid
79
85
  req['Customer-Ip'] = customer_ip if customer_ip != ''
80
86
  req['Test'] = test_header if test_header != ''
81
87
 
82
- logger.debug("Request: #{uri.to_s}: #{req.body}")
88
+ logger.debug("Request: #{uri} headers=(#{req.to_hash}): body=(#{req.body})")
83
89
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
84
- logger.debug("Response: #{response.code.to_i}: #{response.body}")
90
+ logger.debug("Response: #{response.code.to_i} headers=(#{response.to_hash}): body=(#{response.body})")
85
91
 
86
92
  case response.code.to_i
87
93
  when HttpStatusCodes::HTTP_OK_CODE, HttpStatusCodes::HTTP_CREATED_CODE
88
94
  JSON.parse(response.body)
95
+ when HttpStatusCodes::HTTP_ACCEPTED_CODE
96
+ { 'status' => 202 }
89
97
  when HttpStatusCodes::HTTP_NO_CONTENT_CODE
90
98
  { 'status' => 204 }
91
99
  else
@@ -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.0'
4
+ VERSION = '1.2.0'
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.0
4
+ version: 1.2.0
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-11-16 00:00:00.000000000 Z
11
+ date: 2022-01-19 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.2.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