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 +4 -4
- data/README.md +11 -0
- data/lib/voucherify/client.rb +11 -4
- data/lib/voucherify/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 565a60929212c4c5bae7f6a80c58eae860a41904
|
4
|
+
data.tar.gz: 40734fd92df41e7c3371e3328f9e3dec5b5e3edd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/voucherify/client.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
data/lib/voucherify/version.rb
CHANGED
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.
|
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:
|
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
|