beyond_api 0.11.1.pre → 0.15.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 +44 -0
- data/Gemfile.lock +25 -25
- data/lib/beyond_api.rb +13 -13
- data/lib/beyond_api/connection.rb +7 -0
- data/lib/beyond_api/ext.rb +8 -1
- data/lib/beyond_api/logger.rb +13 -0
- data/lib/beyond_api/resources/payment_method_definitions.rb +175 -0
- data/lib/beyond_api/resources/pickup_options.rb +84 -0
- data/lib/beyond_api/resources/products.rb +16 -18
- 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/variations.rb +3 -2
- data/lib/beyond_api/session.rb +32 -22
- data/lib/beyond_api/version.rb +1 -1
- data/lib/generators/templates/beyond_api_initializer.rb +15 -0
- metadata +11 -3
@@ -0,0 +1,252 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ShopLocations
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +GET+ request is used to retrieve a list of all locations for the current shop.
|
10
|
+
#
|
11
|
+
# $ curl 'https://yourshop.api.urn/shop/locations' -i -X GET \
|
12
|
+
# -H 'Accept: application/hal+json' \
|
13
|
+
# -H 'Authorization: Bearer <Access token>'
|
14
|
+
#
|
15
|
+
# @beyond_api.scopes +loca:r+
|
16
|
+
#
|
17
|
+
# @option params [Boolean] :paginated
|
18
|
+
# @option params [Integer] :size the page size
|
19
|
+
# @option params [Integer] :page the page number
|
20
|
+
#
|
21
|
+
# @return [OpenStruct]
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# @locations = session.shop.locations(size: 100, page: 0)
|
25
|
+
#
|
26
|
+
def locations(params = {})
|
27
|
+
handle_all_request("/shop/locations", :locations, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# A +POST+ request is used to create a location.
|
32
|
+
#
|
33
|
+
# $ curl 'https://yourshop.api.urn/shop/locations' -i -X POST \
|
34
|
+
# -H 'Content-Type: application/json;charset=UTF-8' \
|
35
|
+
# -H 'Accept: application/hal+json' \
|
36
|
+
# -H 'Authorization: Bearer <Access token>' \
|
37
|
+
# -d '{
|
38
|
+
# "languageCode" : "de",
|
39
|
+
# "storeCode" : "",
|
40
|
+
# "locationName" : "HealthyThings",
|
41
|
+
# "primaryPhone" : "01522 3097093",
|
42
|
+
# "address" : {
|
43
|
+
# "locality" : "Hamburg",
|
44
|
+
# "postalCode" : "20253",
|
45
|
+
# "regionCode" : "DE",
|
46
|
+
# "addressLines" : [ "Pilatuspool 2", "ePages GmbH" ]
|
47
|
+
# },
|
48
|
+
# "primaryCategory" : {
|
49
|
+
# "categoryId" : "gcid:store",
|
50
|
+
# "displayName" : "Geschaeft"
|
51
|
+
# },
|
52
|
+
# "websiteUrl" : "",
|
53
|
+
# "regularHours" : {
|
54
|
+
# "periods" : [ {
|
55
|
+
# "openDay" : "MONDAY",
|
56
|
+
# "openTime" : "18:00",
|
57
|
+
# "closeDay" : "TUESDAY",
|
58
|
+
# "closeTime" : "03:00"
|
59
|
+
# }, {
|
60
|
+
# "openDay" : "WEDNESDAY",
|
61
|
+
# "openTime" : "17:00",
|
62
|
+
# "closeDay" : "WEDNESDAY",
|
63
|
+
# "closeTime" : "23:00"
|
64
|
+
# } ]
|
65
|
+
# },
|
66
|
+
# "latLng" : {
|
67
|
+
# "latitude" : 53.5847424,
|
68
|
+
# "longitude" : 9.968901
|
69
|
+
# }
|
70
|
+
# }'
|
71
|
+
#
|
72
|
+
# @beyond_api.scopes +loca:c+
|
73
|
+
#
|
74
|
+
# @param body [Hash] the request body
|
75
|
+
#
|
76
|
+
# @return [OpenStruct]
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# body = {
|
80
|
+
# "languageCode" => "de",
|
81
|
+
# "storeCode" => "",
|
82
|
+
# "locationName" => "HealthyThings",
|
83
|
+
# "primaryPhone" => "01522 3097093",
|
84
|
+
# "address" => {
|
85
|
+
# "locality" => "Hamburg",
|
86
|
+
# "postalCode" => "20253",
|
87
|
+
# "regionCode" => "DE",
|
88
|
+
# "addressLines" => [ "Pilatuspool 2", "ePages GmbH" ]
|
89
|
+
# },
|
90
|
+
# "primaryCategory" => {
|
91
|
+
# "categoryId" => "gcid:store",
|
92
|
+
# "displayName" => "Geschaeft"
|
93
|
+
# },
|
94
|
+
# "websiteUrl" => "",
|
95
|
+
# "regularHours" => {
|
96
|
+
# "periods" => [ {
|
97
|
+
# "openDay" => "MONDAY",
|
98
|
+
# "openTime" => "18:00",
|
99
|
+
# "closeDay" => "TUESDAY",
|
100
|
+
# "closeTime" => "03:00"
|
101
|
+
# }, {
|
102
|
+
# "openDay" => "WEDNESDAY",
|
103
|
+
# "openTime" => "17:00",
|
104
|
+
# "closeDay" => "WEDNESDAY",
|
105
|
+
# "closeTime" => "23:00"
|
106
|
+
# } ]
|
107
|
+
# },
|
108
|
+
# "latLng" : {
|
109
|
+
# "latitude" => 53.5847424,
|
110
|
+
# "longitude" => 9.968901
|
111
|
+
# }
|
112
|
+
# }
|
113
|
+
# @location = session.shop.create_location(body)
|
114
|
+
#
|
115
|
+
def create_location(body)
|
116
|
+
response, status = BeyondApi::Request.post(@session, "/shop/locations", body)
|
117
|
+
|
118
|
+
handle_response(response, status)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# A +DELETE+ request is used to delete a location.
|
123
|
+
#
|
124
|
+
# $ curl 'https://yourshop.api.urn/shop/locations/5bcf7c0a-d130-4cf8-af0c-5e57d4605be0' -i -X DELETE \
|
125
|
+
# -H 'Accept: application/hal+json' \
|
126
|
+
# -H 'Authorization: Bearer <Access token>'
|
127
|
+
#
|
128
|
+
# @beyond_api.scopes +loca:d+
|
129
|
+
#
|
130
|
+
# @param location_id [String] the location UUID
|
131
|
+
#
|
132
|
+
# @return true
|
133
|
+
#
|
134
|
+
# @example
|
135
|
+
# session.shop.delete_location("f461fb56-1984-4ade-bd4e-007c273cc923")
|
136
|
+
#
|
137
|
+
def delete_location(location_id)
|
138
|
+
response, status = BeyondApi::Request.delete(@session, "/shop/locations/#{location_id}")
|
139
|
+
|
140
|
+
handle_response(response, status, respond_with_true: true)
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# A +GET+ request is used to retrieve a particular location by its id.
|
145
|
+
#
|
146
|
+
# $ curl 'https://yourshop.api.urn/shop/locations/09ca2715-cdf7-4af3-8b22-9ecf39d1e202' -i -X GET \
|
147
|
+
# -H 'Accept: application/hal+json' \
|
148
|
+
# -H 'Authorization: Bearer <Access token>'
|
149
|
+
#
|
150
|
+
# @beyond_api.scopes +loca:r+
|
151
|
+
#
|
152
|
+
# @param location_id [String] the location UUID
|
153
|
+
#
|
154
|
+
# @return [OpenStruct]
|
155
|
+
#
|
156
|
+
# @example
|
157
|
+
# @location = session.shop.location("27a94b71-9b17-4f06-9596-fbbf4d18021f")
|
158
|
+
#
|
159
|
+
def location(location_id)
|
160
|
+
response, status = BeyondApi::Request.get(@session, "/shop/locations/#{location_id}")
|
161
|
+
|
162
|
+
handle_response(response, status)
|
163
|
+
end
|
164
|
+
|
165
|
+
#
|
166
|
+
# A +PUT+ request is used to update a location.
|
167
|
+
#
|
168
|
+
# $ curl 'https://yourshop.api.urn/shop/locations/a7a2acfa-0243-4e52-8b56-81cb781ce61d' -i -X PUT \
|
169
|
+
# -H 'Content-Type: application/json;charset=UTF-8' \
|
170
|
+
# -H 'Accept: application/hal+json' \
|
171
|
+
# -H 'Authorization: Bearer <Access token>' \
|
172
|
+
# -d '{
|
173
|
+
# "languageCode" : "en",
|
174
|
+
# "storeCode" : "",
|
175
|
+
# "locationName" : "UnhealthyThings",
|
176
|
+
# "primaryPhone" : "01234 691997",
|
177
|
+
# "address" : {
|
178
|
+
# "locality" : "London",
|
179
|
+
# "postalCode" : "1",
|
180
|
+
# "regionCode" : "GB",
|
181
|
+
# "addressLines" : [ "St. James Square", "ePages Ltd" ]
|
182
|
+
# },
|
183
|
+
# "primaryCategory" : {
|
184
|
+
# "categoryId" : "gcid:store",
|
185
|
+
# "displayName" : "Shop"
|
186
|
+
# },
|
187
|
+
# "websiteUrl" : "",
|
188
|
+
# "regularHours" : {
|
189
|
+
# "periods" : [ {
|
190
|
+
# "openDay" : "SATURDAY",
|
191
|
+
# "openTime" : "06:00",
|
192
|
+
# "closeDay" : "SATURDAY",
|
193
|
+
# "closeTime" : "22:00"
|
194
|
+
# } ]
|
195
|
+
# },
|
196
|
+
# "latLng" : {
|
197
|
+
# "latitude" : 51.5072,
|
198
|
+
# "longitude" : -0.1353
|
199
|
+
# }
|
200
|
+
# }'
|
201
|
+
#
|
202
|
+
# @beyond_api.scopes +loca:u+
|
203
|
+
#
|
204
|
+
# @param location_id [String] the location UUID
|
205
|
+
# @param body [Hash] the request body
|
206
|
+
#
|
207
|
+
# @return [OpenStruct]
|
208
|
+
#
|
209
|
+
# @example
|
210
|
+
# body = {
|
211
|
+
# "languageCode" => "de",
|
212
|
+
# "storeCode" => "",
|
213
|
+
# "locationName" => "HealthyThings",
|
214
|
+
# "primaryPhone" => "01522 3097093",
|
215
|
+
# "address" => {
|
216
|
+
# "locality" => "Hamburg",
|
217
|
+
# "postalCode" => "20253",
|
218
|
+
# "regionCode" => "DE",
|
219
|
+
# "addressLines" => [ "Pilatuspool 2", "ePages GmbH" ]
|
220
|
+
# },
|
221
|
+
# "primaryCategory" => {
|
222
|
+
# "categoryId" => "gcid:store",
|
223
|
+
# "displayName" => "Geschaeft"
|
224
|
+
# },
|
225
|
+
# "websiteUrl" => "",
|
226
|
+
# "regularHours" => {
|
227
|
+
# "periods" => [ {
|
228
|
+
# "openDay" => "MONDAY",
|
229
|
+
# "openTime" => "18:00",
|
230
|
+
# "closeDay" => "TUESDAY",
|
231
|
+
# "closeTime" => "03:00"
|
232
|
+
# }, {
|
233
|
+
# "openDay" => "WEDNESDAY",
|
234
|
+
# "openTime" => "17:00",
|
235
|
+
# "closeDay" => "WEDNESDAY",
|
236
|
+
# "closeTime" => "23:00"
|
237
|
+
# } ]
|
238
|
+
# },
|
239
|
+
# "latLng" : {
|
240
|
+
# "latitude" => 53.5847424,
|
241
|
+
# "longitude" => 9.968901
|
242
|
+
# }
|
243
|
+
# }
|
244
|
+
# @location = session.shop.update_location("27a94b71-9b17-4f06-9596-fbbf4d18021f", body)
|
245
|
+
#
|
246
|
+
def update_location(location_id, body)
|
247
|
+
response, status = BeyondApi::Request.put(@session, "/shop/locations/#{location_id}", body)
|
248
|
+
|
249
|
+
handle_response(response, status)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "beyond_api/utils"
|
4
|
-
require "beyond_api/resources/variations/images"
|
5
|
-
require "beyond_api/resources/variations/availability"
|
6
4
|
|
7
5
|
module BeyondApi
|
6
|
+
autoload :VariationImages, "beyond_api/resources/variations/images"
|
7
|
+
autoload :VariationAvailability, "beyond_api/resources/variations/availability"
|
8
|
+
|
8
9
|
class Variations < Base
|
9
10
|
include BeyondApi::VariationImages
|
10
11
|
include BeyondApi::VariationAvailability
|
data/lib/beyond_api/session.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "beyond_api/resources/base"
|
4
|
-
require "beyond_api/resources/carts"
|
5
|
-
require "beyond_api/resources/categories_view"
|
6
|
-
require "beyond_api/resources/categories"
|
7
|
-
require "beyond_api/resources/checkout_settings"
|
8
|
-
require "beyond_api/resources/customers"
|
9
|
-
require "beyond_api/resources/newsletter_target"
|
10
|
-
require "beyond_api/resources/order_settings"
|
11
|
-
require "beyond_api/resources/orders"
|
12
|
-
require "beyond_api/resources/payment_methods"
|
13
|
-
require "beyond_api/resources/product_attribute_definitions"
|
14
|
-
require "beyond_api/resources/products_view"
|
15
|
-
require "beyond_api/resources/products"
|
16
|
-
require "beyond_api/resources/script_tags"
|
17
|
-
require "beyond_api/resources/shipping_zones"
|
18
|
-
require "beyond_api/resources/shop"
|
19
|
-
require "beyond_api/resources/signers"
|
20
|
-
require "beyond_api/resources/token"
|
21
|
-
require "beyond_api/resources/users"
|
22
|
-
require "beyond_api/resources/variations"
|
23
|
-
require "beyond_api/resources/webhook_subscriptions"
|
24
|
-
|
25
3
|
module BeyondApi
|
4
|
+
autoload :Base, "beyond_api/resources/base"
|
5
|
+
autoload :Carts, "beyond_api/resources/carts"
|
6
|
+
autoload :CategoriesView, "beyond_api/resources/categories_view"
|
7
|
+
autoload :Categories, "beyond_api/resources/categories"
|
8
|
+
autoload :CheckoutSettings, "beyond_api/resources/checkout_settings"
|
9
|
+
autoload :Customers, "beyond_api/resources/customers"
|
10
|
+
autoload :NewsletterTarget, "beyond_api/resources/newsletter_target"
|
11
|
+
autoload :OrderSettings, "beyond_api/resources/order_settings"
|
12
|
+
autoload :Orders, "beyond_api/resources/orders"
|
13
|
+
autoload :PaymentMethodDefinitions, "beyond_api/resources/payment_method_definitions"
|
14
|
+
autoload :PickupOptions, "beyond_api/resources/pickup_options"
|
15
|
+
autoload :PaymentMethods, "beyond_api/resources/payment_methods"
|
16
|
+
autoload :ProductAttributeDefinitions, "beyond_api/resources/product_attribute_definitions"
|
17
|
+
autoload :ProductsView, "beyond_api/resources/products_view"
|
18
|
+
autoload :Products, "beyond_api/resources/products"
|
19
|
+
autoload :ScriptTags, "beyond_api/resources/script_tags"
|
20
|
+
autoload :ShippingZones, "beyond_api/resources/shipping_zones"
|
21
|
+
autoload :Shop, "beyond_api/resources/shop"
|
22
|
+
autoload :Signers, "beyond_api/resources/signers"
|
23
|
+
autoload :Token, "beyond_api/resources/token"
|
24
|
+
autoload :Users, "beyond_api/resources/users"
|
25
|
+
autoload :Variations, "beyond_api/resources/variations"
|
26
|
+
autoload :WebhookSubscriptions, "beyond_api/resources/webhook_subscriptions"
|
27
|
+
|
26
28
|
class Session
|
27
29
|
attr_reader :api_url
|
28
30
|
attr_accessor :access_token, :refresh_token
|
@@ -65,10 +67,18 @@ module BeyondApi
|
|
65
67
|
BeyondApi::Orders.new(self)
|
66
68
|
end
|
67
69
|
|
70
|
+
def payment_method_definitions
|
71
|
+
BeyondApi::PaymentMethodDefinitions.new(self)
|
72
|
+
end
|
73
|
+
|
68
74
|
def payment_methods
|
69
75
|
BeyondApi::PaymentMethods.new(self)
|
70
76
|
end
|
71
77
|
|
78
|
+
def pickup_options
|
79
|
+
BeyondApi::PickupOptions.new(self)
|
80
|
+
end
|
81
|
+
|
72
82
|
def product_attribute_definitions
|
73
83
|
BeyondApi::ProductAttributeDefinitions.new(self)
|
74
84
|
end
|
data/lib/beyond_api/version.rb
CHANGED
@@ -12,6 +12,21 @@ BeyondApi.setup do |config|
|
|
12
12
|
# Configure the request timeout in seconds. Default is 5 seconds.
|
13
13
|
# config.timeout = 5.seconds
|
14
14
|
|
15
|
+
# ==> Log configuration
|
16
|
+
|
17
|
+
# Configure the log level. Must be one of :debug, :info, :warn, :error,
|
18
|
+
# :fatal or :unknown. Default is :info.
|
19
|
+
#
|
20
|
+
# config.log_level = :info
|
21
|
+
|
22
|
+
# Configure is response headers should be logged. Default is false.
|
23
|
+
#
|
24
|
+
# config.log_headers = false
|
25
|
+
|
26
|
+
# Configure is response bodies should be logged. Default is false.
|
27
|
+
#
|
28
|
+
# config.log_bodies = false
|
29
|
+
|
15
30
|
# ==> Response configuration
|
16
31
|
# Configure if :_links should be removed from response. Default is false and
|
17
32
|
# :_links are gonna be part of the response.
|
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.15.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unai Abrisketa
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/beyond_api/connection.rb
|
136
136
|
- lib/beyond_api/error.rb
|
137
137
|
- lib/beyond_api/ext.rb
|
138
|
+
- lib/beyond_api/logger.rb
|
138
139
|
- lib/beyond_api/request.rb
|
139
140
|
- lib/beyond_api/resources/base.rb
|
140
141
|
- lib/beyond_api/resources/carts.rb
|
@@ -145,7 +146,9 @@ files:
|
|
145
146
|
- lib/beyond_api/resources/newsletter_target.rb
|
146
147
|
- lib/beyond_api/resources/order_settings.rb
|
147
148
|
- lib/beyond_api/resources/orders.rb
|
149
|
+
- lib/beyond_api/resources/payment_method_definitions.rb
|
148
150
|
- lib/beyond_api/resources/payment_methods.rb
|
151
|
+
- lib/beyond_api/resources/pickup_options.rb
|
149
152
|
- lib/beyond_api/resources/product_attribute_definitions.rb
|
150
153
|
- lib/beyond_api/resources/products.rb
|
151
154
|
- lib/beyond_api/resources/products/attachments.rb
|
@@ -160,6 +163,11 @@ files:
|
|
160
163
|
- lib/beyond_api/resources/script_tags.rb
|
161
164
|
- lib/beyond_api/resources/shipping_zones.rb
|
162
165
|
- lib/beyond_api/resources/shop.rb
|
166
|
+
- lib/beyond_api/resources/shops/address.rb
|
167
|
+
- lib/beyond_api/resources/shops/attributes.rb
|
168
|
+
- lib/beyond_api/resources/shops/images.rb
|
169
|
+
- lib/beyond_api/resources/shops/legals.rb
|
170
|
+
- lib/beyond_api/resources/shops/locations.rb
|
163
171
|
- lib/beyond_api/resources/signers.rb
|
164
172
|
- lib/beyond_api/resources/token.rb
|
165
173
|
- lib/beyond_api/resources/users.rb
|
@@ -190,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
198
|
- !ruby/object:Gem::Version
|
191
199
|
version: 1.3.1
|
192
200
|
requirements: []
|
193
|
-
rubygems_version: 3.0.
|
201
|
+
rubygems_version: 3.0.3
|
194
202
|
signing_key:
|
195
203
|
specification_version: 4
|
196
204
|
summary: Ruby client to access the Beyond API
|