beyond_api 0.1.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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +1 -0
  6. data/CHANGELOG.md +4 -0
  7. data/CONTRIBUTING.md +48 -0
  8. data/GETTING_STARTED.md +0 -0
  9. data/Gemfile +6 -0
  10. data/Gemfile.lock +55 -0
  11. data/LICENSE +19 -0
  12. data/README.md +51 -0
  13. data/Rakefile +11 -0
  14. data/beyond_api.gemspec +31 -0
  15. data/bin/console +18 -0
  16. data/bin/setup +8 -0
  17. data/lib/beyond_api.rb +37 -0
  18. data/lib/beyond_api/connection.rb +30 -0
  19. data/lib/beyond_api/ext.rb +43 -0
  20. data/lib/beyond_api/request.rb +55 -0
  21. data/lib/beyond_api/resources/base.rb +17 -0
  22. data/lib/beyond_api/resources/carts.rb +547 -0
  23. data/lib/beyond_api/resources/categories.rb +168 -0
  24. data/lib/beyond_api/resources/categories_view.rb +142 -0
  25. data/lib/beyond_api/resources/checkout_settings.rb +48 -0
  26. data/lib/beyond_api/resources/newsletter_target.rb +97 -0
  27. data/lib/beyond_api/resources/order_settings.rb +80 -0
  28. data/lib/beyond_api/resources/orders.rb +968 -0
  29. data/lib/beyond_api/resources/payment_methods.rb +192 -0
  30. data/lib/beyond_api/resources/product_attribute_definitions.rb +109 -0
  31. data/lib/beyond_api/resources/product_settings.rb +28 -0
  32. data/lib/beyond_api/resources/products.rb +245 -0
  33. data/lib/beyond_api/resources/products/attachments.rb +119 -0
  34. data/lib/beyond_api/resources/products/availability.rb +177 -0
  35. data/lib/beyond_api/resources/products/custom_attributes.rb +141 -0
  36. data/lib/beyond_api/resources/products/images.rb +165 -0
  37. data/lib/beyond_api/resources/products/searches.rb +52 -0
  38. data/lib/beyond_api/resources/products/variation_properties.rb +87 -0
  39. data/lib/beyond_api/resources/products_view.rb +158 -0
  40. data/lib/beyond_api/resources/scopes.rb +31 -0
  41. data/lib/beyond_api/resources/script_tags.rb +122 -0
  42. data/lib/beyond_api/resources/shipping_zones.rb +324 -0
  43. data/lib/beyond_api/resources/shop.rb +561 -0
  44. data/lib/beyond_api/resources/signers.rb +63 -0
  45. data/lib/beyond_api/resources/token.rb +41 -0
  46. data/lib/beyond_api/resources/users.rb +376 -0
  47. data/lib/beyond_api/resources/variations.rb +145 -0
  48. data/lib/beyond_api/resources/variations/availability.rb +105 -0
  49. data/lib/beyond_api/resources/webhook_subscriptions.rb +176 -0
  50. data/lib/beyond_api/session.rb +121 -0
  51. data/lib/beyond_api/utils.rb +51 -0
  52. data/lib/beyond_api/version.rb +3 -0
  53. data/lib/generators/beyond_api/install_generator.rb +13 -0
  54. data/lib/generators/templates/beyond_api_initializer.rb +29 -0
  55. metadata +194 -0
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class Categories < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +GET+ request is used to list all available categories in a paged manner.
11
+ #
12
+ # $ curl 'https://api-shop.beyondshop.cloud/api/categories' -i -X GET \
13
+ # -H 'Content-Type: application/json' \
14
+ # -H 'Accept: application/hal+json' \
15
+ # -H 'Authorization: Bearer <Access token>'
16
+ #
17
+ # @beyond_api.scopes +catg:r+
18
+ #
19
+ # @option params [Integer] :size the page size
20
+ # @option params [Integer] :page the page number
21
+ #
22
+ # @return [OpenStruct]
23
+ #
24
+ # @example
25
+ # @categories = session.categories.all(size: 100, page: 0)
26
+ #
27
+ def all(params = {})
28
+ response, status = BeyondApi::Request.get(@session, "/categories", params)
29
+
30
+ handle_response(response, status)
31
+ end
32
+
33
+ #
34
+ # A +POST+ request is used to create a category.
35
+ #
36
+ # $ curl 'https://api-shop.beyondshop.cloud/api/categories' -i -X POST \
37
+ # -H 'Content-Type: application/json' \
38
+ # -H 'Authorization: Bearer <Access token>' \
39
+ # -d '{"name":"Power Bars","label":"power-bar","type":"SMART","query":{"bool":{"filter":{"term":{"tags":"power-bar"}}}}}'
40
+ #
41
+ # @beyond_api.scopes +catg:c+
42
+ #
43
+ # @param body [Hash] the request body
44
+ #
45
+ # @return [OpenStruct]
46
+ #
47
+ # @example
48
+ # body = {
49
+ # "name" => "Power Bars",
50
+ # "label" => "power-bar",
51
+ # "type" => "SMART",
52
+ # "query" => { "bool" => { "filter" => { "term" : { "tags" => "power-bar" } } } }
53
+ # }
54
+ # @category = session.categories.create(body)
55
+ #
56
+ def create(body)
57
+ response, status = BeyondApi::Request.post(@session, "/categories", body)
58
+
59
+ handle_response(response, status)
60
+ end
61
+
62
+ #
63
+ # A +DELETE+ request is used to delete a category.
64
+ #
65
+ # $ curl 'https://api-shop.beyondshop.cloud/api/categories/f461fb56-1984-4ade-bd4e-007c273cc923' -i -X DELETE \
66
+ # -H 'Accept: application/hal+json' \
67
+ # -H 'Authorization: Bearer <Access token>'
68
+ #
69
+ # @beyond_api.scopes +catg:d+
70
+ #
71
+ # @param category_id [String] the category UUID
72
+ #
73
+ # @return true
74
+ #
75
+ # @example
76
+ # session.categories.delete("f461fb56-1984-4ade-bd4e-007c273cc923")
77
+ #
78
+ def delete(category_id)
79
+ response, status = BeyondApi::Request.delete(@session, "/categories/#{category_id}")
80
+
81
+ handle_response(response, status, respond_with_true: true)
82
+ end
83
+
84
+ #
85
+ # A +GET+ request is used to retrieve the details of a category.
86
+ #
87
+ # $ curl 'https://api-shop.beyondshop.cloud/api/categories/27a94b71-9b17-4f06-9596-fbbf4d18021f' -i -X GET \
88
+ # -H 'Content-Type: application/json' \
89
+ # -H 'Accept: application/hal+json' \
90
+ # -H 'Authorization: Bearer <Access token>'
91
+ #
92
+ # @beyond_api.scopes +catg:r+
93
+ #
94
+ # @param category_id [String] the category UUID
95
+ #
96
+ # @return [OpenStruct]
97
+ #
98
+ # @example
99
+ # @category = session.categories.find(category_id)
100
+ #
101
+ def find(category_id)
102
+ response, status = BeyondApi::Request.get(@session, "/categories/#{category_id}")
103
+
104
+ handle_response(response, status)
105
+ end
106
+
107
+ #
108
+ # A +PATCH+ request is used to update a category partially with json patch content type.
109
+ #
110
+ # $ curl 'https://api-shop.beyondshop.cloud/api/categories/49250b7a-79a8-48d0-a71c-fc417965928d' -i -X PATCH \
111
+ # -H 'Content-Type: application/json-patch+json' \
112
+ # -H 'Accept: application/hal+json' \
113
+ # -H 'Authorization: Bearer <Access token>' \
114
+ # -d '{"name":"patched name","type":"MANUAL","query":{"bool":{"filter":[{"terms":{"id":["6c449297-65fc-41aa-a49c-68a3561b33e5","6c449297-65fc-41aa-a49c-68a3561b33e6"]}}]}}}'
115
+ #
116
+ # @beyond_api.scopes +catg:u+
117
+ #
118
+ # @param category_id [String] the category UUID
119
+ # @param body [Hash] the request body
120
+ #
121
+ # @return [OpenStruct]
122
+ #
123
+ # @example
124
+ # body = {
125
+ # "name" => "patched name",
126
+ # "type" => "MANUAL",
127
+ # "query" => {"bool" => { "filter" => [ { "terms" => { "id" => [ "6c449297-65fc-41aa-a49c-68a3561b33e5", "6c449297-65fc-41aa-a49c-68a3561b33e6" ] } } ] } }
128
+ # }
129
+ # @category = session.categories.update("49250b7a-79a8-48d0-a71c-fc417965928d", body)
130
+ #
131
+ def patch(category_id, body)
132
+ response, status = BeyondApi::Request.patch(@session, "/categories/#{category_id}", body)
133
+
134
+ handle_response(response, status)
135
+ end
136
+
137
+ #
138
+ # A PUT request is issued to update all category properties with application/json content type.
139
+ #
140
+ # $ curl 'https://api-shop.beyondshop.cloud/api/categories/cb2058dc-871a-4e64-83ac-39a0be9e6f82' -i -X PUT \
141
+ # -H 'Content-Type: application/json' \
142
+ # -H 'Accept: application/hal+json' \
143
+ # -H 'Authorization: Bearer <Access token>' \
144
+ # -d '{"name":"updated name","label":"updated-name","type":"MANUAL","query":{"bool":{"filter":[{"terms":{"id":["6c449297-65fc-41aa-a49c-68a3561b33e5","6c449297-65fc-41aa-a49c-68a3561b33e6"]}}]}}}'
145
+ #
146
+ # @beyond_api.scopes +catg:u+
147
+ #
148
+ # @param category_id [String] the category UUID
149
+ # @param body [Hash] the request body
150
+ #
151
+ # @return [OpenStruct]
152
+ #
153
+ # @example
154
+ # body = {
155
+ # "name" => "updated name",
156
+ # "label" => "updated-name",
157
+ # "type" => "MANUAL",
158
+ # "query" => { "bool" => { "filter" => [ { "terms" => { "id" => [ "6c449297-65fc-41aa-a49c-68a3561b33e5", "6c449297-65fc-41aa-a49c-68a3561b33e6" ] } } ] } }
159
+ # }
160
+ # @category = session.categories.update(category_id, body)
161
+ #
162
+ def update(category_id, body)
163
+ response, status = BeyondApi::Request.put(@session, "/categories/#{category_id}", body)
164
+
165
+ handle_response(response, status)
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class CategoriesView < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +GET+ request is used to list all product categories.
11
+ #
12
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories' -i -X GET \
13
+ # -H 'Content-Type: application/json' \
14
+ # -H 'Accept: application/hal+json'
15
+ #
16
+ #
17
+ # @option params [Integer] :size the page size
18
+ # @option params [Integer] :page the page number
19
+ #
20
+ # @return [OpenStruct]
21
+ #
22
+ # @example
23
+ # @categories = session.categories_view.all(size: 100, page: 0)
24
+ #
25
+ def all(params = {})
26
+ response, status = BeyondApi::Request.get(@session, "/product-view/categories", params)
27
+
28
+ handle_response(response, status)
29
+ end
30
+
31
+ #
32
+ # A +GET+ request is used to retrieve the details of a product category.
33
+ #
34
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/23bb1430-6e82-40e4-9a92-4cb404da74a8' -i -X GET \
35
+ # -H 'Content-Type: application/json' \
36
+ # -H 'Accept: application/hal+json'
37
+ #
38
+ # @param category_id [String] the category UUID
39
+ #
40
+ # @return [OpenStruct]
41
+ #
42
+ # @example
43
+ # @category = session.categories_view.find("23bb1430-6e82-40e4-9a92-4cb404da74a8")
44
+ #
45
+ def find(category_id)
46
+ response, status = BeyondApi::Request.get(@session, "/product-view/categories/#{category_id}")
47
+
48
+ handle_response(response, status)
49
+ end
50
+
51
+ #
52
+ # A +GET+ request is used to list all products of a category.
53
+ #
54
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/681beef2-cd3e-4ce3-8034-4d07c1184447/products' -i -X GET \
55
+ # -H 'Content-Type: application/json' \
56
+ # -H 'Accept: application/hal+json'
57
+ #
58
+ # @param category_id [String] the category UUID
59
+ # @option params [Integer] :size the page size
60
+ # @option params [Integer] :page the page number
61
+ #
62
+ # @return [OpenStruct]
63
+ #
64
+ # @example
65
+ # @products = session.categories_view.products("681beef2-cd3e-4ce3-8034-4d07c1184447", { size: 100, page: 0 })
66
+ #
67
+ def products(category_id, params = {})
68
+ response, status = BeyondApi::Request.get(@session, "/product-view/categories/#{category_id}/products", params)
69
+
70
+ handle_response(response, status)
71
+ end
72
+
73
+ #
74
+ # A +GET+ request is used to find a product category by its unique label.
75
+ #
76
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/search/find-by-label?label=power-bar' -i -X GET \
77
+ # -H 'Content-Type: application/json' \
78
+ # -H 'Accept: application/hal+json'
79
+ #
80
+ # @param label [String] the label of the category
81
+ #
82
+ # @return [OpenStruct]
83
+ #
84
+ # @example
85
+ # @category = session.categories_view.search_by_label("power-bar")
86
+ #
87
+ def search_by_label(label)
88
+ response, status = BeyondApi::Request.get(@session, "/product-view/categories/search/find-by-label", { label: label })
89
+
90
+ handle_response(response, status)
91
+ end
92
+
93
+ #
94
+ # A +GET+ request is used to list all product categories a product is part of using the request parameter productId.
95
+ #
96
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/search/find-by-product?productId=ba68427f-603c-4741-9185-3b379f7769b5' -i -X GET \
97
+ # -H 'Content-Type: application/json' \
98
+ # -H 'Accept: application/hal+json'
99
+ #
100
+ # @param product_id [String] the product UUID of the category
101
+ #
102
+ # @return [OpenStruct]
103
+ #
104
+ # @example
105
+ # @category = session.categories_view.search_by_product_id("ba68427f-603c-4741-9185-3b379f7769b5")
106
+ #
107
+ def search_by_product_id(product_id, params = {})
108
+ response, status = BeyondApi::Request.get(@session, "/product-view/categories/search/find-by-product", params.merge(product_id: product_id))
109
+
110
+ handle_response(response, status)
111
+ end
112
+
113
+ #
114
+ # A +POST+ request is used to search for categories a new product will be part of using the request body. An existing product can also be part of the call. This endpoint can handle all properties a product can have.
115
+ # This request is read-only and cannot create data.
116
+ #
117
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/search/find-by-product' -i -X POST \
118
+ # -H 'Content-Type: application/json' \
119
+ # -H 'Accept: application/hal+json'
120
+ # -d '{
121
+ # "tags" : [ "books" ],
122
+ # "manufacturer" : "The Standard Manufacturer",
123
+ # "salesPrice" : {
124
+ # "amount" : 10.0,
125
+ # "currency" : "EUR"
126
+ # }
127
+ # }'
128
+ #
129
+ # @param product_id [String] the product UUID of the category
130
+ #
131
+ # @return [OpenStruct]
132
+ #
133
+ # @example
134
+ # @category = session.categories_view.search_by_product_id("ba68427f-603c-4741-9185-3b379f7769b5")
135
+ #
136
+ def search_by_product(body, params = {})
137
+ response, status = BeyondApi::Request.post(@session, "/product-view/categories/search/find-by-product", body, params)
138
+
139
+ handle_response(response, status = {})
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class CheckoutSettings < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +GET+ request is used to retrieve the checkout settings.
11
+ #
12
+ # $ curl 'https://api-shop.beyondshop.cloud/api/checkout-settings' -i -X GET \
13
+ # -H 'Accept: application/hal+json' \
14
+ # -H 'Authorization: Bearer <Access token>'
15
+ #
16
+ # @beyond_api.scopes +cset:r+
17
+ #
18
+ # @return [OpenStruct]
19
+ #
20
+ # @example
21
+ # @checkout_settiongs = session.checkout_settings.all
22
+ #
23
+ def all
24
+ response, status = BeyondApi::Request.get(@session, "/checkout-settings")
25
+
26
+ handle_response(response, status)
27
+ end
28
+
29
+ # A +PUT+ request is used to update the checkout settings.
30
+ #
31
+ # $ curl 'https://api-shop.beyondshop.cloud/api/checkout-settings' -i -X PUT \
32
+ # -H 'Content-Type: application/json' \
33
+ # -H 'Accept: application/hal+json' \
34
+ # -H 'Authorization: Bearer <Access token>' \
35
+ # -d ' {
36
+ # "minimumOrderValue" : {
37
+ # "currency" : "EUR",
38
+ # "amount" : 50
39
+ # },
40
+ # "mustAcceptTermsAndConditions" : true
41
+ # }'
42
+ def update(body)
43
+ response, status = BeyondApi::Request.put(@session, "/checkout-settings", body)
44
+
45
+ handle_response(response, status)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class NewsletterTarget < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +POST+ request is used to create the newsletter target. Each shop can only have one newsletter target.
11
+ # You can update this target at any time, or delete the existing one and create a new target.
12
+ #
13
+ # $ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X POST \
14
+ # -H 'Content-Type: application/json' \
15
+ # -H 'Accept: application/hal+json' \
16
+ # -H 'Authorization: Bearer <Access token>' \
17
+ # -d '{
18
+ # "submitUrl": "https://example.org/cgi-bin/subscribe.php"
19
+ # }'
20
+ #
21
+ # @beyond_api.scopes +nltg:m+
22
+ #
23
+ # @param submit_url [String] the URL stating where to submit the newsletter
24
+ #
25
+ # @return [OpenStruct]
26
+ #
27
+ # @example
28
+ # session.newsletter_target.create({ submit_url: "https://example.org/cgi-bin/subscribe.php" })
29
+ #
30
+ def create(submit_url)
31
+ response, status = BeyondApi::Request.post(@session, "/newsletter-target", { submit_url: submit_url})
32
+
33
+ handle_response(response, status)
34
+ end
35
+
36
+ #
37
+ # A +DELETE+ request is used to delete the existing newsletter target.
38
+ #
39
+ # $ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X DELETE \
40
+ # -H 'Authorization: Bearer <Access token>'
41
+ #
42
+ # @beyond_api.scopes +nltg:m+
43
+ #
44
+ # @return true
45
+ #
46
+ # @example
47
+ # session.newsletter_target.delete
48
+ #
49
+ def delete
50
+ response, status = BeyondApi::Request.delete(@session, "/newsletter-target")
51
+
52
+ handle_response(response, status, respond_with_true: true)
53
+ end
54
+
55
+ #
56
+ # A +GET+ request is used to retrieve the newsletter target.
57
+ #
58
+ # $ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X GET
59
+ #
60
+ # @return [OpenStruct]
61
+ #
62
+ # @example
63
+ # session.newsletter_target.find
64
+ #
65
+ def find
66
+ response, status = BeyondApi::Request.get(@session, "/newsletter-target")
67
+
68
+ handle_response(response, status)
69
+ end
70
+
71
+ #
72
+ # A +PUT+ request is used to update the existing newsletter target
73
+ #
74
+ # $ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X PUT \
75
+ # -H 'Content-Type: application/json' \
76
+ # -H 'Accept: application/hal+json' \
77
+ # -H 'Authorization: Bearer <Access token>' \
78
+ # -d '{
79
+ # "submitUrl": "https://example.org/api/newsletter/subscription"
80
+ # }'
81
+ #
82
+ # @beyond_api.scopes +nltg:m+
83
+ #
84
+ # @param submit_url [String] the URL stating where to submit the newsletter
85
+ #
86
+ # @return [OpenStruct]
87
+ #
88
+ # @example
89
+ # session.newsletter_target.update({ submit_url: "https://example.org/cgi-bin/subscribe.php" })
90
+ #
91
+ def update(submit_url)
92
+ response, status = BeyondApi::Request.put(@session, "/newsletter-target", { submit_url: submit_url })
93
+
94
+ handle_response(response, status)
95
+ end
96
+ end
97
+ end