beyond_api 0.8.1.pre → 0.12.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 +46 -0
- data/GETTING_STARTED.md +184 -197
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/lib/beyond_api/error.rb +12 -7
- data/lib/beyond_api/resources/categories.rb +2 -3
- data/lib/beyond_api/resources/categories_view.rb +2 -3
- data/lib/beyond_api/resources/customers.rb +2 -3
- data/lib/beyond_api/resources/orders.rb +2 -3
- data/lib/beyond_api/resources/payment_methods.rb +2 -3
- data/lib/beyond_api/resources/product_attribute_definitions.rb +4 -22
- data/lib/beyond_api/resources/products.rb +11 -11
- data/lib/beyond_api/resources/products_view.rb +2 -3
- data/lib/beyond_api/resources/script_tags.rb +2 -3
- data/lib/beyond_api/resources/shipping_zones.rb +2 -3
- data/lib/beyond_api/resources/shop.rb +11 -438
- data/lib/beyond_api/resources/shops/address.rb +54 -0
- data/lib/beyond_api/resources/shops/attributes.rb +137 -0
- data/lib/beyond_api/resources/shops/images.rb +155 -0
- data/lib/beyond_api/resources/shops/legals.rb +124 -0
- data/lib/beyond_api/resources/shops/locations.rb +252 -0
- data/lib/beyond_api/resources/token.rb +5 -1
- data/lib/beyond_api/resources/users.rb +2 -3
- data/lib/beyond_api/resources/variations.rb +3 -2
- data/lib/beyond_api/resources/webhook_subscriptions.rb +2 -3
- data/lib/beyond_api/session.rb +22 -22
- data/lib/beyond_api/utils.rb +29 -2
- data/lib/beyond_api/version.rb +1 -1
- metadata +8 -3
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,6 +5,21 @@
|
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/1d173fa0b393e8eaf2a2/maintainability)](https://codeclimate.com/github/ePages-de/beyond_api-ruby_client/maintainability)
|
6
6
|
![License](https://img.shields.io/github/license/ePages-de/beyond_api-ruby_client)
|
7
7
|
|
8
|
+
## Get your credentials
|
9
|
+
|
10
|
+
### Sign up for a developer test shop
|
11
|
+
|
12
|
+
First you will need to sign up for a Beyond test shop.
|
13
|
+
Visit [our sign up form](https://signup.beyondshop.cloud), fill out the form with your data, and click the **Sign up** button.
|
14
|
+
|
15
|
+
### Create a custom app
|
16
|
+
|
17
|
+
Log in to the cockpit of your test shop, navigate to **Apps > Custom apps** and click **Add custom app**.
|
18
|
+
Fill out the form with the **App name**, **Application Callback URL** and **App scopes**.
|
19
|
+
Save your app.
|
20
|
+
|
21
|
+
You will then receive your `client_id` and `client_secret`.
|
22
|
+
|
8
23
|
## Installation
|
9
24
|
|
10
25
|
Add this line to your application's Gemfile:
|
data/lib/beyond_api/error.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BeyondApi
|
4
|
-
class Error
|
5
|
-
attr_reader :error_id, :details, :
|
4
|
+
class Error < StandardError
|
5
|
+
attr_reader :error_id, :details, :trace_id, :full_message, :status_code, :error, :error_description
|
6
6
|
|
7
|
-
def initialize(data)
|
8
|
-
@error_id
|
9
|
-
@details
|
10
|
-
@
|
11
|
-
@
|
7
|
+
def initialize(data, status_code = nil)
|
8
|
+
@error_id = data['errorId']
|
9
|
+
@details = data['details']
|
10
|
+
@trace_id = data['traceId']
|
11
|
+
@error = data['error']
|
12
|
+
@error_description = data['error_description']
|
13
|
+
@full_message = data
|
14
|
+
@status_code = status_code
|
15
|
+
|
16
|
+
super(data['message'] || data['error_description'])
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
@@ -16,6 +16,7 @@ module BeyondApi
|
|
16
16
|
#
|
17
17
|
# @beyond_api.scopes +catg:r+
|
18
18
|
#
|
19
|
+
# @option params [Boolean] :paginated
|
19
20
|
# @option params [Integer] :size the page size
|
20
21
|
# @option params [Integer] :page the page number
|
21
22
|
#
|
@@ -25,9 +26,7 @@ module BeyondApi
|
|
25
26
|
# @categories = session.categories.all(size: 100, page: 0)
|
26
27
|
#
|
27
28
|
def all(params = {})
|
28
|
-
|
29
|
-
|
30
|
-
handle_response(response, status)
|
29
|
+
handle_all_request("/categories", :categories, params)
|
31
30
|
end
|
32
31
|
|
33
32
|
#
|
@@ -14,6 +14,7 @@ module BeyondApi
|
|
14
14
|
# -H 'Accept: application/hal+json'
|
15
15
|
#
|
16
16
|
#
|
17
|
+
# @option params [Boolean] :paginated
|
17
18
|
# @option params [Integer] :size the page size
|
18
19
|
# @option params [Integer] :page the page number
|
19
20
|
#
|
@@ -23,9 +24,7 @@ module BeyondApi
|
|
23
24
|
# @categories = session.categories_view.all(size: 100, page: 0)
|
24
25
|
#
|
25
26
|
def all(params = {})
|
26
|
-
|
27
|
-
|
28
|
-
handle_response(response, status)
|
27
|
+
handle_all_request("/product-view/categories", :categories, params)
|
29
28
|
end
|
30
29
|
|
31
30
|
#
|
@@ -14,6 +14,7 @@ module BeyondApi
|
|
14
14
|
#
|
15
15
|
# @beyond_api.scopes +cust:r+
|
16
16
|
#
|
17
|
+
# @option params [Boolean] :paginated
|
17
18
|
# @option params [Integer] :size the page size
|
18
19
|
# @option params [Integer] :page the page number
|
19
20
|
#
|
@@ -23,9 +24,7 @@ module BeyondApi
|
|
23
24
|
# @customers = session.customers.all(size: 20, page: 0)
|
24
25
|
#
|
25
26
|
def all(params = {})
|
26
|
-
|
27
|
-
|
28
|
-
handle_response(response, status)
|
27
|
+
handle_all_request("/customers", :customers, params)
|
29
28
|
end
|
30
29
|
|
31
30
|
#
|
@@ -57,6 +57,7 @@ module BeyondApi
|
|
57
57
|
#
|
58
58
|
# @beyond_api.scopes +ordr:r+
|
59
59
|
#
|
60
|
+
# @option params [Boolean] :paginated
|
60
61
|
# @option params [Integer] :size the page size
|
61
62
|
# @option params [Integer] :page the page number
|
62
63
|
#
|
@@ -66,9 +67,7 @@ module BeyondApi
|
|
66
67
|
# @orders = session.orders.all(size: 100, page: 0)
|
67
68
|
#
|
68
69
|
def all(params = {})
|
69
|
-
|
70
|
-
|
71
|
-
handle_response(response, status)
|
70
|
+
handle_all_request("/orders", :orders, params)
|
72
71
|
end
|
73
72
|
|
74
73
|
#
|
@@ -38,6 +38,7 @@ module BeyondApi
|
|
38
38
|
#
|
39
39
|
# @beyond_api.scopes +pymt:r+
|
40
40
|
#
|
41
|
+
# @option params [Boolean] :paginated
|
41
42
|
# @option params [Integer] :size the page size
|
42
43
|
# @option params [Integer] :page the page number
|
43
44
|
#
|
@@ -47,9 +48,7 @@ module BeyondApi
|
|
47
48
|
# @payment_methods = session.payment_methods.all(size: 100, page: 0)
|
48
49
|
#
|
49
50
|
def all(params = {})
|
50
|
-
|
51
|
-
|
52
|
-
handle_response(response, status)
|
51
|
+
handle_all_request("/payment-methods", :payment_methods, params)
|
53
52
|
end
|
54
53
|
|
55
54
|
#
|
@@ -14,9 +14,9 @@ module BeyondApi
|
|
14
14
|
#
|
15
15
|
# @beyond_api.scopes +prad:r+
|
16
16
|
#
|
17
|
-
# @option
|
18
|
-
# @option
|
19
|
-
# @option
|
17
|
+
# @option params [Boolean] :paginated
|
18
|
+
# @option params [Integer] :size the page size
|
19
|
+
# @option params [Integer] :page the page number
|
20
20
|
#
|
21
21
|
# @return [OpenStruct]
|
22
22
|
#
|
@@ -24,18 +24,7 @@ module BeyondApi
|
|
24
24
|
# @product_attribute_definitions = session.product_attribute_definitions.all(size: 100, page: 0)
|
25
25
|
#
|
26
26
|
def all(params = {})
|
27
|
-
|
28
|
-
result = all_paginated(page: 0, size: 1000)
|
29
|
-
|
30
|
-
(1..result[:page][:total_pages] - 1).each do |page|
|
31
|
-
result[:embedded][:product_attribute_definition].concat(all_paginated(page: page, size: 1000)[:embedded][:product_attribute_definitions])
|
32
|
-
end
|
33
|
-
|
34
|
-
result.is_a?(Hash) ? result.delete(:page) : result.delete_field(:page)
|
35
|
-
result
|
36
|
-
else
|
37
|
-
all_paginated(params)
|
38
|
-
end
|
27
|
+
handle_all_request("/product-attribute-definitions", :product_attribute_definitions, params)
|
39
28
|
end
|
40
29
|
|
41
30
|
#
|
@@ -113,12 +102,5 @@ module BeyondApi
|
|
113
102
|
|
114
103
|
handle_response(response, status)
|
115
104
|
end
|
116
|
-
|
117
|
-
private
|
118
|
-
|
119
|
-
def all_paginated(params = {})
|
120
|
-
response, status = BeyondApi::Request.get(@session, "/product-attribute-definitions", params)
|
121
|
-
handle_response(response, status)
|
122
|
-
end
|
123
105
|
end
|
124
106
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "beyond_api/utils"
|
4
|
-
require "beyond_api/resources/products/attachments"
|
5
|
-
require "beyond_api/resources/products/availability"
|
6
|
-
require "beyond_api/resources/products/cross_sells"
|
7
|
-
require "beyond_api/resources/products/custom_attributes"
|
8
|
-
require "beyond_api/resources/products/images"
|
9
|
-
require "beyond_api/resources/products/searches"
|
10
|
-
require "beyond_api/resources/products/variation_properties"
|
11
|
-
require "beyond_api/resources/products/videos"
|
12
4
|
|
13
5
|
module BeyondApi
|
6
|
+
autoload :ProductAttachments, "beyond_api/resources/products/attachments"
|
7
|
+
autoload :ProductAvailability, "beyond_api/resources/products/availability"
|
8
|
+
autoload :ProductCrossSells, "beyond_api/resources/products/cross_sells"
|
9
|
+
autoload :ProductCustomAttributes, "beyond_api/resources/products/custom_attributes"
|
10
|
+
autoload :ProductImages, "beyond_api/resources/products/images"
|
11
|
+
autoload :ProductSearches, "beyond_api/resources/products/searches"
|
12
|
+
autoload :ProductVariationProperties, "beyond_api/resources/products/variation_properties"
|
13
|
+
autoload :ProductVideos, "beyond_api/resources/products/videos"
|
14
|
+
|
14
15
|
class Products < Base
|
15
16
|
include BeyondApi::ProductAttachments
|
16
17
|
include BeyondApi::ProductAvailability
|
@@ -32,6 +33,7 @@ module BeyondApi
|
|
32
33
|
#
|
33
34
|
# @beyond_api.scopes +prod:r+
|
34
35
|
#
|
36
|
+
# @option params [Boolean] :paginated
|
35
37
|
# @option params [Integer] :size the page size
|
36
38
|
# @option params [Integer] :page the page number
|
37
39
|
#
|
@@ -41,9 +43,7 @@ module BeyondApi
|
|
41
43
|
# @products = session.products.all(size: 100, page: 0)
|
42
44
|
#
|
43
45
|
def all(params = {})
|
44
|
-
|
45
|
-
|
46
|
-
handle_response(response, status)
|
46
|
+
handle_all_request("/products", :products, params)
|
47
47
|
end
|
48
48
|
|
49
49
|
#
|
@@ -13,6 +13,7 @@ module BeyondApi
|
|
13
13
|
# -H 'Content-Type: application/json' \
|
14
14
|
# -H 'Accept: application/hal+json'
|
15
15
|
#
|
16
|
+
# @option params [Boolean] :paginated
|
16
17
|
# @option params [Integer] :size the page size
|
17
18
|
# @option params [Integer] :page the page number
|
18
19
|
#
|
@@ -22,9 +23,7 @@ module BeyondApi
|
|
22
23
|
# @products = session.products_view.all(page: 0, size: 100)
|
23
24
|
#
|
24
25
|
def all(params = {})
|
25
|
-
|
26
|
-
|
27
|
-
handle_response(response, status)
|
26
|
+
handle_all_request("/product-view/products", :products, params)
|
28
27
|
end
|
29
28
|
|
30
29
|
#
|
@@ -12,6 +12,7 @@ module BeyondApi
|
|
12
12
|
# $ curl 'https://api-shop.beyondshop.cloud/api/script-tags' -i -X GET \
|
13
13
|
# -H 'Authorization: Bearer <Access token>'
|
14
14
|
#
|
15
|
+
# @option params [Boolean] :paginated
|
15
16
|
# @option params [Integer] :size the page size
|
16
17
|
# @option params [Integer] :page the page number
|
17
18
|
#
|
@@ -21,9 +22,7 @@ module BeyondApi
|
|
21
22
|
# @script_tags = session.script_tags.all(size: 20, page: 0)
|
22
23
|
#
|
23
24
|
def all(params = {})
|
24
|
-
|
25
|
-
|
26
|
-
handle_response(response, status)
|
25
|
+
handle_all_request("/script-tags", :script_tags, params)
|
27
26
|
end
|
28
27
|
|
29
28
|
#
|
@@ -14,6 +14,7 @@ module BeyondApi
|
|
14
14
|
# $ curl 'https://api-shop.beyondshop.cloud/api/shipping-zones' -i -X GET \
|
15
15
|
# -H 'Authorization: Bearer <Access token>'
|
16
16
|
#
|
17
|
+
# @option params [Boolean] :paginated
|
17
18
|
# @option params [Integer] :size the page size
|
18
19
|
# @option params [Integer] :page the page number
|
19
20
|
#
|
@@ -23,9 +24,7 @@ module BeyondApi
|
|
23
24
|
# @shipping_zones = session.shipping_zones.all(size: 20, page: 0)
|
24
25
|
#
|
25
26
|
def all(params = {})
|
26
|
-
|
27
|
-
|
28
|
-
handle_response(response, status)
|
27
|
+
handle_all_request("/shipping-zones", :shipping_zones, params)
|
29
28
|
end
|
30
29
|
|
31
30
|
#
|
@@ -3,133 +3,20 @@
|
|
3
3
|
require "beyond_api/utils"
|
4
4
|
|
5
5
|
module BeyondApi
|
6
|
+
autoload :ShopAddress, "beyond_api/resources/shops/address"
|
7
|
+
autoload :ShopAttributes, "beyond_api/resources/shops/attributes"
|
8
|
+
autoload :ShopImages, "beyond_api/resources/shops/images"
|
9
|
+
autoload :ShopLegals, "beyond_api/resources/shops/legals"
|
10
|
+
autoload :ShopLocations, "beyond_api/resources/shops/locations"
|
11
|
+
|
6
12
|
class Shop < Base
|
13
|
+
include BeyondApi::ShopAddress
|
14
|
+
include BeyondApi::ShopAttributes
|
15
|
+
include BeyondApi::ShopImages
|
16
|
+
include BeyondApi::ShopLegals
|
17
|
+
include BeyondApi::ShopLocations
|
7
18
|
include BeyondApi::Utils
|
8
19
|
|
9
|
-
#
|
10
|
-
# A +GET+ request is used to retrieve the details of a shop’s address.
|
11
|
-
#
|
12
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X GET
|
13
|
-
#
|
14
|
-
# @return [OpenStruct]
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# session.shop.address
|
18
|
-
#
|
19
|
-
def address
|
20
|
-
response, status = BeyondApi::Request.get(@session, "/shop/address")
|
21
|
-
|
22
|
-
handle_response(response, status)
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# A +GET+ request is used to retrieve a particular shop attribute by its name.
|
27
|
-
#
|
28
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X GET \
|
29
|
-
# -H 'Authorization: Bearer <Access token>'
|
30
|
-
#
|
31
|
-
# @beyond_api.scopes +shat:r+
|
32
|
-
#
|
33
|
-
# @param attribute_name [String] the attribute name
|
34
|
-
#
|
35
|
-
# @return [OpenStruct]
|
36
|
-
#
|
37
|
-
# @example
|
38
|
-
# @shop_attribute = session.shop.attribute("second-unknown-attribute-name")
|
39
|
-
#
|
40
|
-
def attribute(attribute_name)
|
41
|
-
response, status = BeyondApi::Request.get(@session, "/shop/attributes/#{attribute_name}")
|
42
|
-
|
43
|
-
handle_response(response, status)
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# A +GET+ request is used to retrieve a list of all shop attributes.
|
48
|
-
#
|
49
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X GET \
|
50
|
-
# -H 'Authorization: Bearer <Access token>'
|
51
|
-
#
|
52
|
-
# @beyond_api.scopes +shat:r+
|
53
|
-
#
|
54
|
-
# @option params [Integer] :size the page size
|
55
|
-
# @option params [Integer] :page the page number
|
56
|
-
#
|
57
|
-
# @return [OpenStruct]
|
58
|
-
#
|
59
|
-
# @example
|
60
|
-
# @shop_attributes = session.shop.attributes(size: 5, page: 1)
|
61
|
-
#
|
62
|
-
def attributes(params = {})
|
63
|
-
response, status = BeyondApi::Request.get(@session, "/shop/attributes", params)
|
64
|
-
|
65
|
-
handle_response(response, status)
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# A +POST+ request is used to create a shop attribute.
|
70
|
-
#
|
71
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X POST \
|
72
|
-
# -H 'Content-Type: application/json' \
|
73
|
-
# -H 'Authorization: Bearer <Access token>' \
|
74
|
-
# -d '{
|
75
|
-
# "name" : "second-unknown-attribute-name",
|
76
|
-
# "value" : "correct-value",
|
77
|
-
# "public" : false
|
78
|
-
# }'
|
79
|
-
#
|
80
|
-
# @beyond_api.scopes +shat:c+
|
81
|
-
#
|
82
|
-
# @param body [Hash] the request body
|
83
|
-
#
|
84
|
-
# @return [OpenStruct]
|
85
|
-
#
|
86
|
-
# @example
|
87
|
-
# body = {
|
88
|
-
# "name" => "second-unknown-attribute-name",
|
89
|
-
# "value" => "correct-value",
|
90
|
-
# "public" => false
|
91
|
-
# }
|
92
|
-
#
|
93
|
-
# session.shop.create_attribute(body)
|
94
|
-
#
|
95
|
-
def create_attribute(body)
|
96
|
-
response, status = BeyondApi::Request.post(@session, "/shop/attributes", body)
|
97
|
-
|
98
|
-
handle_response(response, status)
|
99
|
-
end
|
100
|
-
|
101
|
-
#
|
102
|
-
# A +POST+ request is used to create a shop image.
|
103
|
-
#
|
104
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images' -i -X POST \
|
105
|
-
# -H 'Content-Type: application/json' \
|
106
|
-
# -H 'Accept: application/hal+json' \
|
107
|
-
# -H 'Authorization: Bearer <Access token>' \
|
108
|
-
# -d '{
|
109
|
-
# "dataUri" : "file.png?hash=212-2323-4343",
|
110
|
-
# "label" : "logo"
|
111
|
-
# }'
|
112
|
-
#
|
113
|
-
# @beyond_api.scopes +shim:c+
|
114
|
-
#
|
115
|
-
# @param body [Hash] the request body
|
116
|
-
#
|
117
|
-
# @return true
|
118
|
-
#
|
119
|
-
# @example
|
120
|
-
# body = {
|
121
|
-
# "data_uri" => "file.png?hash=212-2323-4343",
|
122
|
-
# "label" => "logo"
|
123
|
-
# }
|
124
|
-
#
|
125
|
-
# session.shop.create_image(body)
|
126
|
-
#
|
127
|
-
def create_image(body)
|
128
|
-
response, status = BeyondApi::Request.post(@session, "/shop/images", body)
|
129
|
-
|
130
|
-
handle_response(response, status, respond_with_true: true)
|
131
|
-
end
|
132
|
-
|
133
20
|
#
|
134
21
|
# A +GET+ request is used to retrieve the details of a shop.
|
135
22
|
#
|
@@ -147,168 +34,6 @@ module BeyondApi
|
|
147
34
|
handle_response(response, status)
|
148
35
|
end
|
149
36
|
|
150
|
-
#
|
151
|
-
# A +DELETE+ request is used to delete an shop attribute.
|
152
|
-
#
|
153
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X DELETE \
|
154
|
-
# -H 'Authorization: Bearer <Access token>'
|
155
|
-
#
|
156
|
-
# @beyond_api.scopes +shat:d+
|
157
|
-
#
|
158
|
-
# @param attribute_name [String] the attribute name
|
159
|
-
#
|
160
|
-
# @return true
|
161
|
-
#
|
162
|
-
# @example
|
163
|
-
# session.shop.delete_attribute("second-unknown-attribute-name")
|
164
|
-
#
|
165
|
-
def delete_attribute(attribute_name)
|
166
|
-
response, status = BeyondApi::Request.delete(@session, "/shop/attributes/#{attribute_name}")
|
167
|
-
|
168
|
-
handle_response(response, status, respond_with_true: true)
|
169
|
-
end
|
170
|
-
|
171
|
-
#
|
172
|
-
# A +DELETE+ request is used to delete a shop image.
|
173
|
-
#
|
174
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/6a7646dc-7f26-4730-a98f-52f9b63978fb' -i -X DELETE \
|
175
|
-
# -H 'Content-Type: application/json' \
|
176
|
-
# -H 'Accept: application/hal+json' \
|
177
|
-
# -H 'Authorization: Bearer <Access token>'
|
178
|
-
#
|
179
|
-
# @beyond_api.scopes +shim:d+
|
180
|
-
#
|
181
|
-
# @param image_id [String] the image UUID
|
182
|
-
#
|
183
|
-
# @return true
|
184
|
-
#
|
185
|
-
# @example
|
186
|
-
# session.shop.delete_image("6a7646dc-7f26-4730-a98f-52f9b63978fb")
|
187
|
-
#
|
188
|
-
def delete_image(image_id)
|
189
|
-
response, status = BeyondApi::Request.delete(@session, "/shop/images/#{image_id}")
|
190
|
-
|
191
|
-
handle_response(response, status, respond_with_true: true)
|
192
|
-
end
|
193
|
-
|
194
|
-
#
|
195
|
-
# A +GET+ request is used to retrieve a single shop image.
|
196
|
-
#
|
197
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/2feee7ac-f1cb-4faf-9488-f3ce07394141' -i -X GET \
|
198
|
-
# -H 'Accept: application/hal+json'
|
199
|
-
#
|
200
|
-
# @param image_id [String] the image UUID
|
201
|
-
#
|
202
|
-
# @return [OpenStruct]
|
203
|
-
#
|
204
|
-
# @example
|
205
|
-
# @image = session.shop.image("2feee7ac-f1cb-4faf-9488-f3ce07394141")
|
206
|
-
#
|
207
|
-
def image(image_id)
|
208
|
-
response, status = BeyondApi::Request.get(@session, "/shop/images/#{image_id}")
|
209
|
-
|
210
|
-
handle_response(response, status)
|
211
|
-
end
|
212
|
-
|
213
|
-
#
|
214
|
-
# A +GET+ request is used to retrieve the images of a shop.
|
215
|
-
#
|
216
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images' -i -X GET \
|
217
|
-
# -H 'Accept: application/hal+json'
|
218
|
-
#
|
219
|
-
# @option params [Integer] :size the page size
|
220
|
-
# @option params [Integer] :page the page number
|
221
|
-
#
|
222
|
-
# @return [OpenStruct]
|
223
|
-
#
|
224
|
-
# @example
|
225
|
-
# @images = session.shop.images(size: 5, page: 1)
|
226
|
-
#
|
227
|
-
def images(params = {})
|
228
|
-
response, status = BeyondApi::Request.get(@session, "/shop/images", params)
|
229
|
-
|
230
|
-
handle_response(response, status)
|
231
|
-
end
|
232
|
-
|
233
|
-
#
|
234
|
-
# A +GET+ request is used to retrieve a specific part of the legal content information.
|
235
|
-
#
|
236
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/right-of-withdrawal' -i -X GET \
|
237
|
-
# -H 'Content-Type: application/json' \
|
238
|
-
# -H 'Accept: application/json'
|
239
|
-
#
|
240
|
-
# @param legal_content_type [String] the legal content type
|
241
|
-
#
|
242
|
-
# @return [OpenStruct]
|
243
|
-
#
|
244
|
-
# @example
|
245
|
-
# @legal_content = session.shop.legal_content("right-of-withdrawal")
|
246
|
-
#
|
247
|
-
def legal_content(legal_content_type)
|
248
|
-
response, status = BeyondApi::Request.get(@session, "/legal-content/#{legal_content_type}")
|
249
|
-
|
250
|
-
handle_response(response, status)
|
251
|
-
end
|
252
|
-
|
253
|
-
#
|
254
|
-
# A +GET+ request is used to retrieve the legal content of a shop.
|
255
|
-
#
|
256
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content' -i -X GET \
|
257
|
-
# -H 'Content-Type: application/json' \
|
258
|
-
# -H 'Accept: application/json'
|
259
|
-
#
|
260
|
-
# @option params [Integer] :size the page size
|
261
|
-
# @option params [Integer] :page the page number
|
262
|
-
#
|
263
|
-
# @return [OpenStruct]
|
264
|
-
#
|
265
|
-
# @example
|
266
|
-
# @legal_content = session.shop.legal_contents(size: 5, page: 1)
|
267
|
-
#
|
268
|
-
def legal_contents(params = {})
|
269
|
-
response, status = BeyondApi::Request.get(@session, "/legal-content", params)
|
270
|
-
|
271
|
-
handle_response(response, status)
|
272
|
-
end
|
273
|
-
|
274
|
-
#
|
275
|
-
# A +GET+ request is used to retrieve the details of the legal resource.
|
276
|
-
#
|
277
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/legal' -i -X GET \
|
278
|
-
# -H 'Authorization: Bearer <Access token>'
|
279
|
-
#
|
280
|
-
# @beyond_api.scopes +legl:r+
|
281
|
-
#
|
282
|
-
# @return [OpenStruct]
|
283
|
-
#
|
284
|
-
# @example
|
285
|
-
# @legal_details = session.shop.legal_details
|
286
|
-
#
|
287
|
-
def legal_details
|
288
|
-
response, status = BeyondApi::Request.get(@session, "/shop/legal")
|
289
|
-
|
290
|
-
handle_response(response, status)
|
291
|
-
end
|
292
|
-
|
293
|
-
#
|
294
|
-
# A +GET+ request is issued to search for shop images by label.
|
295
|
-
#
|
296
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/search/find-by-label?label=logo' -i -X GET \
|
297
|
-
# -H 'Accept: application/hal+json'
|
298
|
-
#
|
299
|
-
# @param label [String] the image label
|
300
|
-
#
|
301
|
-
# @return [OpenStruct]
|
302
|
-
#
|
303
|
-
# @example
|
304
|
-
# session.shop.search_images_by_label("logo")
|
305
|
-
#
|
306
|
-
def search_images_by_label(label)
|
307
|
-
response, status = BeyondApi::Request.get(@session, "/shop/images/search/find-by-label", { label: label })
|
308
|
-
|
309
|
-
handle_response(response, status)
|
310
|
-
end
|
311
|
-
|
312
37
|
#
|
313
38
|
# A +PATCH+ request is used to change attributes of a shop.
|
314
39
|
#
|
@@ -360,157 +85,5 @@ module BeyondApi
|
|
360
85
|
|
361
86
|
handle_response(response, status)
|
362
87
|
end
|
363
|
-
|
364
|
-
#
|
365
|
-
# A +PATCH+ request is used to patch a shop’s address partially with json content type.
|
366
|
-
#
|
367
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X PATCH \
|
368
|
-
# -H 'Content-Type: application/json' \
|
369
|
-
# -H 'Accept: application/hal+json' \
|
370
|
-
# -H 'Authorization: Bearer <Access token>' \
|
371
|
-
# -d '{
|
372
|
-
# "city" : "Barcelona"
|
373
|
-
# }'
|
374
|
-
#
|
375
|
-
# @beyond_api.scopes +shad:u+
|
376
|
-
#
|
377
|
-
# @param body [Hash] the request body
|
378
|
-
#
|
379
|
-
# @return [OpenStruct]
|
380
|
-
#
|
381
|
-
# @example
|
382
|
-
# body = {
|
383
|
-
# "city" => "Barcelona"
|
384
|
-
# }
|
385
|
-
#
|
386
|
-
# session.shop.update_address(body)
|
387
|
-
#
|
388
|
-
def update_address(body)
|
389
|
-
response, status = BeyondApi::Request.patch(@session, "/shop/address", body)
|
390
|
-
|
391
|
-
handle_response(response, status)
|
392
|
-
end
|
393
|
-
|
394
|
-
#
|
395
|
-
# A +PUT+ request is used to update a shop attribute. This operation is idempotent and will create a new shop attribute if required.
|
396
|
-
#
|
397
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X PUT \
|
398
|
-
# -H 'Content-Type: application/json' \
|
399
|
-
# -H 'Authorization: Bearer <Access token>' \
|
400
|
-
# -d '{
|
401
|
-
# "value" : "new-value",
|
402
|
-
# "public" : false
|
403
|
-
# }'
|
404
|
-
#
|
405
|
-
# @beyond_api.scopes +shat:u+
|
406
|
-
#
|
407
|
-
# @param attribute_name [String] the attribute name
|
408
|
-
# @param body [Hash] the request body
|
409
|
-
#
|
410
|
-
# @return [OpenStruct]
|
411
|
-
#
|
412
|
-
# @example
|
413
|
-
# body = {
|
414
|
-
# "value" => "new-value",
|
415
|
-
# "public" => false
|
416
|
-
# }
|
417
|
-
#
|
418
|
-
# session.shop.update_attribute("second-unknown-attribute-name", body)
|
419
|
-
#
|
420
|
-
def update_attribute(attribute_name, body)
|
421
|
-
response, status = BeyondApi::Request.put(@session, "/shop/attributes/#{attribute_name}", body)
|
422
|
-
|
423
|
-
handle_response(response, status)
|
424
|
-
end
|
425
|
-
|
426
|
-
#
|
427
|
-
# A +PUT+ request is used to update the content of a specific part of the legal content information. Changes on the properties type and mandatory will be ignored.
|
428
|
-
#
|
429
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/legal-notice' -i -X PUT \
|
430
|
-
# -H 'Content-Type: application/json' \
|
431
|
-
# -H 'Accept: application/json' \
|
432
|
-
# -H 'Authorization: Bearer <Access token>' \
|
433
|
-
# -d '{
|
434
|
-
# "content" : "new legal content"
|
435
|
-
# }'
|
436
|
-
#
|
437
|
-
# @beyond_api.scopes +lcnt:u+
|
438
|
-
#
|
439
|
-
# @param body [Hash] the request body
|
440
|
-
#
|
441
|
-
# @return [OpenStruct]
|
442
|
-
#
|
443
|
-
# @example
|
444
|
-
# session.shop.update_legal_content(body)
|
445
|
-
#
|
446
|
-
def update_legal_content(body)
|
447
|
-
response, status = BeyondApi::Request.put(@session, "/legal-content/legal-notice")
|
448
|
-
|
449
|
-
handle_response(response, status)
|
450
|
-
end
|
451
|
-
|
452
|
-
#
|
453
|
-
# A +PATCH+ request is used to update a legal resource partially with json content type.
|
454
|
-
#
|
455
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/legal' -i -X PATCH \
|
456
|
-
# -H 'Content-Type: application/json' \
|
457
|
-
# -H 'Accept: application/hal+json' \
|
458
|
-
# -H 'Authorization: Bearer <Access token>' \
|
459
|
-
# -d '{
|
460
|
-
# "vatId" : "GB 111111111"
|
461
|
-
# }'
|
462
|
-
#
|
463
|
-
# @beyond_api.scopes +legl:u+
|
464
|
-
#
|
465
|
-
# @param body [Hash] the request body
|
466
|
-
#
|
467
|
-
# @return [OpenStruct]
|
468
|
-
#
|
469
|
-
# @example
|
470
|
-
# body = {
|
471
|
-
# "vat_id" => "GB 111111111"
|
472
|
-
# }
|
473
|
-
#
|
474
|
-
# session.shop.update_legal_details(body)
|
475
|
-
#
|
476
|
-
def update_legal_details(body)
|
477
|
-
response, status = BeyondApi::Request.patch(@session, "/shop/legal")
|
478
|
-
|
479
|
-
handle_response(response, status)
|
480
|
-
end
|
481
|
-
|
482
|
-
#
|
483
|
-
# A +POST+ request is used to upload a shop image. The body of the request must contain the content of the image.
|
484
|
-
#
|
485
|
-
# $ curl --data-binary '@/home/epages/sample.png' 'https://api-shop.beyondshop.cloud/api/shop/images?fileName=sample.png&label=invoice logo' -X POST \
|
486
|
-
# -H 'Content-Type: image/png' \
|
487
|
-
# -H 'Authorization: Bearer <Access token>'
|
488
|
-
#
|
489
|
-
# @beyond_api.scopes +shim:c+
|
490
|
-
#
|
491
|
-
# @param image_path [String] the image path
|
492
|
-
# @param image_name [String] the image name
|
493
|
-
# @param label [String] the image label
|
494
|
-
#
|
495
|
-
# @return true
|
496
|
-
#
|
497
|
-
# @example
|
498
|
-
# session.shop.upload_image("/home/epages/sample.png", "sample.png", "invoice logo")
|
499
|
-
#
|
500
|
-
def upload_image(image_path, image_name, label)
|
501
|
-
content_type = case File.extname(image_path)
|
502
|
-
when ".png"
|
503
|
-
"image/png"
|
504
|
-
when ".jpg", ".jpeg"
|
505
|
-
"image/jpeg"
|
506
|
-
when ".gif"
|
507
|
-
"image/gif"
|
508
|
-
end
|
509
|
-
image_binary = File.binread(image_path)
|
510
|
-
|
511
|
-
response, status = BeyondApi::Request.upload(@session, "/shop/images", image_binary, content_type, { file_name: image_name, label: label })
|
512
|
-
|
513
|
-
handle_response(response, status, respond_with_true: true)
|
514
|
-
end
|
515
88
|
end
|
516
89
|
end
|