beyond_api 0.20.0.pre → 0.21.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +2 -2
- data/lib/beyond_api/request.rb +4 -2
- data/lib/beyond_api/resources/products/images.rb +1 -1
- data/lib/beyond_api/resources/variations/images.rb +32 -0
- data/lib/beyond_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40f831d05843ba3350e2aa8a390715004c1bc99f82836a9f40b60e7f0888ef25
|
4
|
+
data.tar.gz: 4ae22902b0eb2b17941d3e1c59c039eba3d374cb6c0836091ed96906e2f2eae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555e694512db5677f89330f54586fc377461e7d5ea17d8a4d8fb4c65851c01ab2f443ee182b1ebe50f725e57eceada098d4eb11e7e2d538f2a5b8bffd69fafd1
|
7
|
+
data.tar.gz: 41752eb106202b23d7c1a449e30d6e4defe811d00bddb1280403829fe71d59683a08ae0b7797c615ff88a583ddcbcd05aa60c72dcc1b6b47ce0b610732c8ac6f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/beyond_api/request.rb
CHANGED
@@ -20,12 +20,14 @@ module BeyondApi
|
|
20
20
|
end
|
21
21
|
|
22
22
|
[:post, :put, :patch].each do |method|
|
23
|
-
define_method(method) do |session, path, body = {}, params = {}|
|
23
|
+
define_method(method) do |session, path, body = {}, params = {}, content_type = 'application/json'|
|
24
24
|
response = BeyondApi::Connection.default.send(method) do |request|
|
25
25
|
request.url(session.api_url + path)
|
26
26
|
request.headers["Authorization"] = "Bearer #{session.access_token}" unless session.access_token.nil?
|
27
|
+
request.headers["Content-Type"] = content_type
|
27
28
|
request.params = params.to_h.camelize_keys
|
28
|
-
|
29
|
+
|
30
|
+
request.body = body.respond_to?(:camelize_keys) ? body.camelize_keys.to_json : body
|
29
31
|
end
|
30
32
|
|
31
33
|
[response.body.blank? ? nil : JSON.parse(response.body), response.status]
|
@@ -162,7 +162,7 @@ module BeyondApi
|
|
162
162
|
#
|
163
163
|
def sort_images(product_id, image_ids)
|
164
164
|
body = image_ids.map { |image_id| "#{@session.api_url}/products/#{product_id}/images/#{image_id}" }
|
165
|
-
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/images", body)
|
165
|
+
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/images", body.join("\n"), {}, 'text/uri-list')
|
166
166
|
|
167
167
|
handle_response(response, status, respond_with_true: true)
|
168
168
|
end
|
@@ -129,6 +129,38 @@ module BeyondApi
|
|
129
129
|
handle_response(response, status)
|
130
130
|
end
|
131
131
|
|
132
|
+
# A +PUT+ request is used to sort the variation images. This is done by passing the self-links of the images to the desired variation. The request must contain URIs for all images of the given page.
|
133
|
+
#
|
134
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/8a8a7002-f864-4011-9991-d6ffb1bd1085/variations/60c2c2a5-ece0-4d04-b90d-f38ee710961c/images' -i -X PUT \
|
135
|
+
# -H 'Content-Type: text/uri-list' \
|
136
|
+
# -H 'Authorization: Bearer <Access token>' \
|
137
|
+
# -d 'https://api-shop.beyondshop.cloud/api/products/8a8a7002-f864-4011-9991-d6ffb1bd1085/variations/60c2c2a5-ece0-4d04-b90d-f38ee710961c/images/a12cae49-3efb-4874-989e-37df6981a4db
|
138
|
+
# https://api-shop.beyondshop.cloud/api/products/8a8a7002-f864-4011-9991-d6ffb1bd1085/variations/60c2c2a5-ece0-4d04-b90d-f38ee710961c/images/4f562165-968c-42fd-a245-1dcc045f8151
|
139
|
+
# https://api-shop.beyondshop.cloud/api/products/8a8a7002-f864-4011-9991-d6ffb1bd1085/variations/60c2c2a5-ece0-4d04-b90d-f38ee710961c/images/93cd0802-15db-4772-b524-e1c4c6c27b77'
|
140
|
+
#
|
141
|
+
# @beyond_api.scopes +prod:u+
|
142
|
+
#
|
143
|
+
# @param product_id [String] the product UUID
|
144
|
+
# @param variation_id [String] the variation UUID
|
145
|
+
# @param images [Array] the image UUIDS
|
146
|
+
#
|
147
|
+
# @return true
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# body = [
|
151
|
+
# "c9082802-a0d0-416e-9039-02fa465a027e",
|
152
|
+
# "78e9993d-8db3-45d8-8f76-6b8f2aea9c45",
|
153
|
+
# "9233ee97-5dbb-4c00-a7b2-e1512c69a938"
|
154
|
+
# ]
|
155
|
+
# session.variations.sort_images("3f4b2b56-c22d-4d80-b4ed-d5b33ed161eb", body)
|
156
|
+
#
|
157
|
+
def sort_images(product_id, variation_id, image_ids)
|
158
|
+
body = image_ids.map { |image_id| "#{@session.api_url}/products/#{product_id}/variations/#{variation_id}/images/#{image_id}" }
|
159
|
+
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/variations/#{variation_id}/images", body.join("\n"), {}, 'text/uri-list')
|
160
|
+
|
161
|
+
handle_response(response, status, respond_with_true: true)
|
162
|
+
end
|
163
|
+
|
132
164
|
#
|
133
165
|
# A +POST+ request is used to upload an image to the image storage and assign the URL of the image to the variation. The body of the request must contain the content of the image.
|
134
166
|
#
|
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.21.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:
|
14
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
- !ruby/object:Gem::Version
|
244
244
|
version: 1.3.1
|
245
245
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
246
|
+
rubygems_version: 3.2.16
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
249
|
summary: Ruby client to access the Beyond API
|