beyond_api 0.24.1.pre → 0.24.3.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 +5 -0
- data/Gemfile.lock +1 -1
- data/lib/beyond_api/connection.rb +4 -3
- data/lib/beyond_api/error.rb +2 -0
- data/lib/beyond_api/resources/shipping_zones.rb +57 -1
- data/lib/beyond_api/utils.rb +7 -1
- data/lib/beyond_api/version.rb +1 -1
- data/lib/beyond_api.rb +10 -1
- data/lib/generators/templates/beyond_api_initializer.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9a08ccefc4acb0bfeacf32a46a5245957fecd2aa36e382417031a641638bb0c
|
4
|
+
data.tar.gz: 5841b98257b1233859ac6e4066172411017560aca64abf3e87ec134452949d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6a82f6ff8d9902d48541ca9a4e1d0458b42256cc3678c2960a7fad0e99cc6648fbd0ff3a93f795405ad22048bd4bf3c08d697175b2c8981b11f656b23b061ed
|
7
|
+
data.tar.gz: 1dab71c2c694618119f57aaad1fe46a5febf61a104ae5251e737e83418883d449a01cb1b2646f236011acef501877bf8f25bc62ba4ca3a3b51ce2fc78dbe747d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,15 +9,16 @@ module BeyondApi
|
|
9
9
|
|
10
10
|
def self.default
|
11
11
|
Faraday.new(ssl: { verify: true }) do |faraday|
|
12
|
+
faraday.adapter(:net_http)
|
12
13
|
faraday.options[:open_timeout] = BeyondApi.configuration.open_timeout.to_i
|
13
14
|
faraday.options[:timeout] = BeyondApi.configuration.timeout.to_i
|
14
|
-
faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
|
15
|
-
bodies: BeyondApi.configuration.log_bodies }
|
16
15
|
faraday.headers["Accept"] = "application/json"
|
17
16
|
faraday.headers["Content-Type"] = "application/json"
|
18
17
|
faraday.request(:multipart)
|
19
18
|
faraday.request(:url_encoded)
|
20
|
-
faraday.
|
19
|
+
faraday.request(:retry, BeyondApi.configuration.retry_options)
|
20
|
+
faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
|
21
|
+
bodies: BeyondApi.configuration.log_bodies }
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
data/lib/beyond_api/error.rb
CHANGED
@@ -5,6 +5,8 @@ module BeyondApi
|
|
5
5
|
attr_reader :error_id, :details, :trace_id, :full_message, :status_code, :error, :error_description
|
6
6
|
|
7
7
|
def initialize(data, status_code = nil)
|
8
|
+
data ||= {}
|
9
|
+
|
8
10
|
@error_id = data["errorId"]
|
9
11
|
@details = data["details"]
|
10
12
|
@trace_id = data["traceId"]
|
@@ -108,7 +108,7 @@ module BeyondApi
|
|
108
108
|
# "amount" => "19.99"
|
109
109
|
# }
|
110
110
|
# }
|
111
|
-
# @
|
111
|
+
# @shipping_method = session.shipping_zones.create_shipping_method("905e981c-1489-45af-9138-0a7dc1f0b085", body)
|
112
112
|
#
|
113
113
|
def create_shipping_method(shipping_zone_id, body)
|
114
114
|
path = "/shipping-zones/#{shipping_zone_id}/shipping-methods"
|
@@ -360,5 +360,61 @@ module BeyondApi
|
|
360
360
|
|
361
361
|
handle_response(response, status)
|
362
362
|
end
|
363
|
+
|
364
|
+
#
|
365
|
+
# A +PUT+ request is used to update a shipping method in a shipping zone.
|
366
|
+
#
|
367
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shipping-zones/c4137d8b-3dd1-4b73-91f0-32f1433c8195/shipping-methods/25df7018-a7a2-4903-85fa-6a3a73ae40b2' -i -X PUT \
|
368
|
+
# -H 'Content-Type: application/json' \
|
369
|
+
# -H 'Authorization: Bearer <Access token>' \
|
370
|
+
# -d '{
|
371
|
+
# "name" : "Express",
|
372
|
+
# "description" : "Shipping overnight. Delivery on the next day.",
|
373
|
+
# "taxClass" : "REGULAR",
|
374
|
+
# "freeShippingValue" : {
|
375
|
+
# "currency" : "EUR",
|
376
|
+
# "amount" : 200
|
377
|
+
# },
|
378
|
+
# "fixedPrice" : {
|
379
|
+
# "taxModel" : "GROSS",
|
380
|
+
# "currency" : "EUR",
|
381
|
+
# "amount" : 25
|
382
|
+
# }
|
383
|
+
# }'
|
384
|
+
#
|
385
|
+
# @beyond_api.scopes +shpz:u+
|
386
|
+
#
|
387
|
+
# @param shipping_zone_id [String] the shipping zone UUID
|
388
|
+
# @param shipping_method_id [String] the shipping method UUID
|
389
|
+
# @param body [String] the request body
|
390
|
+
#
|
391
|
+
# @return [OpenStruct]
|
392
|
+
#
|
393
|
+
# @example
|
394
|
+
# body = {
|
395
|
+
# "name" : "Express",
|
396
|
+
# "description" : "Shipping overnight. Delivery on the next day.",
|
397
|
+
# "taxClass" : "REGULAR",
|
398
|
+
# "freeShippingValue" : {
|
399
|
+
# "currency" : "EUR",
|
400
|
+
# "amount" : 200
|
401
|
+
# },
|
402
|
+
# "fixedPrice" : {
|
403
|
+
# "taxModel" : "GROSS",
|
404
|
+
# "currency" : "EUR",
|
405
|
+
# "amount" : 25
|
406
|
+
# }
|
407
|
+
# }
|
408
|
+
# @shipping_method = session.shipping_zones.update_shipping_method("c4137d8b-3dd1-4b73-91f0-32f1433c8195", "25df7018-a7a2-4903-85fa-6a3a73ae40b2", body)
|
409
|
+
#
|
410
|
+
def update_shipping_method(shipping_zone_id, shipping_method_id, body)
|
411
|
+
path = "/shipping-zones/#{shipping_zone_id}/shipping-methods/#{shipping_method_id}"
|
412
|
+
|
413
|
+
response, status = BeyondApi::Request.put(@session,
|
414
|
+
path,
|
415
|
+
body)
|
416
|
+
|
417
|
+
handle_response(response, status)
|
418
|
+
end
|
363
419
|
end
|
364
420
|
end
|
data/lib/beyond_api/utils.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "ostruct"
|
4
|
+
|
3
5
|
module BeyondApi
|
4
6
|
module Utils
|
5
7
|
extend self
|
@@ -22,7 +24,11 @@ module BeyondApi
|
|
22
24
|
result = all_paginated(url, params.merge(page: 0, size: paginated_size))
|
23
25
|
|
24
26
|
(1..result[:page][:total_pages] - 1).each do |page|
|
25
|
-
result[:embedded][resource].concat(
|
27
|
+
result[:embedded][resource].concat(
|
28
|
+
all_paginated(url,
|
29
|
+
params.merge(page: page,
|
30
|
+
size: paginated_size))[:embedded][resource]
|
31
|
+
)
|
26
32
|
end
|
27
33
|
|
28
34
|
result[:page][:size] = result[:page][:total_elements]
|
data/lib/beyond_api/version.rb
CHANGED
data/lib/beyond_api.rb
CHANGED
@@ -29,7 +29,7 @@ module BeyondApi
|
|
29
29
|
class Configuration
|
30
30
|
attr_accessor :client_id, :client_secret, :open_timeout, :timeout, :remove_response_links,
|
31
31
|
:remove_response_key_underscores, :object_struct_responses, :raise_error_requests,
|
32
|
-
:log_headers, :log_bodies, :log_level, :all_pagination_size
|
32
|
+
:log_headers, :log_bodies, :log_level, :all_pagination_size, :retry_options
|
33
33
|
|
34
34
|
def initialize
|
35
35
|
@client_id = nil
|
@@ -46,6 +46,15 @@ module BeyondApi
|
|
46
46
|
@log_bodies = false
|
47
47
|
|
48
48
|
@all_pagination_size = 200
|
49
|
+
|
50
|
+
@retry_options = {
|
51
|
+
max: 5,
|
52
|
+
interval: 0.05,
|
53
|
+
interval_randomness: 0.5,
|
54
|
+
backoff_factor: 2,
|
55
|
+
retry_statuses: [409],
|
56
|
+
exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed]
|
57
|
+
}
|
49
58
|
end
|
50
59
|
end
|
51
60
|
end
|
@@ -50,4 +50,18 @@ BeyondApi.setup do |config|
|
|
50
50
|
# BeyondApi::Error object with detailed information of the error.
|
51
51
|
# Default is false.
|
52
52
|
# config.raise_error_requests = false
|
53
|
+
|
54
|
+
# ==> Retry configuration
|
55
|
+
# Configure the retry options for requests. Default is:
|
56
|
+
# config.retry_options = {
|
57
|
+
# max: 5,
|
58
|
+
# interval: 0.05,
|
59
|
+
# interval_randomness: 0.5,
|
60
|
+
# backoff_factor: 2,
|
61
|
+
# retry_statuses: [409],
|
62
|
+
# exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed]
|
63
|
+
# }
|
64
|
+
# Or you can set single retry options like this:
|
65
|
+
# config.retry_options[:max] = 5
|
66
|
+
# config.retry_options[:interval] = 1
|
53
67
|
end
|
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.24.
|
4
|
+
version: 0.24.3.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: 2024-11-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|