voucherify 1.6.0 → 1.6.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
  SHA1:
3
- metadata.gz: 800036b75eddda37c21f8810e7714115199ee6fe
4
- data.tar.gz: e532b67e12613ee8614fd905871ba8b0f2f67245
3
+ metadata.gz: 565a60929212c4c5bae7f6a80c58eae860a41904
4
+ data.tar.gz: 40734fd92df41e7c3371e3328f9e3dec5b5e3edd
5
5
  SHA512:
6
- metadata.gz: 06b366360954a90095a9bff92a3bf14eee34d48acdd50318cce48cce476bf10c9db698b07f87501b1298cbbbcdd196b89a51195aa432c9def0c238dde73c3150
7
- data.tar.gz: 42915e671bfb83780614f35966d6af50868cc55cd00a01d4799f4807de81bb15827d98e39b7d62fbd44cdba08bf03b72641f113097b4190adbc0fa1845e41ff9
6
+ metadata.gz: 9802c34e91ac73d8ea0311050f6c7ea8bf65c5aa6569361b12f5d0a6fe33898f95142e5f9697159bd348b447b5282cdb872b3fed662e8aa5a4877624a25f8c7d
7
+ data.tar.gz: c2cc18cffaa6cadd8e91b871fc40b68e9ae431e2463a9d0faa1ba89f42546cb42c2ac3fe69484a8ce39b3ce9140ce20643920250b3f4f883ca1165abf47235ea
data/README.md CHANGED
@@ -91,6 +91,16 @@ voucherify = Voucherify::Client.new({
91
91
  })
92
92
  ```
93
93
 
94
+ and timeout settings:
95
+ ```ruby
96
+ voucherify = Voucherify::Client.new({
97
+ :applicationId => 'YOUR-APPLICATION-ID',
98
+ :clientSecretKey => 'YOUR-CLIENT-SECRET-KEY',
99
+ :apiVersion => 'v2017-04-05',
100
+ :timeout => 10 // in seconds
101
+ })
102
+ ```
103
+
94
104
  ## API
95
105
 
96
106
  This SDK is fully consistent with restful API Voucherify provides.
@@ -546,6 +556,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
546
556
  Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk.
547
557
 
548
558
  ## Changelog
559
+ - **2018-09-05** - `1.6.1` - Request timeout settings
549
560
  - **2017-11-16** - `1.6.0` - Expose promotion API, Redemptions and Validations namespace update
550
561
  - **2017-11-16** - `1.5.0` - Expose events API
551
562
  - **2017-05-07** - `1.4.0` - Segments, Validation rules, API Versioning
@@ -17,6 +17,7 @@ module Voucherify
17
17
  'X-Voucherify-API-Version' => @options[:apiVersion] || @options['apiVersion'],
18
18
  :accept => :json,
19
19
  }.reject{ |k,v| v.nil? }
20
+ @timeout = @options[:timeout] || @options['timeout']
20
21
  end
21
22
 
22
23
  def vouchers
@@ -66,7 +67,7 @@ module Voucherify
66
67
  def get(path, params = {})
67
68
  begin
68
69
  url = @backend_url + path
69
- response = RestClient.get(url, @headers.merge({:params => params}))
70
+ response = RestClient::Request::execute(method: :get, url: url, headers: @headers.merge({:params => params}), read_timeout: @timeout, open_timeout: @timeout)
70
71
  JSON.parse(response.body)
71
72
  rescue RestClient::Exception => e
72
73
  raise VoucherifyError.new(e)
@@ -76,7 +77,7 @@ module Voucherify
76
77
  def put(path, body, params = {})
77
78
  begin
78
79
  url = @backend_url + path
79
- response = RestClient.put(url, body, @headers.merge({:params => params, :content_type => :json}))
80
+ response = RestClient::Request::execute(method: :put, url: url, payload: body, headers: @headers.merge({:params => params, :content_type => :json}), read_timeout: @timeout, open_timeout: @timeout)
80
81
  JSON.parse(response.body)
81
82
  rescue RestClient::Exception => e
82
83
  raise VoucherifyError.new(e)
@@ -86,7 +87,7 @@ module Voucherify
86
87
  def post(path, body, params = {})
87
88
  begin
88
89
  url = @backend_url + path
89
- response = RestClient.post(url, body, @headers.merge({:params => params, :content_type => :json}))
90
+ response = RestClient::Request::execute(method: :post, url: url, payload: body, headers: @headers.merge({:params => params, :content_type => :json}), read_timeout: @timeout, open_timeout: @timeout)
90
91
  if !response.body.empty?
91
92
  JSON.parse(response.body)
92
93
  else
@@ -100,7 +101,7 @@ module Voucherify
100
101
  def delete(path, params = {})
101
102
  begin
102
103
  url = @backend_url + path
103
- RestClient.delete(url, @headers.merge({:params => params}))
104
+ RestClient::Request::execute(method: :delete, url: url, headers: @headers.merge({:params => params}), read_timeout: @timeout, open_timeout: @timeout)
104
105
  nil
105
106
  rescue RestClient::Exception => e
106
107
  raise VoucherifyError.new(e)
@@ -115,6 +116,11 @@ module Voucherify
115
116
  attr_reader :key
116
117
 
117
118
  def initialize (restClientError)
119
+ if restClientError.is_a? RestClient::Exceptions::Timeout
120
+ @response = restClientError
121
+ @details = restClientError
122
+ super(restClientError)
123
+ else
118
124
  @response = restClientError.response
119
125
  parsedResponse = JSON.parse(@response)
120
126
  @code = parsedResponse['code']
@@ -123,5 +129,6 @@ module Voucherify
123
129
  super(parsedResponse['message'])
124
130
  end
125
131
  end
132
+ end
126
133
 
127
134
  end
@@ -1,3 +1,3 @@
1
1
  module Voucherify
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voucherify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawelrychlik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-30 00:00:00.000000000 Z
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.5.2
139
+ rubygems_version: 2.5.2.3
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Ruby SDK for Voucherify. More info on http://www.voucherify.io