beyond_api 0.5.1.pre → 0.6.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 +57 -3
- data/Gemfile.lock +3 -3
- data/lib/beyond_api/resources/carts.rb +18 -9
- data/lib/beyond_api/resources/categories.rb +2 -2
- data/lib/beyond_api/resources/categories_view.rb +13 -2
- data/lib/beyond_api/resources/checkout_settings.rb +16 -1
- data/lib/beyond_api/resources/customers.rb +333 -0
- data/lib/beyond_api/resources/newsletter_target.rb +1 -1
- data/lib/beyond_api/resources/order_settings.rb +45 -28
- data/lib/beyond_api/resources/orders.rb +175 -87
- data/lib/beyond_api/resources/payment_methods.rb +28 -25
- data/lib/beyond_api/resources/product_attribute_definitions.rb +3 -5
- data/lib/beyond_api/resources/products/attachments.rb +13 -14
- data/lib/beyond_api/resources/products/availability.rb +12 -10
- data/lib/beyond_api/resources/products/cross_sells.rb +159 -0
- data/lib/beyond_api/resources/products/custom_attributes.rb +7 -7
- data/lib/beyond_api/resources/products/images.rb +47 -8
- data/lib/beyond_api/resources/products/videos.rb +146 -0
- data/lib/beyond_api/resources/products.rb +11 -9
- data/lib/beyond_api/resources/products_view.rb +6 -51
- data/lib/beyond_api/resources/shipping_zones.rb +5 -5
- data/lib/beyond_api/resources/shop.rb +16 -21
- data/lib/beyond_api/resources/signers.rb +1 -1
- data/lib/beyond_api/resources/users.rb +13 -10
- data/lib/beyond_api/resources/variations/images.rb +160 -0
- data/lib/beyond_api/resources/variations.rb +40 -37
- data/lib/beyond_api/resources/webhook_subscriptions.rb +1 -1
- data/lib/beyond_api/session.rb +5 -5
- data/lib/beyond_api/version.rb +1 -1
- metadata +7 -4
- data/lib/beyond_api/resources/product_settings.rb +0 -28
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ProductVideos
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +POST+ request is used to create a video and add it to a product.
|
10
|
+
#
|
11
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/f7716244-568c-4536-bc25-317030f83395/videos' -i -X POST \
|
12
|
+
# -H 'Content-Type: application/hal+json' \
|
13
|
+
# -H 'Accept: application/hal+json' \
|
14
|
+
# -H 'Authorization: Bearer <Access token>' \
|
15
|
+
# -d '{
|
16
|
+
# "type" : "VIMEO",
|
17
|
+
# "source" : "https://vimeo.com/7265982"
|
18
|
+
# }'
|
19
|
+
#
|
20
|
+
# @beyond_api.scopes +prod:u+
|
21
|
+
#
|
22
|
+
# @param product_id [String] the product UUID
|
23
|
+
# @param body [Hash] the request body
|
24
|
+
#
|
25
|
+
# @return [OpenStruct]
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# body = {
|
29
|
+
# "type" => "VIMEO",
|
30
|
+
# "source" => "https://vimeo.com/7265982"
|
31
|
+
# }
|
32
|
+
# @video = session.products.add_video("f7716244-568c-4536-bc25-317030f83395", body)
|
33
|
+
#
|
34
|
+
def add_video(product_id, body)
|
35
|
+
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/videos", body)
|
36
|
+
|
37
|
+
handle_response(response, status)
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# A +DELETE+ request is used to delete a product video
|
42
|
+
#
|
43
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/1cc9ef5e-62b1-43c7-8745-f4aa8be79934/videos/60869f60-1a4b-4013-b86c-00a2ab9ddc2c' -i -X DELETE \
|
44
|
+
# -H 'Content-Type: application/hal+json' \
|
45
|
+
# -H 'Accept: application/hal+json' \
|
46
|
+
# -H 'Authorization: Bearer <Access token>'
|
47
|
+
#
|
48
|
+
# @beyond_api.scopes +prod:u+
|
49
|
+
#
|
50
|
+
# @param product_id [String] the product UUID
|
51
|
+
# @param video_id [String] the video UUID
|
52
|
+
#
|
53
|
+
# @return [true]
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# session.products.delete_video("1cc9ef5e-62b1-43c7-8745-f4aa8be79934", "60869f60-1a4b-4013-b86c-00a2ab9ddc2c")
|
57
|
+
#
|
58
|
+
def delete_video(product_id, video_id)
|
59
|
+
response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/videos/#{video_id}")
|
60
|
+
|
61
|
+
handle_response(response, status, respond_with_true: true)
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# A +PUT+ request is used to update a video.
|
66
|
+
#
|
67
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/9d33da61-1f60-4ad3-9de0-2f1dc0910ebb/videos/ef51af21-5381-4ccb-a107-8bfa574d3556' -i -X PUT \
|
68
|
+
# -H 'Content-Type: application/hal+json' \
|
69
|
+
# -H 'Accept: application/hal+json' \
|
70
|
+
# -H 'Authorization: Bearer <Access token>' \
|
71
|
+
# -d '{
|
72
|
+
# "type" : "VIMEO",
|
73
|
+
# "source" : "https://vimeo.com/7265982"
|
74
|
+
# }'
|
75
|
+
#
|
76
|
+
# @beyond_api.scopes +prod:u+
|
77
|
+
#
|
78
|
+
# @param product_id [String] the product UUID
|
79
|
+
# @param video_id [String] the video UUID
|
80
|
+
# @param body [Hash] the request body
|
81
|
+
#
|
82
|
+
# @return [OpenStruct]
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
# body = {
|
86
|
+
# "type" => "VIMEO",
|
87
|
+
# "source" => "https://vimeo.com/7265982"
|
88
|
+
# }
|
89
|
+
# @video = session.products.update_video("9d33da61-1f60-4ad3-9de0-2f1dc0910ebb", "ef51af21-5381-4ccb-a107-8bfa574d3556", body)
|
90
|
+
#
|
91
|
+
def update_video(product_id, video_id, body)
|
92
|
+
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/videos/#{video_id}", body)
|
93
|
+
|
94
|
+
handle_response(response, status)
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# A +GET+ request is used to retrieve a single video of a product.
|
99
|
+
#
|
100
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/94c3baf9-1390-4bf8-a6c1-fb234533fa14/videos/ada27b8c-ddf0-489a-9143-5bec938c1e17' -i -X GET \
|
101
|
+
# -H 'Content-Type: application/hal+json' \
|
102
|
+
# -H 'Accept: application/hal+json' \
|
103
|
+
# -H 'Authorization: Bearer <Access token>'
|
104
|
+
#
|
105
|
+
# @beyond_api.scopes +prod:r+
|
106
|
+
#
|
107
|
+
# @param product_id [String] the product UUID
|
108
|
+
# @param video_id [String] the video UUID
|
109
|
+
#
|
110
|
+
# @return [OpenStruct]
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# @video = session.products.video("94c3baf9-1390-4bf8-a6c1-fb234533fa14", "ada27b8c-ddf0-489a-9143-5bec938c1e17")
|
114
|
+
#
|
115
|
+
def video(product_id, video_id)
|
116
|
+
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/videos/#{video_id}")
|
117
|
+
|
118
|
+
handle_response(response, status)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# A +GET+ request is used to retrieve the videos of a product.
|
123
|
+
#
|
124
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/04c6ad65-465d-405e-a428-f73349104b65/videos' -i -X GET \
|
125
|
+
# -H 'Content-Type: application/hal+json' \
|
126
|
+
# -H 'Accept: application/hal+json' \
|
127
|
+
# -H 'Authorization: Bearer <Access token>'
|
128
|
+
#
|
129
|
+
# @beyond_api.scopes +prod:r+
|
130
|
+
#
|
131
|
+
# @param product_id [String] the product UUID
|
132
|
+
# @option params [Integer] :size the page size
|
133
|
+
# @option params [Integer] :page the page number
|
134
|
+
#
|
135
|
+
# @return [OpenStruct]
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
# @videos = session.products.videos("04c6ad65-465d-405e-a428-f73349104b65", size: 100, page: 0)
|
139
|
+
#
|
140
|
+
def videos(product_id, params = {})
|
141
|
+
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/videos", params)
|
142
|
+
|
143
|
+
handle_response(response, status)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -3,19 +3,23 @@
|
|
3
3
|
require "beyond_api/utils"
|
4
4
|
require "beyond_api/resources/products/attachments"
|
5
5
|
require "beyond_api/resources/products/availability"
|
6
|
+
require "beyond_api/resources/products/cross_sells"
|
6
7
|
require "beyond_api/resources/products/custom_attributes"
|
7
8
|
require "beyond_api/resources/products/images"
|
8
9
|
require "beyond_api/resources/products/searches"
|
9
10
|
require "beyond_api/resources/products/variation_properties"
|
11
|
+
require "beyond_api/resources/products/videos"
|
10
12
|
|
11
13
|
module BeyondApi
|
12
14
|
class Products < Base
|
13
15
|
include BeyondApi::ProductAttachments
|
14
16
|
include BeyondApi::ProductAvailability
|
17
|
+
include BeyondApi::ProductCrossSells
|
15
18
|
include BeyondApi::ProductCustomAttributes
|
16
19
|
include BeyondApi::ProductImages
|
17
20
|
include BeyondApi::ProductSearches
|
18
21
|
include BeyondApi::ProductVariationProperties
|
22
|
+
include BeyondApi::ProductVideos
|
19
23
|
include BeyondApi::Utils
|
20
24
|
|
21
25
|
#
|
@@ -74,7 +78,6 @@ module BeyondApi
|
|
74
78
|
# "amount" : 99.95,
|
75
79
|
# "currency" : "EUR"
|
76
80
|
# },
|
77
|
-
# "onSale" : true,
|
78
81
|
# "visible" : true,
|
79
82
|
# "taxClass" : "REGULAR",
|
80
83
|
# "shippingWeight" : 100,
|
@@ -134,7 +137,6 @@ module BeyondApi
|
|
134
137
|
# "amount": 99.95,
|
135
138
|
# "currency": "EUR"
|
136
139
|
# },
|
137
|
-
# "onSale": true,
|
138
140
|
# "visible": true,
|
139
141
|
# "taxClass": "REGULAR",
|
140
142
|
# "shippingWeight": 100,
|
@@ -183,7 +185,7 @@ module BeyondApi
|
|
183
185
|
# @return true
|
184
186
|
#
|
185
187
|
# @example
|
186
|
-
# session.products.delete("
|
188
|
+
# session.products.delete("c06c61af-f99a-4698-90fa-8c3199ca732f")
|
187
189
|
#
|
188
190
|
def delete(product_id)
|
189
191
|
response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}")
|
@@ -206,7 +208,7 @@ module BeyondApi
|
|
206
208
|
# @return [OpenStruct]
|
207
209
|
#
|
208
210
|
# @example
|
209
|
-
# @product = session.products.find("
|
211
|
+
# @product = session.products.find("75ebcb57-aefb-4963-8225-060c528e070d")
|
210
212
|
#
|
211
213
|
def find(product_id)
|
212
214
|
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}")
|
@@ -224,10 +226,10 @@ module BeyondApi
|
|
224
226
|
# -H 'Accept: application/hal+json' \
|
225
227
|
# -H 'Authorization: Bearer <Access token>' \
|
226
228
|
# -d '{
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
#
|
229
|
+
# "name" : "patched name",
|
230
|
+
# "description" : "patched description. <p><br></p><blockquote> <ol><li><strong>\n<h1></h1><h6></h6><em><a href=\"http://example.com\" target=\"_blank\"><u>this is my test html</u></a>\n</em></strong> </li></ol> </blockquote>",
|
231
|
+
# "productIdentifiers" : null,
|
232
|
+
# "manufacturer" : "patched manufacturer"
|
231
233
|
# }'
|
232
234
|
#
|
233
235
|
# @param product_id [String] the product UUID
|
@@ -242,7 +244,7 @@ module BeyondApi
|
|
242
244
|
# "productIdentifiers": null,
|
243
245
|
# "manufacturer": "patched manufacturer"
|
244
246
|
# }
|
245
|
-
# @product = session.products.update("
|
247
|
+
# @product = session.products.update("b69e3f47-03b8-40d2-843c-ae89a3d9bcdd", body)
|
246
248
|
#
|
247
249
|
def update(product_id, body)
|
248
250
|
response, status = BeyondApi::Request.patch(@session, "/products/#{product_id}", body)
|
@@ -19,10 +19,10 @@ module BeyondApi
|
|
19
19
|
# @return [OpenStruct]
|
20
20
|
#
|
21
21
|
# @example
|
22
|
-
# @products = session.
|
22
|
+
# @products = session.products_view.all(page: 0, size: 100)
|
23
23
|
#
|
24
24
|
def all(params = {})
|
25
|
-
response, status = BeyondApi::Request.get(@session, "/product-view/products")
|
25
|
+
response, status = BeyondApi::Request.get(@session, "/product-view/products", params)
|
26
26
|
|
27
27
|
handle_response(response, status)
|
28
28
|
end
|
@@ -37,7 +37,7 @@ module BeyondApi
|
|
37
37
|
# @return [OpenStruct]
|
38
38
|
#
|
39
39
|
# @example
|
40
|
-
# @tags = session.
|
40
|
+
# @tags = session.products_view.available_tags
|
41
41
|
#
|
42
42
|
def available_tags
|
43
43
|
response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-available-tags")
|
@@ -58,7 +58,7 @@ module BeyondApi
|
|
58
58
|
# @return [OpenStruct]
|
59
59
|
#
|
60
60
|
# @example
|
61
|
-
# @product = session.
|
61
|
+
# @product = session.products_view.find("f75f8fb2-5a48-4d94-aad6-3d3692c06472")
|
62
62
|
#
|
63
63
|
def find(product_id)
|
64
64
|
response, status = BeyondApi::Request.get(@session, "/product-view/products/#{product_id}")
|
@@ -66,51 +66,6 @@ module BeyondApi
|
|
66
66
|
handle_response(response, status)
|
67
67
|
end
|
68
68
|
|
69
|
-
#
|
70
|
-
# A +POST+ request is used to search for products using a query provided as request body.
|
71
|
-
#
|
72
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-by-query' -i -X POST \
|
73
|
-
# -H 'Content-Type: application/json' \
|
74
|
-
# -H 'Accept: application/hal+json' \
|
75
|
-
# -d '{ "query": {"bool":{"filter":[{"term":{"tags":"number0"}},{"range":{"salesPrice.amount":{"lte":8.7}}},{"range":{"createdAt":{"gte":"now-1h"}}}]}}, "sort": "name.keyword"}'
|
76
|
-
#
|
77
|
-
# @param query [String] the hash to search
|
78
|
-
#
|
79
|
-
# @return [OpenStruct]
|
80
|
-
#
|
81
|
-
# @example
|
82
|
-
# body = {
|
83
|
-
# "query"=> {
|
84
|
-
# "bool"=> {
|
85
|
-
# "filter"=> [{
|
86
|
-
# "term"=> {
|
87
|
-
# "tags"=> "number0"
|
88
|
-
# }
|
89
|
-
# }, {
|
90
|
-
# "range"=> {
|
91
|
-
# "salesPrice.amount"=> {
|
92
|
-
# "lte"=> 8.7
|
93
|
-
# }
|
94
|
-
# }
|
95
|
-
# }, {
|
96
|
-
# "range"=> {
|
97
|
-
# "createdAt"=> {
|
98
|
-
# "gte"=> "now-1h"
|
99
|
-
# }
|
100
|
-
# }
|
101
|
-
# }]
|
102
|
-
# }
|
103
|
-
# },
|
104
|
-
# "sort"=> "name.keyword"
|
105
|
-
# }
|
106
|
-
# @products = session.product_view_products.search_by_query(body)
|
107
|
-
#
|
108
|
-
def search_by_query(query)
|
109
|
-
response, status = BeyondApi::Request.post(@session, "/product-view/products/search/find-by-query", body)
|
110
|
-
|
111
|
-
handle_response(response, status)
|
112
|
-
end
|
113
|
-
|
114
69
|
#
|
115
70
|
# A +GET+ request is used to search for products matching any tag of the list given by a client. The intention is to offer product search capabilities for a shop’s storefront.
|
116
71
|
#
|
@@ -125,7 +80,7 @@ module BeyondApi
|
|
125
80
|
# @return [OpenStruct]
|
126
81
|
#
|
127
82
|
# @example
|
128
|
-
# @products = session.
|
83
|
+
# @products = session.products_view.search_by_tag("number0", {page: 0, size: 100})
|
129
84
|
#
|
130
85
|
def search_by_tag(tag, params = {})
|
131
86
|
response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-tags", params.merge(tag: tag))
|
@@ -147,7 +102,7 @@ module BeyondApi
|
|
147
102
|
# @return [OpenStruct]
|
148
103
|
#
|
149
104
|
# @example
|
150
|
-
# @products = session.
|
105
|
+
# @products = session.products_view.search_by_term("search snippet", {page: 0, size: 100})
|
151
106
|
#
|
152
107
|
def search_by_term(term, params = {})
|
153
108
|
response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-term", params.merge(query: term))
|
@@ -103,7 +103,7 @@ module BeyondApi
|
|
103
103
|
# "amount" => "19.99"
|
104
104
|
# }
|
105
105
|
# }
|
106
|
-
# @shipping_zone = session.shipping_zones.
|
106
|
+
# @shipping_zone = session.shipping_zones.create_shipping_method("905e981c-1489-45af-9138-0a7dc1f0b085", body)
|
107
107
|
#
|
108
108
|
def create_shipping_method(shipping_zone_id, body)
|
109
109
|
response, status = BeyondApi::Request.post(@session, "/shipping-zones/#{shipping_zone_id}/shipping-methods", body)
|
@@ -240,15 +240,15 @@ module BeyondApi
|
|
240
240
|
end
|
241
241
|
|
242
242
|
#
|
243
|
-
# A
|
243
|
+
# A +PUT+ request is used to sort the shipping zones. This is done by passing the self-links of the shipping zones in the desired order.all
|
244
244
|
# The request must contain URIs for all shipping zones of the given page.
|
245
245
|
#
|
246
246
|
# $ curl 'https://api-shop.beyondshop.cloud/api/shipping-zones' -i -X PUT \
|
247
247
|
# -H 'Content-Type: text/uri-list' \
|
248
248
|
# -H 'Authorization: Bearer <Access token>' \
|
249
249
|
# -d 'https://api-shop.beyondshop.cloud/api/shipping-zones/9fa80513-be11-494f-ac01-61832e0d7808
|
250
|
-
#
|
251
|
-
#
|
250
|
+
# https://api-shop.beyondshop.cloud/api/shipping-zones/f0911d4c-1ab0-4bbd-88e3-cb675cbb7da7
|
251
|
+
# https://api-shop.beyondshop.cloud/api/shipping-zones/ef2e7cb7-820e-4d62-b361-12240f635164'
|
252
252
|
#
|
253
253
|
# @beyond_api.scopes +shpz:u+
|
254
254
|
#
|
@@ -261,7 +261,7 @@ module BeyondApi
|
|
261
261
|
# session.shipping_zones.sort(shipping_zone_ids)
|
262
262
|
#
|
263
263
|
def sort(shipping_zone_ids)
|
264
|
-
body = shipping_zone_ids.map { |
|
264
|
+
body = shipping_zone_ids.map { |id| "#{session.api_url}/shipping-zones/#{id}" }
|
265
265
|
response, status = BeyondApi::Request.put(@session, "/shipping-zones", body)
|
266
266
|
|
267
267
|
handle_response(response, status, respond_with_true: true)
|
@@ -9,10 +9,7 @@ module BeyondApi
|
|
9
9
|
#
|
10
10
|
# A +GET+ request is used to retrieve the details of a shop’s address.
|
11
11
|
#
|
12
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X GET
|
13
|
-
# -H 'Authorization: Bearer <Access token>'
|
14
|
-
#
|
15
|
-
# @beyond_api.scopes +shad:r+
|
12
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X GET
|
16
13
|
#
|
17
14
|
# @return [OpenStruct]
|
18
15
|
#
|
@@ -141,7 +138,7 @@ module BeyondApi
|
|
141
138
|
#
|
142
139
|
# @example
|
143
140
|
# body = {
|
144
|
-
# "
|
141
|
+
# "data_uri" => "file.png?hash=212-2323-4343",
|
145
142
|
# "label" => "logo"
|
146
143
|
# }
|
147
144
|
#
|
@@ -225,7 +222,7 @@ module BeyondApi
|
|
225
222
|
# @return [OpenStruct]
|
226
223
|
#
|
227
224
|
# @example
|
228
|
-
# session.shop.image("2feee7ac-f1cb-4faf-9488-f3ce07394141")
|
225
|
+
# @image = session.shop.image("2feee7ac-f1cb-4faf-9488-f3ce07394141")
|
229
226
|
#
|
230
227
|
def image(image_id)
|
231
228
|
response, status = BeyondApi::Request.get(@session, "/shop/images/#{image_id}")
|
@@ -245,7 +242,7 @@ module BeyondApi
|
|
245
242
|
# @return [OpenStruct]
|
246
243
|
#
|
247
244
|
# @example
|
248
|
-
# session.shop.images(size: 5, page: 1)
|
245
|
+
# @images = session.shop.images(size: 5, page: 1)
|
249
246
|
#
|
250
247
|
def images(params = {})
|
251
248
|
response, status = BeyondApi::Request.get(@session, "/shop/images", params)
|
@@ -265,10 +262,10 @@ module BeyondApi
|
|
265
262
|
# @return [OpenStruct]
|
266
263
|
#
|
267
264
|
# @example
|
268
|
-
# session.shop.legal_content("right-of-withdrawal")
|
265
|
+
# @legal_content = session.shop.legal_content("right-of-withdrawal")
|
269
266
|
#
|
270
267
|
def legal_content(legal_content_type)
|
271
|
-
response, status = BeyondApi::Request.get(@session, "/legal-content
|
268
|
+
response, status = BeyondApi::Request.get(@session, "/legal-content/#{legal_content_type}")
|
272
269
|
|
273
270
|
handle_response(response, status)
|
274
271
|
end
|
@@ -286,10 +283,10 @@ module BeyondApi
|
|
286
283
|
# @return [OpenStruct]
|
287
284
|
#
|
288
285
|
# @example
|
289
|
-
# session.shop.legal_contents(size: 5, page: 1)
|
286
|
+
# @legal_content = session.shop.legal_contents(size: 5, page: 1)
|
290
287
|
#
|
291
288
|
def legal_contents(params = {})
|
292
|
-
response, status = BeyondApi::Request.get(@session, "/legal-content")
|
289
|
+
response, status = BeyondApi::Request.get(@session, "/legal-content", params)
|
293
290
|
|
294
291
|
handle_response(response, status)
|
295
292
|
end
|
@@ -305,7 +302,7 @@ module BeyondApi
|
|
305
302
|
# @return [OpenStruct]
|
306
303
|
#
|
307
304
|
# @example
|
308
|
-
# session.shop.legal_details
|
305
|
+
# @legal_details = session.shop.legal_details
|
309
306
|
#
|
310
307
|
def legal_details
|
311
308
|
response, status = BeyondApi::Request.get(@session, "/shop/legal")
|
@@ -361,7 +358,6 @@ module BeyondApi
|
|
361
358
|
# -H 'Authorization: Bearer <Access token>' \
|
362
359
|
# -d '{
|
363
360
|
# "name" : "anotherName",
|
364
|
-
# "closedShopMessage" : "This shop is opening soon.",
|
365
361
|
# "primaryHostname" : "cornershop.amazingdiscounts.xyz",
|
366
362
|
# "fallbackHostname" : "cornershop.beyondshop.cloud",
|
367
363
|
# "tax" : {
|
@@ -384,24 +380,23 @@ module BeyondApi
|
|
384
380
|
# @example
|
385
381
|
# body = {
|
386
382
|
# "name" => "anotherName",
|
387
|
-
# "
|
388
|
-
# "
|
389
|
-
# "fallbackHostname" => "cornershop.beyondshop.cloud",
|
383
|
+
# "primary_hostname" => "cornershop.amazingdiscounts.xyz",
|
384
|
+
# "fallback_hostname" => "cornershop.beyondshop.cloud",
|
390
385
|
# "tax" => {
|
391
386
|
# "taxModel" => "GROSS",
|
392
387
|
# "vatExempted" => false
|
393
388
|
# },
|
394
389
|
# "currencies" => [ "EUR", "USD", "GBP" ],
|
395
|
-
# "
|
390
|
+
# "default_currency" => "USD",
|
396
391
|
# "locales" => [ "en-GB", "de-DE" ],
|
397
|
-
# "
|
398
|
-
# "
|
392
|
+
# "default_locale" => "en-GB",
|
393
|
+
# "closed_by_merchant" => false
|
399
394
|
# }
|
400
395
|
#
|
401
396
|
# session.shop.update(body)
|
402
397
|
#
|
403
398
|
def update(body)
|
404
|
-
response, status = BeyondApi::Request.patch(@session, "/shop")
|
399
|
+
response, status = BeyondApi::Request.patch(@session, "/shop", body)
|
405
400
|
|
406
401
|
handle_response(response, status)
|
407
402
|
end
|
@@ -513,7 +508,7 @@ module BeyondApi
|
|
513
508
|
#
|
514
509
|
# @example
|
515
510
|
# body = {
|
516
|
-
# "
|
511
|
+
# "vat_id" => "GB 111111111"
|
517
512
|
# }
|
518
513
|
#
|
519
514
|
# session.shop.update_legal_details(body)
|
@@ -46,7 +46,7 @@ module BeyondApi
|
|
46
46
|
# @return [OpenStruct]
|
47
47
|
#
|
48
48
|
# @example
|
49
|
-
# session.users.all(
|
49
|
+
# @users = session.users.all(size: 100, page: 0)
|
50
50
|
#
|
51
51
|
def all(params = {})
|
52
52
|
response, status = BeyondApi::Request.get(@session, "/users")
|
@@ -95,8 +95,6 @@ module BeyondApi
|
|
95
95
|
# "newUsername" : "new username"
|
96
96
|
# }'
|
97
97
|
#
|
98
|
-
# @beyond_api.scopes ++
|
99
|
-
#
|
100
98
|
# @param user_id [String] the user UUID
|
101
99
|
# @param new_username [String] the new username
|
102
100
|
# @param current_password [String] the current password
|
@@ -132,7 +130,12 @@ module BeyondApi
|
|
132
130
|
# @return [OpenStruct]
|
133
131
|
#
|
134
132
|
# @example
|
135
|
-
#
|
133
|
+
# body = {
|
134
|
+
# "username" => "user",
|
135
|
+
# "password" => "GoodPassword01!;)",
|
136
|
+
# "email" => "baxter@example.org"
|
137
|
+
# }
|
138
|
+
# @user = session.users.create(body)
|
136
139
|
#
|
137
140
|
def create(body)
|
138
141
|
response, status = BeyondApi::Request.post(@session, "/users", body)
|
@@ -197,7 +200,7 @@ module BeyondApi
|
|
197
200
|
# @return [OpenStruct]
|
198
201
|
#
|
199
202
|
# @example
|
200
|
-
# session.users.find(
|
203
|
+
# @user = session.users.find("e4b528ce-bb9e-4cc5-95e1-7dadfa4cf0f3")
|
201
204
|
#
|
202
205
|
def find(user_id)
|
203
206
|
response, status = BeyondApi::Request.get(@session, "/users/#{user_id}")
|
@@ -218,7 +221,7 @@ module BeyondApi
|
|
218
221
|
# @return [OpenStruct]
|
219
222
|
#
|
220
223
|
# @example
|
221
|
-
# session.users.roles(
|
224
|
+
# @roles = session.users.roles("0d4bd0a5-94dc-498e-b6a6-305c619bb20d")
|
222
225
|
#
|
223
226
|
def roles(user_id)
|
224
227
|
response, status = BeyondApi::Request.get(@session, "/users/#{user_id}/roles")
|
@@ -240,7 +243,7 @@ module BeyondApi
|
|
240
243
|
# @return [OpenStruct]
|
241
244
|
#
|
242
245
|
# @example
|
243
|
-
# session.users.search_by_username(username)
|
246
|
+
# @user = session.users.search_by_username(username)
|
244
247
|
#
|
245
248
|
def search_by_username(username)
|
246
249
|
response, status = BeyondApi::Request.get(@session, "/users/search/find-by-username", username: username)
|
@@ -351,7 +354,7 @@ module BeyondApi
|
|
351
354
|
#
|
352
355
|
# A +POST+ request is used to verify a password against the password guidelines.
|
353
356
|
#
|
354
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/users/verify-password' -i -X POST \
|
357
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/users/verify-password?userRole=merchant' -i -X POST \
|
355
358
|
# -H 'Content-Type: application/json' \
|
356
359
|
# -H 'Accept: application/json' \
|
357
360
|
# -d '{
|
@@ -367,8 +370,8 @@ module BeyondApi
|
|
367
370
|
# @example
|
368
371
|
# session.users.verify_password(password)
|
369
372
|
#
|
370
|
-
def verify_password(password)
|
371
|
-
response, status = BeyondApi::Request.post(@session, "/users/verify-password", password: password)
|
373
|
+
def verify_password(password, user_role)
|
374
|
+
response, status = BeyondApi::Request.post(@session, "/users/verify-password", password: password, user_role: user_role)
|
372
375
|
|
373
376
|
handle_response(response, status, respond_with_true: true)
|
374
377
|
end
|