beyond_api 0.17.0.pre → 0.18.0.pre

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: 121cdb5fc26eaefb6eb20ccad546c70508ed15517e159227b973ab95333ec30f
4
- data.tar.gz: 42bc3c28f1696e588c2ed9cd405e32ddee90b2d716299d9354773f70b18613dd
3
+ metadata.gz: e9b48b71a8bbe959b3250221b561ea742a3d82e0d80a0f0b9f4638cc2f57b5ed
4
+ data.tar.gz: 4c9353fd93cef022310c1b7ae1b147776d1e1bc6da94a751adc68f14852efb2a
5
5
  SHA512:
6
- metadata.gz: fbd457331b5d3939a81590f983eb27e2c0ef754f8d4f5cb75c25299d4fd0db0f0c206766463f3918542ef74c3db652a7f5a2b61c677addb63071091c0ed8a397
7
- data.tar.gz: 659cc4f40f38f5f36c4c0ab476720cb1a1fc7ef1a6d518b7f0d5f71d8ad3219983e8304c07c5ad8c28d20d0baa2d0225ffe0c6b8324f575f43b0f14fbc3bffb0
6
+ metadata.gz: e7cbc7f1f943fc00701e2f548756dfa0cc2808cc51096bf0c6a6be5bbf9b7edfcfd16b80ae351251feb3d26f9be0cba23df3fbf093ff4a69b5ff169b0087a297
7
+ data.tar.gz: 946ce5ce94a725e55ee7e1c172b4094b6146836c5e4f8cb28b4823c0426db1923044c4b4cc22f9f470ff55101a5698be694e82876a05f296510a07d91b465b02
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### v0.18.0.pre
2
+
3
+ * features
4
+ * Add new token retrieval/refresh methods
5
+ * `Token#authorization_code`
6
+ * `Token#refresh_token`
7
+ * `Token#client_credentials`
8
+ * Add alias methods for avoiding deprecation
9
+ * `refresh` -> `refresh_token`
10
+ * `create` -> `authorization_code`
11
+
1
12
  ### v0.17.0.pre
2
13
 
3
14
  * enhancements
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_api (0.17.0.pre)
4
+ beyond_api (0.18.0.pre)
5
5
  faraday (~> 0.15)
6
6
 
7
7
  GEM
@@ -52,4 +52,4 @@ DEPENDENCIES
52
52
  yard (~> 0.9)
53
53
 
54
54
  BUNDLED WITH
55
- 2.1.4
55
+ 2.2.26
@@ -98,8 +98,8 @@ module BeyondApi
98
98
  # }
99
99
  # },
100
100
  # "shippingPeriod" : {
101
- # "minDays" : 2,
102
- # "maxDays" : 4,
101
+ # "min" : 2,
102
+ # "max" : 4,
103
103
  # "displayUnit" : "WEEKS"
104
104
  # }
105
105
  # }'
@@ -157,8 +157,8 @@ module BeyondApi
157
157
  # }
158
158
  # },
159
159
  # "shippingPeriod": {
160
- # "minDays": 2,
161
- # "maxDays": 4,
160
+ # "min": 2,
161
+ # "max": 4,
162
162
  # "displayUnit": "WEEKS"
163
163
  # }
164
164
  # }
@@ -17,31 +17,32 @@ module BeyondApi
17
17
  raise InvalidSessionError.new("Session api_url cannot be nil") if session.api_url.nil?
18
18
  end
19
19
 
20
- def create(code)
21
- response, status = BeyondApi::Request.token(@session.api_url + "/oauth/token",
22
- grant_type: "authorization_code",
23
- code: code)
24
-
25
- handle_response(response, status)
20
+ def authorization_code(code)
21
+ handle_token_call("authorization_code", code: code)
26
22
  end
27
23
 
28
- def refresh
29
- response, status = BeyondApi::Request.token(@session.api_url + "/oauth/token",
30
- grant_type: "refresh_token",
31
- refresh_token: @session.refresh_token)
32
-
33
- handle_response(response, status)
24
+ def refresh_token
25
+ handle_token_call("refresh_token", refresh_token: @session.refresh_token)
34
26
  end
35
27
 
36
28
  def client_credentials
29
+ handle_token_call("client_credentials")
30
+ end
31
+
32
+ alias_method :refresh, :refresh_token
33
+ alias_method :create, :authorization_code
34
+
35
+ private
36
+
37
+ def handle_token_call(grant_type, params = {})
38
+ params.merge!(grant_type: grant_type)
39
+
37
40
  response, status = BeyondApi::Request.token(@session.api_url + "/oauth/token",
38
- grant_type: "client_credentials")
41
+ params)
39
42
 
40
43
  handle_response(response, status)
41
44
  end
42
45
 
43
- private
44
-
45
46
  def handle_response(response, status)
46
47
  if status.between?(200, 299)
47
48
  @session.access_token = response["access_token"]
@@ -1,3 +1,3 @@
1
1
  module BeyondApi
2
- VERSION = "0.17.0.pre".freeze
2
+ VERSION = "0.18.0.pre".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.pre
4
+ version: 0.18.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-08-12 00:00:00.000000000 Z
14
+ date: 2021-08-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: 1.3.1
201
201
  requirements: []
202
- rubygems_version: 3.1.2
202
+ rubygems_version: 3.2.26
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Ruby client to access the Beyond API