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,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ module ProductSearches
7
+
8
+ #
9
+ # A +GET+ request is used to search for a product by SKU.
10
+ #
11
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/search/find-by-sku?sku=vino020' -i -X GET \
12
+ # -H 'Authorization: Bearer <Access token>'
13
+ #
14
+ # @beyond_api.scopes +prod:r+
15
+ #
16
+ # @param sku [String] the product sku to search
17
+ #
18
+ # @return [OpenStruct]
19
+ #
20
+ # @example
21
+ # @product = session.product.search_by_sku("vino020")
22
+ #
23
+ def search_by_sku(sku)
24
+ response, status = BeyondApi::Request.get(@session, "/products/search/find-by-sku", sku: sku)
25
+
26
+ handle_response(response, status)
27
+ end
28
+
29
+ #
30
+ # A +GET+ request is used to search used tags by a starting string. All strings are sorted by usage, starting with the biggest.
31
+ #
32
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/search/tags?startsWith=aw' -i -X GET \
33
+ # -H 'Authorization: Bearer <Access token>'
34
+ #
35
+ # @beyond_api.scopes +prod:r+
36
+ #
37
+ # @param starts_with [String] the tag start to search
38
+ # @option param [Integer] :size the page size
39
+ # @option param [Integer] :page the page numbe
40
+ #
41
+ # @return [OpenStruct]
42
+ #
43
+ # @example
44
+ # @tags = session.product.search_tags_starting_by("aw")
45
+ #
46
+ def search_tags_starting_by(starts_with, params = {})
47
+ response, status = BeyondApi::Request.get(@session, "/products/search/tags", params.merge(starts_with: starts_with))
48
+
49
+ handle_response(response, status)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ module ProductVariationProperties
7
+
8
+ #
9
+ # A +PATCH+ request is used to update the variation properties of a variation product.
10
+ #
11
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/51953b86-7ccc-4e80-acbd-1a2fc921fc2e/variation-properties' -i -X PATCH \
12
+ # -H 'Content-Type: application/hal+json' \
13
+ # -H 'Accept: application/hal+json' \
14
+ # -H 'Authorization: Bearer <Access token>' \
15
+ # -d '[ {
16
+ # "property" : "salesPrice",
17
+ # "enabled" : true
18
+ # }, {
19
+ # "property" : "listPrice",
20
+ # "enabled" : true
21
+ # }, {
22
+ # "property" : "refPrice",
23
+ # "enabled" : true
24
+ # }, {
25
+ # "property" : "manufacturerPrice",
26
+ # "enabled" : true
27
+ # }, {
28
+ # "property" : "productIdentifiers",
29
+ # "enabled" : true
30
+ # } ]'
31
+ #
32
+ # @beyond_api.scopes +prod:r+
33
+ #
34
+ # @param product_id [String] the product UUID
35
+ # @param body [Array<Hash>] the request body
36
+ #
37
+ # @return [OpenStruct]
38
+ #
39
+ # @example
40
+ # body = [{
41
+ # "property": "salesPrice",
42
+ # "enabled": true
43
+ # }, {
44
+ # "property": "listPrice",
45
+ # "enabled": true
46
+ # }, {
47
+ # "property": "refPrice",
48
+ # "enabled": true
49
+ # }, {
50
+ # "property": "manufacturerPrice",
51
+ # "enabled": true
52
+ # }, {
53
+ # "property": "productIdentifiers",
54
+ # "enabled": true
55
+ # }]
56
+ #
57
+ # @variation_properties = session.products.update_variation_properties("7f32696a-df56-4380-a91b-fffb97f025b4", body)
58
+ #
59
+ def update_variation_properties(product_id, body)
60
+ response, status = BeyondApi::Request.patch(@session, "/products/#{product_id}/variation-properties", body)
61
+
62
+ handle_response(response, status)
63
+ end
64
+
65
+ #
66
+ # A +GET+ request is used to retrieve the variation properties of a variation product.
67
+ #
68
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/ea81446c-8fec-418c-8b3c-6e43fdee713a/variation-properties' -i -X GET \
69
+ # -H 'Accept: application/hal+json' \
70
+ # -H 'Authorization: Bearer <Access token>'
71
+ #
72
+ # @beyond_api.scopes +prod:r+
73
+ #
74
+ # @param product_id [String] the product UUID
75
+ #
76
+ # @return [OpenStruct]
77
+ #
78
+ # @example
79
+ # @variation_properties = session.products.variation_properties("7f32696a-df56-4380-a91b-fffb97f025b4")
80
+ #
81
+ def variation_properties(product_id)
82
+ response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/variation-properties")
83
+
84
+ handle_response(response, status)
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,158 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class ProductsView < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +GET+ request is used to list all products.
11
+ #
12
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products' -i -X GET \
13
+ # -H 'Content-Type: application/json' \
14
+ # -H 'Accept: application/hal+json'
15
+ #
16
+ # @option params [Integer] :size the page size
17
+ # @option params [Integer] :page the page number
18
+ #
19
+ # @return [OpenStruct]
20
+ #
21
+ # @example
22
+ # @products = session.product_view_products.all(page: 0, size: 100)
23
+ #
24
+ def all(params = {})
25
+ response, status = BeyondApi::Request.get(@session, "/product-view/products")
26
+
27
+ handle_response(response, status)
28
+ end
29
+
30
+ #
31
+ # A +GET+ request is used to list all available tags.
32
+ #
33
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-available-tags' -i -X GET \
34
+ # -H 'Content-Type: application/json' \
35
+ # -H 'Accept: application/hal+json'
36
+ #
37
+ # @return [OpenStruct]
38
+ #
39
+ # @example
40
+ # @tags = session.product_view_products.available_tags
41
+ #
42
+ def available_tags
43
+ response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-available-tags")
44
+
45
+ handle_response(response, status)
46
+ end
47
+
48
+ #
49
+ # TODO: To be documented.
50
+ # NOTE: 10.4 10.5 and 10.6 are the same call with different response.
51
+ #
52
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/f75f8fb2-5a48-4d94-aad6-3d3692c06472' -i -X GET \
53
+ # -H 'Content-Type: application/json' \
54
+ # -H 'Accept: application/hal+json'
55
+ #
56
+ # @param product_id [String] the product UUID
57
+ #
58
+ # @return [OpenStruct]
59
+ #
60
+ # @example
61
+ # @product = session.product_view_products.find("e3e86c45-de19-4179-87a4-f5f7756a0294")
62
+ #
63
+ def find(product_id)
64
+ response, status = BeyondApi::Request.get(@session, "/product-view/products/#{product_id}")
65
+
66
+ handle_response(response, status)
67
+ end
68
+
69
+ #
70
+ # A +POST+ request is used to search for products using a query provided as request body.
71
+ #
72
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-by-query' -i -X POST \
73
+ # -H 'Content-Type: application/json' \
74
+ # -H 'Accept: application/hal+json' \
75
+ # -d '{ "query": {"bool":{"filter":[{"term":{"tags":"number0"}},{"range":{"salesPrice.amount":{"lte":8.7}}},{"range":{"createdAt":{"gte":"now-1h"}}}]}}, "sort": "name.keyword"}'
76
+ #
77
+ # @param query [String] the hash to search
78
+ #
79
+ # @return [OpenStruct]
80
+ #
81
+ # @example
82
+ # body = {
83
+ # "query"=> {
84
+ # "bool"=> {
85
+ # "filter"=> [{
86
+ # "term"=> {
87
+ # "tags"=> "number0"
88
+ # }
89
+ # }, {
90
+ # "range"=> {
91
+ # "salesPrice.amount"=> {
92
+ # "lte"=> 8.7
93
+ # }
94
+ # }
95
+ # }, {
96
+ # "range"=> {
97
+ # "createdAt"=> {
98
+ # "gte"=> "now-1h"
99
+ # }
100
+ # }
101
+ # }]
102
+ # }
103
+ # },
104
+ # "sort"=> "name.keyword"
105
+ # }
106
+ # @products = session.product_view_products.search_by_query(body)
107
+ #
108
+ def search_by_query(query)
109
+ response, status = BeyondApi::Request.post(@session, "/product-view/products/search/find-by-query", body)
110
+
111
+ handle_response(response, status)
112
+ end
113
+
114
+ #
115
+ # A +GET+ request is used to search for products matching any tag of the list given by a client. The intention is to offer product search capabilities for a shop’s storefront.
116
+ #
117
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-by-tags?tag=number0' -i -X GET \
118
+ # -H 'Content-Type: application/json' \
119
+ # -H 'Accept: application/hal+json'
120
+ #
121
+ # @param tag [String] the tag to search
122
+ # @option params [Integer] :size the page size
123
+ # @option params [Integer] :page the page number
124
+ #
125
+ # @return [OpenStruct]
126
+ #
127
+ # @example
128
+ # @products = session.product_view_products.search_by_tag("number0", page: 0, size: 100)
129
+ #
130
+ def search_by_tag(tag, params = {})
131
+ response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-tags", params.merge(tag: tag))
132
+
133
+ handle_response(response, status)
134
+ end
135
+
136
+ #
137
+ # A +GET+ request is used to search for products matching any tag of the list given by a client. The intention is to offer product search capabilities for a shop’s storefront.
138
+ #
139
+ # $ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-by-term?query=search+snippet' -i -X GET \
140
+ # -H 'Content-Type: application/json' \
141
+ # -H 'Accept: application/hal+json'
142
+ #
143
+ # @param term [String] the term to search
144
+ # @option params [Integer] :size the page size
145
+ # @option params [Integer] :page the page number
146
+ #
147
+ # @return [OpenStruct]
148
+ #
149
+ # @example
150
+ # @products = session.product_view_products.search_by_term("search snippet", page: 0, size: 100)
151
+ #
152
+ def search_by_term(term, params = {})
153
+ response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-term", params.merge(query: term))
154
+
155
+ handle_response(response, status)
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class Scopes < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +GET+ request will list all scopes in the system.
11
+ #
12
+ # $ curl 'https://api-shop.beyondshop.cloud/api/scopes' -i -X GET \
13
+ # -H 'Authorization: Bearer <Access token>'
14
+ #
15
+ # @beyond_api.scopes +scop:r+
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
+ # @scopes = session.scopes.all(size: 20, page: 0)
24
+ #
25
+ def all(params = {})
26
+ response, status = BeyondApi::Request.get(@session, "/scopes", params)
27
+
28
+ handle_response(response, status)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "beyond_api/utils"
4
+
5
+ module BeyondApi
6
+ class ScriptTags < Base
7
+ include BeyondApi::Utils
8
+
9
+ #
10
+ # A +GET+ request is used to retrieve a list of all script tags for a shop.
11
+ #
12
+ # $ curl 'https://api-shop.beyondshop.cloud/api/script-tags' -i -X GET \
13
+ # -H 'Authorization: Bearer <Access token>'
14
+ #
15
+ # @option params [Integer] :size the page size
16
+ # @option params [Integer] :page the page number
17
+ #
18
+ # @return [OpenStruct]
19
+ #
20
+ # @example
21
+ # @script_tags = session.script_tags.all(size: 20, page: 0)
22
+ #
23
+ def all(params = {})
24
+ response, status = BeyondApi::Request.get(@session, "/script-tags", params)
25
+
26
+ handle_response(response, status)
27
+ end
28
+
29
+ #
30
+ # A +GET+ request is used to retrieve a single script tag.
31
+ #
32
+ # $ curl 'https://api-shop.beyondshop.cloud/api/script-tags/df170ab1-13ae-4955-8b51-2478246acf59' -i -X GET \
33
+ # -H 'Authorization: Bearer <Access token>'
34
+ #
35
+ # @param script_tag_id [String] the script tag UUID
36
+ #
37
+ # @return [OpenStruct]
38
+ #
39
+ # @example
40
+ # @script_tag = session.script_tags.find("df170ab1-13ae-4955-8b51-2478246acf59")
41
+ #
42
+ def find(script_tag_id)
43
+ response, status = BeyondApi::Request.get(@session, "/script-tags/#{script_tag_id}")
44
+
45
+ handle_response(response, status)
46
+ end
47
+
48
+ #
49
+ # A +POST+ request is used to create a script tag.
50
+ #
51
+ # $ curl 'https://api-shop.beyondshop.cloud/api/script-tags' -i -X POST \
52
+ # -H 'Content-Type: application/json' \
53
+ # -H 'Accept: application/hal+json' \
54
+ # -H 'Authorization: Bearer <Access token>' \
55
+ # -d '{
56
+ # "scriptUrl": "https://example.org/js/fancy-script.js"
57
+ # }'
58
+ #
59
+ # @beyond_api.scopes +sctg:m+
60
+ #
61
+ # @param script_tag_url [String] the url of the script
62
+ #
63
+ # @return [OpenStruct]
64
+ #
65
+ # @example
66
+ # @script_tag = session.script_tags.create("https://example.org/js/fancy-script.js")
67
+ #
68
+ def create(script_tag_url)
69
+ response, status = BeyondApi::Request.post(@session, "/script-tags", { script_url: script_tag_url })
70
+
71
+ handle_response(response, status)
72
+ end
73
+
74
+ #
75
+ # A +DELETE+ request is used to delete a script tag. You can only delete a script tag created by your app.
76
+ #
77
+ # $ curl 'https://api-shop.beyondshop.cloud/api/script-tags/4a9f7776-d74d-4311-8ddb-121bd5407520' -i -X DELETE \
78
+ # -H 'Authorization: Bearer <Access token>'
79
+ #
80
+ # @beyond_api.scopes +sctg:m+
81
+ #
82
+ # @param script_tag_id [String] the script tag UUID
83
+ #
84
+ # @return true
85
+ #
86
+ # @example
87
+ # session.script_tags.delete("4a9f7776-d74d-4311-8ddb-121bd5407520")
88
+ #
89
+ def delete(script_tag_id)
90
+ response, status = BeyondApi::Request.delete(@session, "/script-tags/#{script_tag_id}")
91
+
92
+ handle_response(response, status, respond_with_true: true)
93
+ end
94
+
95
+ #
96
+ # A +PUT+ request is used to update an existing script tag. You can only update a script tag created by your app.
97
+ #
98
+ # $ curl 'https://api-shop.beyondshop.cloud/api/script-tags/d6c7b3d2-4984-4fa6-b5f2-b0f5cfc63bd3' -i -X PUT \
99
+ # -H 'Content-Type: application/json' \
100
+ # -H 'Accept: application/hal+json' \
101
+ # -H 'Authorization: Bearer <Access token>' \
102
+ # -d '{
103
+ # "scriptUrl": "https://example.org/scripts/someOtherScript.js"
104
+ # }'
105
+ #
106
+ # @beyond_api.scopes +sctg:m+
107
+ #
108
+ # @param script_tag_id [String] the script tag UUID
109
+ # @param script_tag_url [String] the url of the script
110
+ #
111
+ # @return [OpenStruct]
112
+ #
113
+ # @example
114
+ # @script_tag = session.script_tags.create("https://example.org/scripts/someOtherScript.js")
115
+ #
116
+ def update(script_tag_id, script_tag_url)
117
+ response, status = BeyondApi::Request.put(@session, "/script-tags/#{script_tag_id}", { script_url: script_tag_url })
118
+
119
+ handle_response(response, status)
120
+ end
121
+ end
122
+ end