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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -3
  3. data/Gemfile.lock +3 -3
  4. data/lib/beyond_api/resources/carts.rb +18 -9
  5. data/lib/beyond_api/resources/categories.rb +2 -2
  6. data/lib/beyond_api/resources/categories_view.rb +13 -2
  7. data/lib/beyond_api/resources/checkout_settings.rb +16 -1
  8. data/lib/beyond_api/resources/customers.rb +333 -0
  9. data/lib/beyond_api/resources/newsletter_target.rb +1 -1
  10. data/lib/beyond_api/resources/order_settings.rb +45 -28
  11. data/lib/beyond_api/resources/orders.rb +175 -87
  12. data/lib/beyond_api/resources/payment_methods.rb +28 -25
  13. data/lib/beyond_api/resources/product_attribute_definitions.rb +3 -5
  14. data/lib/beyond_api/resources/products/attachments.rb +13 -14
  15. data/lib/beyond_api/resources/products/availability.rb +12 -10
  16. data/lib/beyond_api/resources/products/cross_sells.rb +159 -0
  17. data/lib/beyond_api/resources/products/custom_attributes.rb +7 -7
  18. data/lib/beyond_api/resources/products/images.rb +47 -8
  19. data/lib/beyond_api/resources/products/videos.rb +146 -0
  20. data/lib/beyond_api/resources/products.rb +11 -9
  21. data/lib/beyond_api/resources/products_view.rb +6 -51
  22. data/lib/beyond_api/resources/shipping_zones.rb +5 -5
  23. data/lib/beyond_api/resources/shop.rb +16 -21
  24. data/lib/beyond_api/resources/signers.rb +1 -1
  25. data/lib/beyond_api/resources/users.rb +13 -10
  26. data/lib/beyond_api/resources/variations/images.rb +160 -0
  27. data/lib/beyond_api/resources/variations.rb +40 -37
  28. data/lib/beyond_api/resources/webhook_subscriptions.rb +1 -1
  29. data/lib/beyond_api/session.rb +5 -5
  30. data/lib/beyond_api/version.rb +1 -1
  31. metadata +7 -4
  32. data/lib/beyond_api/resources/product_settings.rb +0 -28
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ module VariationImages
7
+
8
+ #
9
+ # A +POST+ request is used to create an image and add it to a variation. The URL of the image will be assigned to the variation. The image URL has to be provided in body of the request.
10
+ #
11
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/a08ca814-52e9-4e00-82a2-3e9b012e5f9d/variations/4b58cdb7-4d3d-419a-ae27-8469f8b04276/images' -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
+ # "dataUri" : "photostore-2.JPG?hash=8a627f655c68f56dfbbf217ab7d5563281225998",
17
+ # "width" : 100,
18
+ # "height" : 200
19
+ # }'
20
+ #
21
+ # @beyond_api.scopes +prod:u+
22
+ #
23
+ # @param product_id [String] the product UUID
24
+ # @param variation_id [String] the variation UUID
25
+ # @param body [Hash] the request body
26
+ #
27
+ # @return [OpenStruct]
28
+ #
29
+ # @example
30
+ # body = {
31
+ # "data_uri" => "photostore-2.JPG?hash=8a627f655c68f56dfbbf217ab7d5563281225998",
32
+ # "width" => 100,
33
+ # "height" => 200
34
+ # }
35
+ # @image = session.variations.add_image("a08ca814-52e9-4e00-82a2-3e9b012e5f9d", "4b58cdb7-4d3d-419a-ae27-8469f8b04276", body)
36
+ #
37
+ def add_image(product_id, variation_id, body)
38
+ response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variations/#{variation_id}/images", body)
39
+
40
+ handle_response(response, status)
41
+ end
42
+
43
+
44
+ #
45
+ # A +DELETE+ request is used to delete a variation image
46
+ #
47
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/8f5736f8-0a5f-4c08-bbac-3c524e2a6294/variations/86f3047c-ff29-4906-83c1-93e24ef88f3e/images/193d2ba4-3cf0-4326-a655-ef46e8a97c6a' -i -X DELETE \
48
+ # -H 'Content-Type: application/hal+json' \
49
+ # -H 'Accept: application/hal+json' \
50
+ # -H 'Authorization: Bearer <Access token>'
51
+ #
52
+ # @beyond_api.scopes +prod:u+
53
+ #
54
+ # @param product_id [String] the product UUID
55
+ # @param variation_id [String] the variation UUID
56
+ # @param image_id [String] the image UUID
57
+ #
58
+ # @return [true]
59
+ #
60
+ # @example
61
+ # session.variations.delete_image("8f5736f8-0a5f-4c08-bbac-3c524e2a6294", "86f3047c-ff29-4906-83c1-93e24ef88f3e", "193d2ba4-3cf0-4326-a655-ef46e8a97c6a")
62
+ #
63
+ def delete_image(product_id, variation_id, image_id)
64
+ response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/variations/#{variation_id}/images/#{image_id}")
65
+
66
+ handle_response(response, status, respond_with_true: true)
67
+ end
68
+
69
+ #
70
+ # A +GET+ request is used to retrieve a single image of a variation.
71
+ #
72
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/8665fc36-003e-4120-8a74-a9d6449644ae/variations/9163db42-92e7-418c-a3d8-651e7aaca569/images/86fc2691-5dfb-47e1-aae7-4bc2f658a80b' -i -X GET \
73
+ # -H 'Content-Type: application/hal+json' \
74
+ # -H 'Accept: application/hal+json' \
75
+ # -H 'Authorization: Bearer <Access token>'
76
+ #
77
+ # @beyond_api.scopes +prod:r+
78
+ #
79
+ # @param product_id [String] the product UUID
80
+ # @param variation_id [String] the variation UUID
81
+ # @param image_id [String] the image UUID
82
+ #
83
+ # @return [OpenStruct]
84
+ #
85
+ # @example
86
+ # @image = session.variations.image("8665fc36-003e-4120-8a74-a9d6449644ae", "a9163db42-92e7-418c-a3d8-651e7aaca569", "86fc2691-5dfb-47e1-aae7-4bc2f658a80b")
87
+ #
88
+ def image(product_id, image_id)
89
+ response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/variations/#{variation_id}/images/#{image_id}")
90
+
91
+ handle_response(response, status)
92
+ end
93
+
94
+ #
95
+ # A +GET+ request is used to retrieve the images of a variation.
96
+ #
97
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/b4948e53-05af-4e0b-8877-28bc8811f73e/variations/50c5bf45-5dd6-4bae-babf-813c7cdca488/images' -i -X GET \
98
+ # -H 'Content-Type: application/hal+json' \
99
+ # -H 'Accept: application/hal+json' \
100
+ # -H 'Authorization: Bearer <Access token>'
101
+ #
102
+ # @beyond_api.scopes +prod:r+
103
+ #
104
+ # @param product_id [String] the product UUID
105
+ # @param variation_id [String] the variation UUID
106
+ # @option params [Integer] :size the page size
107
+ # @option params [Integer] :page the page number
108
+ #
109
+ # @return [OpenStruct]
110
+ #
111
+ # @example
112
+ # @images = session.variations.images("b4948e53-05af-4e0b-8877-28bc8811f73e", "50c5bf45-5dd6-4bae-babf-813c7cdca488", size: 100, page: 0)
113
+ #
114
+ def images(product_id, variation_id, params = {})
115
+ response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/variations/#{variation_id}/images", params)
116
+
117
+ handle_response(response, status)
118
+ end
119
+
120
+ #
121
+ # 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.
122
+ #
123
+ # $ curl --data-binary '@/home/epages/file.png' 'https://api-shop.beyondshop.cloud/api/products/4125b993-49fc-47c8-b9b3-76d8871e4e06/variations/d7fecf94-2e57-4122-8c94-a0acd840c111/images?fileName=file.png' -X POST \
124
+ # -H 'Content-Type: image/png' \
125
+ # -H 'Authorization: Bearer <Access token>'
126
+ #
127
+ # @beyond_api.scopes +prod:u+
128
+ #
129
+ # @param product_id [String] the product UUID
130
+ # @param variation_id [String] the variation UUID
131
+ # @param image_path [String] the image path
132
+ # @param image_name [String] the image name
133
+ #
134
+ # @return [OpenStruct]
135
+ #
136
+ # @example
137
+ # body = {
138
+ # "type" => "VIMEO",
139
+ # "source" => "https://vimeo.com/7265982"
140
+ # }
141
+ #
142
+ # session.variation.upload_image("4125b993-49fc-47c8-b9b3-76d8871e4e06", "d7fecf94-2e57-4122-8c94-a0acd840c111", "/home/epages/file.png", "file.png")
143
+ #
144
+ def upload_image(product_id, variation_id, image_path, image_name)
145
+ content_type = case File.extname(image_path)
146
+ when ".png"
147
+ "image/png"
148
+ when ".jpg", ".jpeg"
149
+ "image/jpeg"
150
+ when ".gif"
151
+ "image/gif"
152
+ end
153
+ image_binary = File.binread(image_path)
154
+
155
+ response, status = BeyondApi::Request.upload(@session, "/products/#{product_id}/variations/#{variation_id}/images", image_binary, content_type, { file_name: image_name })
156
+
157
+ handle_response(response, status, respond_with_true: true)
158
+ end
159
+ end
160
+ end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "beyond_api/utils"
4
+ require "beyond_api/resources/variations/images"
4
5
  require "beyond_api/resources/variations/availability"
5
6
 
6
7
  module BeyondApi
7
8
  class Variations < Base
9
+ include BeyondApi::VariationImages
8
10
  include BeyondApi::VariationAvailability
9
11
  include BeyondApi::Utils
10
12
 
@@ -23,7 +25,7 @@ module BeyondApi
23
25
  # @return [OpenStruct]
24
26
  #
25
27
  # @example
26
- # @products = session.variations.all(size: 100, page: 0)
28
+ # @variations = session.variations.all("dc1b5caf-51ea-4fcd-b1ba-0c5128e91d17", { size: 100, page: 0 })
27
29
  #
28
30
  def all(product_id, params = {})
29
31
  response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/variations", params)
@@ -47,7 +49,7 @@ module BeyondApi
47
49
  # @return [OpenStruct]
48
50
  #
49
51
  # @example
50
- # @product = session.variations.find("f461fb56-1984-4ade-bd4e-007c273cc923", "f6e5bb16-af2e-440f-acd3-a883ad3c1922")
52
+ # @variation = session.variations.find("5f6e426e-c8d9-48ba-9b37-9a8eb6381373", "f6e5bb16-af2e-440f-acd3-a883ad3c1922")
51
53
  #
52
54
  def find(product_id, variation_id)
53
55
  response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/variations/#{variation_id}")
@@ -63,36 +65,36 @@ module BeyondApi
63
65
  # -H 'Accept: application/hal+json' \
64
66
  # -H 'Authorization: Bearer <Access token>' \
65
67
  # -d '{
66
- # "salesPrice" : {
67
- # "taxModel" : "NET",
68
- # "amount" : 8.7,
69
- # "currency" : "EUR"
70
- # },
71
- # "listPrice" : {
72
- # "taxModel" : "NET",
73
- # "amount" : 10.95,
74
- # "currency" : "EUR"
75
- # },
76
- # "manufacturerPrice" : {
77
- # "taxModel" : "NET",
78
- # "amount" : 99.95,
79
- # "currency" : "EUR"
80
- # },
81
- # "refPrice" : {
82
- # "refQuantity" : 1,
83
- # "unit" : "LITER",
84
- # "quantity" : 0.75,
85
- # "price" : {
68
+ # "salesPrice" : {
86
69
  # "taxModel" : "NET",
87
- # "amount" : 11.6,
70
+ # "amount" : 8.7,
88
71
  # "currency" : "EUR"
89
- # }
90
- # },
91
- # "sku" : "my-new-sku",
92
- # "productIdentifiers" : [ {
93
- # "type" : "EAN",
94
- # "value" : "9780134308135"
95
- # } ]
72
+ # },
73
+ # "listPrice" : {
74
+ # "taxModel" : "NET",
75
+ # "amount" : 10.95,
76
+ # "currency" : "EUR"
77
+ # },
78
+ # "manufacturerPrice" : {
79
+ # "taxModel" : "NET",
80
+ # "amount" : 99.95,
81
+ # "currency" : "EUR"
82
+ # },
83
+ # "refPrice" : {
84
+ # "refQuantity" : 1,
85
+ # "unit" : "LITER",
86
+ # "quantity" : 0.75,
87
+ # "price" : {
88
+ # "taxModel" : "NET",
89
+ # "amount" : 11.6,
90
+ # "currency" : "EUR"
91
+ # }
92
+ # },
93
+ # "sku" : "my-new-sku",
94
+ # "productIdentifiers" : [ {
95
+ # "type" : "EAN",
96
+ # "value" : "9780134308135"
97
+ # } ]
96
98
  # }'
97
99
  #
98
100
  # @beyond_api.scopes +prod:u+
@@ -105,22 +107,22 @@ module BeyondApi
105
107
  #
106
108
  # @example
107
109
  # body = {
108
- # "salesPrice": {
110
+ # "sales_price" => {
109
111
  # "taxModel": "NET",
110
112
  # "amount": 8.7,
111
113
  # "currency": "EUR"
112
114
  # },
113
- # "listPrice": {
115
+ # "list_price" => {
114
116
  # "taxModel": "NET",
115
117
  # "amount": 10.95,
116
118
  # "currency": "EUR"
117
119
  # },
118
- # "manufacturerPrice": {
120
+ # "manufacturer_price" => {
119
121
  # "taxModel": "NET",
120
122
  # "amount": 99.95,
121
123
  # "currency": "EUR"
122
124
  # },
123
- # "refPrice": {
125
+ # "ref_price" => {
124
126
  # "refQuantity": 1,
125
127
  # "unit": "LITER",
126
128
  # "quantity": 0.75,
@@ -130,13 +132,14 @@ module BeyondApi
130
132
  # "currency": "EUR"
131
133
  # }
132
134
  # },
133
- # "sku": "my-new-sku",
134
- # "productIdentifiers": [{
135
+ # "sku" => "my-new-sku",
136
+ # "product_identifiers" => [{
135
137
  # "type": "EAN",
136
138
  # "value": "9780134308135"
137
139
  # }]
138
140
  # }
139
- # @product = session.variations.update("f461fb56-1984-4ade-bd4e-007c273cc923", "f6e5bb16-af2e-440f-acd3-a883ad3c1922", body)
141
+ #
142
+ # @variation = session.variations.update("7cf4b5b1-b141-4869-96d1-4eaee8bf7563", "9f93fdd0-2d21-4ea9-b9d7-e9a53edb091b", body)
140
143
  #
141
144
  def update(product_id, variation_id, body)
142
145
  response, status = BeyondApi::Request.patch(@session, "/products/#{product_id}/variations/#{variation_id}", body)
@@ -110,7 +110,7 @@ module BeyondApi
110
110
  # @return true
111
111
  #
112
112
  # @example
113
- # webhook_subscriptions = session.webhook_subscriptions.delete("c6076a5a-a8ad-443f-b20b-8a1b268b069e")
113
+ # session.webhook_subscriptions.delete("c6076a5a-a8ad-443f-b20b-8a1b268b069e")
114
114
  #
115
115
  def delete(webhook_subscription_id)
116
116
  response, status = BeyondApi::Request.delete(@session, "/webhook-subscriptions/#{webhook_subscription_id}")
@@ -5,12 +5,12 @@ require "beyond_api/resources/carts"
5
5
  require "beyond_api/resources/categories_view"
6
6
  require "beyond_api/resources/categories"
7
7
  require "beyond_api/resources/checkout_settings"
8
+ require "beyond_api/resources/customers"
8
9
  require "beyond_api/resources/newsletter_target"
9
10
  require "beyond_api/resources/order_settings"
10
11
  require "beyond_api/resources/orders"
11
12
  require "beyond_api/resources/payment_methods"
12
13
  require "beyond_api/resources/product_attribute_definitions"
13
- require "beyond_api/resources/product_settings"
14
14
  require "beyond_api/resources/products_view"
15
15
  require "beyond_api/resources/products"
16
16
  require "beyond_api/resources/scopes"
@@ -50,6 +50,10 @@ module BeyondApi
50
50
  BeyondApi::CheckoutSettings.new(self)
51
51
  end
52
52
 
53
+ def customers
54
+ BeyondApi::Customers.new(self)
55
+ end
56
+
53
57
  def newsletter_target
54
58
  BeyondApi::NewsletterTarget.new(self)
55
59
  end
@@ -70,10 +74,6 @@ module BeyondApi
70
74
  BeyondApi::ProductAttributeDefinitions.new(self)
71
75
  end
72
76
 
73
- def product_settings
74
- BeyondApi::ProductSettings.new(self)
75
- end
76
-
77
77
  def products_view
78
78
  BeyondApi::ProductsView.new(self)
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module BeyondApi
2
- VERSION = "0.5.1.pre".freeze
2
+ VERSION = "0.6.0.pre".freeze
3
3
  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.5.1.pre
4
+ version: 0.6.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: 2019-12-03 00:00:00.000000000 Z
13
+ date: 2020-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -140,19 +140,21 @@ files:
140
140
  - lib/beyond_api/resources/categories.rb
141
141
  - lib/beyond_api/resources/categories_view.rb
142
142
  - lib/beyond_api/resources/checkout_settings.rb
143
+ - lib/beyond_api/resources/customers.rb
143
144
  - lib/beyond_api/resources/newsletter_target.rb
144
145
  - lib/beyond_api/resources/order_settings.rb
145
146
  - lib/beyond_api/resources/orders.rb
146
147
  - lib/beyond_api/resources/payment_methods.rb
147
148
  - lib/beyond_api/resources/product_attribute_definitions.rb
148
- - lib/beyond_api/resources/product_settings.rb
149
149
  - lib/beyond_api/resources/products.rb
150
150
  - lib/beyond_api/resources/products/attachments.rb
151
151
  - lib/beyond_api/resources/products/availability.rb
152
+ - lib/beyond_api/resources/products/cross_sells.rb
152
153
  - lib/beyond_api/resources/products/custom_attributes.rb
153
154
  - lib/beyond_api/resources/products/images.rb
154
155
  - lib/beyond_api/resources/products/searches.rb
155
156
  - lib/beyond_api/resources/products/variation_properties.rb
157
+ - lib/beyond_api/resources/products/videos.rb
156
158
  - lib/beyond_api/resources/products_view.rb
157
159
  - lib/beyond_api/resources/scopes.rb
158
160
  - lib/beyond_api/resources/script_tags.rb
@@ -163,6 +165,7 @@ files:
163
165
  - lib/beyond_api/resources/users.rb
164
166
  - lib/beyond_api/resources/variations.rb
165
167
  - lib/beyond_api/resources/variations/availability.rb
168
+ - lib/beyond_api/resources/variations/images.rb
166
169
  - lib/beyond_api/resources/webhook_subscriptions.rb
167
170
  - lib/beyond_api/session.rb
168
171
  - lib/beyond_api/utils.rb
@@ -187,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
190
  - !ruby/object:Gem::Version
188
191
  version: 1.3.1
189
192
  requirements: []
190
- rubygems_version: 3.0.1
193
+ rubygems_version: 3.0.3
191
194
  signing_key:
192
195
  specification_version: 4
193
196
  summary: Ruby client to access the Beyond API
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "beyond_api/utils"
4
-
5
- module BeyondApi
6
- class ProductSettings < Base
7
- include BeyondApi::Utils
8
-
9
- #
10
- # A +GET+ request is used to retrieve the product settings.
11
- #
12
- # $ curl 'https://api-shop.beyondshop.cloud/api/product-settings' -i -X GET \
13
- # -H 'Authorization: Bearer <Access token>'
14
- #
15
- # @beyond_api.scopes +prst:r+
16
- #
17
- # @return [OpenStruct]
18
- #
19
- # @example
20
- # @product_settings = session.product_settings.all
21
- #
22
- def all
23
- response, status = BeyondApi::Request.get(@session, "/product_settings")
24
-
25
- handle_response(response, status)
26
- end
27
- end
28
- end