beyond_api 0.7.1.pre → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -3
- data/Gemfile.lock +2 -2
- data/lib/beyond_api.rb +1 -2
- data/lib/beyond_api/error.rb +14 -0
- data/lib/beyond_api/resources/shop.rb +0 -40
- data/lib/beyond_api/resources/token.rb +16 -6
- data/lib/beyond_api/session.rb +0 -5
- data/lib/beyond_api/version.rb +1 -1
- metadata +3 -3
- data/lib/beyond_api/resources/scopes.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 687b39004d4ab172f3a2433b310fd09b95d3aa241be7e5f782941ae0edbeb491
|
4
|
+
data.tar.gz: 0524b2418f1185ae9902054381fc17ecd5e97fba16b9b2af5df80fd7bca47f65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a00f049eb3570f335a5ea6ad1eefc323ed1ea96b9e642dafa3277ad5854ccc6edc16d5b7aae156cd46cf7311809cdad4b4eb241d2935e24895e1bd581857ce
|
7
|
+
data.tar.gz: 85c9dfe12bbeb3dd6592a6371be3611f85b009a6eb050cf12bba2cf5a9f93025809a44f46364ec5e9c7c474f542108e8a0112ff16beac30e410f8d85bbe0b7a7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
### v0.8.0.pre
|
2
|
+
|
3
|
+
* deprecations
|
4
|
+
* Remove `BeyondApi::Shop#open`
|
5
|
+
* Remove `BeyondApi::Shop#close`
|
6
|
+
* Remove `BeyondApi::Scopes`
|
7
|
+
|
8
|
+
* features
|
9
|
+
* Add `BeyondApi::Token#client_credentials`
|
10
|
+
|
11
|
+
* enhancements
|
12
|
+
* Create a custom `BeyondApi::Error` class
|
13
|
+
* Avoid duplicated code on token response handling
|
14
|
+
|
1
15
|
### v0.7.1.pre
|
2
16
|
|
3
17
|
* bug-fixes
|
@@ -6,12 +20,12 @@
|
|
6
20
|
|
7
21
|
### v0.7.0.pre
|
8
22
|
|
9
|
-
* features
|
10
|
-
* Add `Products#assign_variation_images_differentiator` method
|
11
|
-
|
12
23
|
* deprecations
|
13
24
|
* `Variations#adjust_stock_level` receives parameter `relative_amount` instead of `body`
|
14
25
|
|
26
|
+
* features
|
27
|
+
* Add `Products#assign_variation_images_differentiator` method
|
28
|
+
|
15
29
|
### v0.6.0.pre
|
16
30
|
|
17
31
|
* bug-fixes
|
data/Gemfile.lock
CHANGED
data/lib/beyond_api.rb
CHANGED
@@ -3,6 +3,7 @@ require "beyond_api/version"
|
|
3
3
|
require "beyond_api/connection"
|
4
4
|
require "beyond_api/request"
|
5
5
|
require "beyond_api/session"
|
6
|
+
require "beyond_api/error"
|
6
7
|
|
7
8
|
require "beyond_api/ext"
|
8
9
|
require "beyond_api/utils"
|
@@ -10,8 +11,6 @@ require "beyond_api/utils"
|
|
10
11
|
require "logger"
|
11
12
|
|
12
13
|
module BeyondApi
|
13
|
-
class Error < StandardError; end
|
14
|
-
|
15
14
|
def self.logger
|
16
15
|
@@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
17
16
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BeyondApi
|
4
|
+
class Error
|
5
|
+
attr_reader :error_id, :details, :message, :trace_id
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@error_id = data['errorId']
|
9
|
+
@details = data['details']
|
10
|
+
@message = data['message']
|
11
|
+
@trace_id = data['traceId']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -65,26 +65,6 @@ module BeyondApi
|
|
65
65
|
handle_response(response, status)
|
66
66
|
end
|
67
67
|
|
68
|
-
#
|
69
|
-
# A +POST+ request is used to close a shop.
|
70
|
-
#
|
71
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/close' -i -X POST \
|
72
|
-
# -H 'Content-Type: application/json' \
|
73
|
-
# -H 'Authorization: Bearer <Access token>'
|
74
|
-
#
|
75
|
-
# @beyond_api.scopes +shcl:c+
|
76
|
-
#
|
77
|
-
# @return true
|
78
|
-
#
|
79
|
-
# @example
|
80
|
-
# session.shop.close
|
81
|
-
#
|
82
|
-
def close
|
83
|
-
response, status = BeyondApi::Request.post(@session, "/shop/close")
|
84
|
-
|
85
|
-
handle_response(response, status, respond_with_true: true)
|
86
|
-
end
|
87
|
-
|
88
68
|
#
|
89
69
|
# A +POST+ request is used to create a shop attribute.
|
90
70
|
#
|
@@ -310,26 +290,6 @@ module BeyondApi
|
|
310
290
|
handle_response(response, status)
|
311
291
|
end
|
312
292
|
|
313
|
-
#
|
314
|
-
# A +POST+ request is used to open a shop.
|
315
|
-
#
|
316
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/open' -i -X POST \
|
317
|
-
# -H 'Content-Type: application/json' \
|
318
|
-
# -H 'Authorization: Bearer <Access token>'
|
319
|
-
#
|
320
|
-
# @beyond_api.scopes +shcl:c+
|
321
|
-
#
|
322
|
-
# @return true
|
323
|
-
#
|
324
|
-
# @example
|
325
|
-
# session.shop.open
|
326
|
-
#
|
327
|
-
def open
|
328
|
-
response, status = BeyondApi::Request.post(@session, "/shop/open")
|
329
|
-
|
330
|
-
handle_response(response, status, respond_with_true: true)
|
331
|
-
end
|
332
|
-
|
333
293
|
#
|
334
294
|
# A +GET+ request is issued to search for shop images by label.
|
335
295
|
#
|
@@ -8,6 +8,7 @@ module BeyondApi
|
|
8
8
|
|
9
9
|
def initialize(session)
|
10
10
|
@session = session
|
11
|
+
|
11
12
|
raise InvalidSessionError.new("Invalid session") unless session.is_a? BeyondApi::Session
|
12
13
|
raise InvalidSessionError.new("Session api_url cannot be nil") if session.api_url.nil?
|
13
14
|
end
|
@@ -17,12 +18,7 @@ module BeyondApi
|
|
17
18
|
grant_type: "authorization_code",
|
18
19
|
code: code)
|
19
20
|
|
20
|
-
|
21
|
-
@session.access_token = response["access_token"]
|
22
|
-
@session.refresh_token = response["refresh_token"]
|
23
|
-
else
|
24
|
-
BeyondApi::Error.new(response)
|
25
|
-
end
|
21
|
+
handle_response(response, status)
|
26
22
|
end
|
27
23
|
|
28
24
|
def refresh
|
@@ -30,9 +26,23 @@ module BeyondApi
|
|
30
26
|
grant_type: "refresh_token",
|
31
27
|
refresh_token: @session.refresh_token)
|
32
28
|
|
29
|
+
handle_response(response, status)
|
30
|
+
end
|
31
|
+
|
32
|
+
def client_credentials
|
33
|
+
response, status = BeyondApi::Request.token(@session.api_url + "/oauth/token",
|
34
|
+
grant_type: "client_credentials")
|
35
|
+
|
36
|
+
handle_response(response, status)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def handle_response(response, status)
|
33
42
|
if status.between?(200, 299)
|
34
43
|
@session.access_token = response["access_token"]
|
35
44
|
@session.refresh_token = response["refresh_token"]
|
45
|
+
@session
|
36
46
|
else
|
37
47
|
BeyondApi::Error.new(response)
|
38
48
|
end
|
data/lib/beyond_api/session.rb
CHANGED
@@ -13,7 +13,6 @@ require "beyond_api/resources/payment_methods"
|
|
13
13
|
require "beyond_api/resources/product_attribute_definitions"
|
14
14
|
require "beyond_api/resources/products_view"
|
15
15
|
require "beyond_api/resources/products"
|
16
|
-
require "beyond_api/resources/scopes"
|
17
16
|
require "beyond_api/resources/script_tags"
|
18
17
|
require "beyond_api/resources/shipping_zones"
|
19
18
|
require "beyond_api/resources/shop"
|
@@ -82,10 +81,6 @@ module BeyondApi
|
|
82
81
|
BeyondApi::Products.new(self)
|
83
82
|
end
|
84
83
|
|
85
|
-
def scopes
|
86
|
-
BeyondApi::Scopes.new(self)
|
87
|
-
end
|
88
|
-
|
89
84
|
def script_tags
|
90
85
|
BeyondApi::ScriptTags.new(self)
|
91
86
|
end
|
data/lib/beyond_api/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unai Abrisketa
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-02-
|
13
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- bin/setup
|
134
134
|
- lib/beyond_api.rb
|
135
135
|
- lib/beyond_api/connection.rb
|
136
|
+
- lib/beyond_api/error.rb
|
136
137
|
- lib/beyond_api/ext.rb
|
137
138
|
- lib/beyond_api/request.rb
|
138
139
|
- lib/beyond_api/resources/base.rb
|
@@ -156,7 +157,6 @@ files:
|
|
156
157
|
- lib/beyond_api/resources/products/variation_properties.rb
|
157
158
|
- lib/beyond_api/resources/products/videos.rb
|
158
159
|
- lib/beyond_api/resources/products_view.rb
|
159
|
-
- lib/beyond_api/resources/scopes.rb
|
160
160
|
- lib/beyond_api/resources/script_tags.rb
|
161
161
|
- lib/beyond_api/resources/shipping_zones.rb
|
162
162
|
- lib/beyond_api/resources/shop.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "beyond_api/utils"
|
4
|
-
|
5
|
-
module BeyondApi
|
6
|
-
class Scopes < Base
|
7
|
-
include BeyondApi::Utils
|
8
|
-
|
9
|
-
#
|
10
|
-
# A +GET+ request will list all scopes in the system.
|
11
|
-
#
|
12
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/scopes' -i -X GET \
|
13
|
-
# -H 'Authorization: Bearer <Access token>'
|
14
|
-
#
|
15
|
-
# @beyond_api.scopes +scop:r+
|
16
|
-
#
|
17
|
-
# @option params [Integer] :size the page size
|
18
|
-
# @option params [Integer] :page the page number
|
19
|
-
|
20
|
-
# @return [OpenStruct]
|
21
|
-
#
|
22
|
-
# @example
|
23
|
-
# @scopes = session.scopes.all(size: 20, page: 0)
|
24
|
-
#
|
25
|
-
def all(params = {})
|
26
|
-
response, status = BeyondApi::Request.get(@session, "/scopes", params)
|
27
|
-
|
28
|
-
handle_response(response, status)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|