beyond_api 0.20.0.pre → 0.22.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: '084d3533192827ae43bcbbdcef706d5e6a3fd9ab7c518492c87dcf57e2ff8233'
4
- data.tar.gz: e28b3a3526b2a97eb511137acf723345512dadcaa9fd7532990245ef0846d572
3
+ metadata.gz: 36af284208461355e7ae3302f115ac42bc76acdb5263075668913143a848ba44
4
+ data.tar.gz: 1fe0caa89098be3311ae83578e02865f4430c575a1492ccfa652539dc17a8ed9
5
5
  SHA512:
6
- metadata.gz: 25f33bb7cefa616071fb0b29bbf1c9a104eeb963407e58049a61ee80d9fa93e920859350129c6c398160e357b2de0fb3c9bbf2da4aac63c61cfeccf5f2154e5c
7
- data.tar.gz: ca5922134ab627f9fa3482e4a4b367bd0b1252df4a15f6536045b5390518876c597dbedeca3738c51c16402d7dafdf67bc314c3e995398d421d1d7dca0bde74d
6
+ metadata.gz: 8bffe7d60dff8e3e564691a8d3d441416876e00e39e8169b58749cadaad9579fd5bf9e346794c63fc6bd0a61791c83687abf56fa80b3ed7eaaf57aafe26b3e8e
7
+ data.tar.gz: 80fae8d0016715b82b453f9b589036dcb5afb1591b6db39fe511792fc01bbd5f553d9865cd8c20a7c398ab78368c7d0bbdca5e2b166ecf2ef472ed382fd26489
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### v0.22.0.pre
2
+
3
+ * features
4
+ * Add at `ScriptTags#all` an optional parameter to retrieve only owner scripts
5
+
6
+ ### v0.21.0.pre
7
+
8
+ * bug-fixes
9
+ * Fix `Products#sort_images` method
10
+
11
+ * features
12
+ * Add `Variations#sort_images` method
1
13
  ### v0.20.0.pre
2
14
 
3
15
  * features
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_api (0.20.0.pre)
4
+ beyond_api (0.22.0.pre)
5
5
  faraday (~> 1.8.0)
6
6
 
7
7
  GEM
@@ -45,7 +45,7 @@ GEM
45
45
  concurrent-ruby (~> 1.0)
46
46
  method_source (1.0.0)
47
47
  minitest (5.14.4)
48
- multipart-post (2.1.1)
48
+ multipart-post (2.2.3)
49
49
  parallel (1.21.0)
50
50
  parser (3.0.3.1)
51
51
  ast (~> 2.4.1)
@@ -112,4 +112,4 @@ DEPENDENCIES
112
112
  yard (~> 0.9)
113
113
 
114
114
  BUNDLED WITH
115
- 2.2.31
115
+ 2.3.0
@@ -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
- request.body = body.camelize_keys.to_json
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]
@@ -139,7 +139,7 @@ module BeyondApi
139
139
  # -H 'Authorization: Bearer <Access token>' \
140
140
  # -d '{
141
141
  # "name" : "Another name",
142
- # "description" : "Pay by Converge.",
142
+ # "description" : "Pay by ACME.",
143
143
  # "taxClass" : "REGULAR",
144
144
  # "discountOrFee" : {
145
145
  # "type" : "ABSOLUTE",
@@ -166,7 +166,7 @@ module BeyondApi
166
166
  # @example
167
167
  # body = {
168
168
  # "name" => "Another name",
169
- # "description" => "Pay by Converge.",
169
+ # "description" => "Pay by ACME.",
170
170
  # "tax_class" => "REGULAR",
171
171
  # "discount_or_fee" => {
172
172
  # "type" => "ABSOLUTE",
@@ -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
@@ -13,6 +13,7 @@ module BeyondApi
13
13
  # -H 'Authorization: Bearer <Access token>'
14
14
  #
15
15
  # @option params [Boolean] :paginated
16
+ # @option params [Boolean] :only_own
16
17
  # @option params [Integer] :size the page size
17
18
  # @option params [Integer] :page the page number
18
19
  #
@@ -24,6 +25,8 @@ module BeyondApi
24
25
  def all(params = {})
25
26
  path = "/script-tags"
26
27
 
28
+ params.merge!(client_id: BeyondApi.configuration.client_id) if params[:only_own]
29
+
27
30
  handle_all_request(path, :script_tags, params)
28
31
  end
29
32
 
@@ -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
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeyondApi
4
- VERSION = "0.20.0.pre"
4
+ VERSION = "0.22.0.pre"
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0.pre
4
+ version: 0.22.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
8
8
  - Kathia Salazar
9
9
  - German San Emeterio
10
10
  - Kenneth Gallego
11
- autorequire:
11
+ autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-12-03 00:00:00.000000000 Z
14
+ date: 2022-12-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -153,8 +153,8 @@ dependencies:
153
153
  - - "~>"
154
154
  - !ruby/object:Gem::Version
155
155
  version: 1.8.0
156
- description:
157
- email:
156
+ description:
157
+ email:
158
158
  executables: []
159
159
  extensions: []
160
160
  extra_rdoc_files: []
@@ -228,7 +228,7 @@ files:
228
228
  homepage: https://github.com/ePages-de/beyond_api-ruby_client
229
229
  licenses: []
230
230
  metadata: {}
231
- post_install_message:
231
+ post_install_message:
232
232
  rdoc_options: []
233
233
  require_paths:
234
234
  - lib
@@ -243,8 +243,8 @@ 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.0.3
247
- signing_key:
246
+ rubygems_version: 3.3.7
247
+ signing_key:
248
248
  specification_version: 4
249
249
  summary: Ruby client to access the Beyond API
250
250
  test_files: []