beyond_api 0.9.0.pre → 0.12.1.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 +43 -0
- data/Gemfile.lock +1 -1
- data/lib/beyond_api/error.rb +12 -7
- data/lib/beyond_api/ext.rb +8 -1
- data/lib/beyond_api/resources/categories.rb +2 -3
- data/lib/beyond_api/resources/categories_view.rb +2 -3
- data/lib/beyond_api/resources/customers.rb +2 -3
- data/lib/beyond_api/resources/orders.rb +2 -3
- data/lib/beyond_api/resources/payment_methods.rb +2 -3
- data/lib/beyond_api/resources/product_attribute_definitions.rb +1 -20
- data/lib/beyond_api/resources/products.rb +10 -29
- data/lib/beyond_api/resources/products_view.rb +2 -3
- data/lib/beyond_api/resources/script_tags.rb +2 -3
- data/lib/beyond_api/resources/shipping_zones.rb +2 -3
- 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/token.rb +5 -1
- data/lib/beyond_api/resources/users.rb +2 -3
- data/lib/beyond_api/resources/variations.rb +3 -2
- data/lib/beyond_api/resources/webhook_subscriptions.rb +2 -3
- data/lib/beyond_api/session.rb +22 -22
- data/lib/beyond_api/utils.rb +29 -2
- data/lib/beyond_api/version.rb +1 -1
- metadata +7 -2
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ShopAddress
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +GET+ request is used to retrieve the details of a shop’s address.
|
10
|
+
#
|
11
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X GET
|
12
|
+
#
|
13
|
+
# @return [OpenStruct]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# session.shop.address
|
17
|
+
#
|
18
|
+
def address
|
19
|
+
response, status = BeyondApi::Request.get(@session, "/shop/address")
|
20
|
+
|
21
|
+
handle_response(response, status)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# A +PATCH+ request is used to patch a shop’s address partially with json content type.
|
26
|
+
#
|
27
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X PATCH \
|
28
|
+
# -H 'Content-Type: application/json' \
|
29
|
+
# -H 'Accept: application/hal+json' \
|
30
|
+
# -H 'Authorization: Bearer <Access token>' \
|
31
|
+
# -d '{
|
32
|
+
# "city" : "Barcelona"
|
33
|
+
# }'
|
34
|
+
#
|
35
|
+
# @beyond_api.scopes +shad:u+
|
36
|
+
#
|
37
|
+
# @param body [Hash] the request body
|
38
|
+
#
|
39
|
+
# @return [OpenStruct]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# body = {
|
43
|
+
# "city" => "Barcelona"
|
44
|
+
# }
|
45
|
+
#
|
46
|
+
# session.shop.update_address(body)
|
47
|
+
#
|
48
|
+
def update_address(body)
|
49
|
+
response, status = BeyondApi::Request.patch(@session, "/shop/address", body)
|
50
|
+
|
51
|
+
handle_response(response, status)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ShopAttributes
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +GET+ request is used to retrieve a particular shop attribute by its name.
|
10
|
+
#
|
11
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X GET \
|
12
|
+
# -H 'Authorization: Bearer <Access token>'
|
13
|
+
#
|
14
|
+
# @beyond_api.scopes +shat:r+
|
15
|
+
#
|
16
|
+
# @param attribute_name [String] the attribute name
|
17
|
+
#
|
18
|
+
# @return [OpenStruct]
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# @shop_attribute = session.shop.attribute("second-unknown-attribute-name")
|
22
|
+
#
|
23
|
+
def attribute(attribute_name)
|
24
|
+
response, status = BeyondApi::Request.get(@session, "/shop/attributes/#{attribute_name}")
|
25
|
+
|
26
|
+
handle_response(response, status)
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# A +GET+ request is used to retrieve a list of all shop attributes.
|
31
|
+
#
|
32
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X GET \
|
33
|
+
# -H 'Authorization: Bearer <Access token>'
|
34
|
+
#
|
35
|
+
# @beyond_api.scopes +shat:r+
|
36
|
+
#
|
37
|
+
# @option params [Integer] :size the page size
|
38
|
+
# @option params [Integer] :page the page number
|
39
|
+
#
|
40
|
+
# @return [OpenStruct]
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# @shop_attributes = session.shop.attributes(size: 5, page: 1)
|
44
|
+
#
|
45
|
+
def attributes(params = {})
|
46
|
+
response, status = BeyondApi::Request.get(@session, "/shop/attributes", params)
|
47
|
+
|
48
|
+
handle_response(response, status)
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# A +POST+ request is used to create a shop attribute.
|
53
|
+
#
|
54
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X POST \
|
55
|
+
# -H 'Content-Type: application/json' \
|
56
|
+
# -H 'Authorization: Bearer <Access token>' \
|
57
|
+
# -d '{
|
58
|
+
# "name" : "second-unknown-attribute-name",
|
59
|
+
# "value" : "correct-value",
|
60
|
+
# "public" : false
|
61
|
+
# }'
|
62
|
+
#
|
63
|
+
# @beyond_api.scopes +shat:c+
|
64
|
+
#
|
65
|
+
# @param body [Hash] the request body
|
66
|
+
#
|
67
|
+
# @return [OpenStruct]
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# body = {
|
71
|
+
# "name" => "second-unknown-attribute-name",
|
72
|
+
# "value" => "correct-value",
|
73
|
+
# "public" => false
|
74
|
+
# }
|
75
|
+
#
|
76
|
+
# session.shop.create_attribute(body)
|
77
|
+
#
|
78
|
+
def create_attribute(body)
|
79
|
+
response, status = BeyondApi::Request.post(@session, "/shop/attributes", body)
|
80
|
+
|
81
|
+
handle_response(response, status)
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# A +DELETE+ request is used to delete an shop attribute.
|
86
|
+
#
|
87
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X DELETE \
|
88
|
+
# -H 'Authorization: Bearer <Access token>'
|
89
|
+
#
|
90
|
+
# @beyond_api.scopes +shat:d+
|
91
|
+
#
|
92
|
+
# @param attribute_name [String] the attribute name
|
93
|
+
#
|
94
|
+
# @return true
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# session.shop.delete_attribute("second-unknown-attribute-name")
|
98
|
+
#
|
99
|
+
def delete_attribute(attribute_name)
|
100
|
+
response, status = BeyondApi::Request.delete(@session, "/shop/attributes/#{attribute_name}")
|
101
|
+
|
102
|
+
handle_response(response, status, respond_with_true: true)
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# A +PUT+ request is used to update a shop attribute. This operation is idempotent and will create a new shop attribute if required.
|
107
|
+
#
|
108
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X PUT \
|
109
|
+
# -H 'Content-Type: application/json' \
|
110
|
+
# -H 'Authorization: Bearer <Access token>' \
|
111
|
+
# -d '{
|
112
|
+
# "value" : "new-value",
|
113
|
+
# "public" : false
|
114
|
+
# }'
|
115
|
+
#
|
116
|
+
# @beyond_api.scopes +shat:u+
|
117
|
+
#
|
118
|
+
# @param attribute_name [String] the attribute name
|
119
|
+
# @param body [Hash] the request body
|
120
|
+
#
|
121
|
+
# @return [OpenStruct]
|
122
|
+
#
|
123
|
+
# @example
|
124
|
+
# body = {
|
125
|
+
# "value" => "new-value",
|
126
|
+
# "public" => false
|
127
|
+
# }
|
128
|
+
#
|
129
|
+
# session.shop.update_attribute("second-unknown-attribute-name", body)
|
130
|
+
#
|
131
|
+
def update_attribute(attribute_name, body)
|
132
|
+
response, status = BeyondApi::Request.put(@session, "/shop/attributes/#{attribute_name}", body)
|
133
|
+
|
134
|
+
handle_response(response, status)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ShopImages
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +POST+ request is used to create a shop image.
|
10
|
+
#
|
11
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images' -i -X POST \
|
12
|
+
# -H 'Content-Type: application/json' \
|
13
|
+
# -H 'Accept: application/hal+json' \
|
14
|
+
# -H 'Authorization: Bearer <Access token>' \
|
15
|
+
# -d '{
|
16
|
+
# "dataUri" : "file.png?hash=212-2323-4343",
|
17
|
+
# "label" : "logo"
|
18
|
+
# }'
|
19
|
+
#
|
20
|
+
# @beyond_api.scopes +shim:c+
|
21
|
+
#
|
22
|
+
# @param body [Hash] the request body
|
23
|
+
#
|
24
|
+
# @return true
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# body = {
|
28
|
+
# "data_uri" => "file.png?hash=212-2323-4343",
|
29
|
+
# "label" => "logo"
|
30
|
+
# }
|
31
|
+
#
|
32
|
+
# session.shop.create_image(body)
|
33
|
+
#
|
34
|
+
def create_image(body)
|
35
|
+
response, status = BeyondApi::Request.post(@session, "/shop/images", body)
|
36
|
+
|
37
|
+
handle_response(response, status, respond_with_true: true)
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# A +DELETE+ request is used to delete a shop image.
|
42
|
+
#
|
43
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/6a7646dc-7f26-4730-a98f-52f9b63978fb' -i -X DELETE \
|
44
|
+
# -H 'Content-Type: application/json' \
|
45
|
+
# -H 'Accept: application/hal+json' \
|
46
|
+
# -H 'Authorization: Bearer <Access token>'
|
47
|
+
#
|
48
|
+
# @beyond_api.scopes +shim:d+
|
49
|
+
#
|
50
|
+
# @param image_id [String] the image UUID
|
51
|
+
#
|
52
|
+
# @return true
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# session.shop.delete_image("6a7646dc-7f26-4730-a98f-52f9b63978fb")
|
56
|
+
#
|
57
|
+
def delete_image(image_id)
|
58
|
+
response, status = BeyondApi::Request.delete(@session, "/shop/images/#{image_id}")
|
59
|
+
|
60
|
+
handle_response(response, status, respond_with_true: true)
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# A +GET+ request is used to retrieve a single shop image.
|
65
|
+
#
|
66
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/2feee7ac-f1cb-4faf-9488-f3ce07394141' -i -X GET \
|
67
|
+
# -H 'Accept: application/hal+json'
|
68
|
+
#
|
69
|
+
# @param image_id [String] the image UUID
|
70
|
+
#
|
71
|
+
# @return [OpenStruct]
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# @image = session.shop.image("2feee7ac-f1cb-4faf-9488-f3ce07394141")
|
75
|
+
#
|
76
|
+
def image(image_id)
|
77
|
+
response, status = BeyondApi::Request.get(@session, "/shop/images/#{image_id}")
|
78
|
+
|
79
|
+
handle_response(response, status)
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# A +GET+ request is used to retrieve the images of a shop.
|
84
|
+
#
|
85
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images' -i -X GET \
|
86
|
+
# -H 'Accept: application/hal+json'
|
87
|
+
#
|
88
|
+
# @option params [Integer] :size the page size
|
89
|
+
# @option params [Integer] :page the page number
|
90
|
+
#
|
91
|
+
# @return [OpenStruct]
|
92
|
+
#
|
93
|
+
# @example
|
94
|
+
# @images = session.shop.images(size: 5, page: 1)
|
95
|
+
#
|
96
|
+
def images(params = {})
|
97
|
+
response, status = BeyondApi::Request.get(@session, "/shop/images", params)
|
98
|
+
|
99
|
+
handle_response(response, status)
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# A +GET+ request is issued to search for shop images by label.
|
104
|
+
#
|
105
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/search/find-by-label?label=logo' -i -X GET \
|
106
|
+
# -H 'Accept: application/hal+json'
|
107
|
+
#
|
108
|
+
# @param label [String] the image label
|
109
|
+
#
|
110
|
+
# @return [OpenStruct]
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# session.shop.search_images_by_label("logo")
|
114
|
+
#
|
115
|
+
def search_images_by_label(label)
|
116
|
+
response, status = BeyondApi::Request.get(@session, "/shop/images/search/find-by-label", { label: label })
|
117
|
+
|
118
|
+
handle_response(response, status)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# A +POST+ request is used to upload a shop image. The body of the request must contain the content of the image.
|
123
|
+
#
|
124
|
+
# $ curl --data-binary '@/home/epages/sample.png' 'https://api-shop.beyondshop.cloud/api/shop/images?fileName=sample.png&label=invoice logo' -X POST \
|
125
|
+
# -H 'Content-Type: image/png' \
|
126
|
+
# -H 'Authorization: Bearer <Access token>'
|
127
|
+
#
|
128
|
+
# @beyond_api.scopes +shim:c+
|
129
|
+
#
|
130
|
+
# @param image_path [String] the image path
|
131
|
+
# @param image_name [String] the image name
|
132
|
+
# @param label [String] the image label
|
133
|
+
#
|
134
|
+
# @return true
|
135
|
+
#
|
136
|
+
# @example
|
137
|
+
# session.shop.upload_image("/home/epages/sample.png", "sample.png", "invoice logo")
|
138
|
+
#
|
139
|
+
def upload_image(image_path, image_name, label)
|
140
|
+
content_type = case File.extname(image_path)
|
141
|
+
when ".png"
|
142
|
+
"image/png"
|
143
|
+
when ".jpg", ".jpeg"
|
144
|
+
"image/jpeg"
|
145
|
+
when ".gif"
|
146
|
+
"image/gif"
|
147
|
+
end
|
148
|
+
image_binary = File.binread(image_path)
|
149
|
+
|
150
|
+
response, status = BeyondApi::Request.upload(@session, "/shop/images", image_binary, content_type, { file_name: image_name, label: label })
|
151
|
+
|
152
|
+
handle_response(response, status, respond_with_true: true)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ShopLegals
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +GET+ request is used to retrieve a specific part of the legal content information.
|
10
|
+
#
|
11
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/right-of-withdrawal' -i -X GET \
|
12
|
+
# -H 'Content-Type: application/json' \
|
13
|
+
# -H 'Accept: application/json'
|
14
|
+
#
|
15
|
+
# @param legal_content_type [String] the legal content type
|
16
|
+
#
|
17
|
+
# @return [OpenStruct]
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# @legal_content = session.shop.legal_content("right-of-withdrawal")
|
21
|
+
#
|
22
|
+
def legal_content(legal_content_type)
|
23
|
+
response, status = BeyondApi::Request.get(@session, "/legal-content/#{legal_content_type}")
|
24
|
+
|
25
|
+
handle_response(response, status)
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# A +GET+ request is used to retrieve the legal content of a shop.
|
30
|
+
#
|
31
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content' -i -X GET \
|
32
|
+
# -H 'Content-Type: application/json' \
|
33
|
+
# -H 'Accept: application/json'
|
34
|
+
#
|
35
|
+
# @option params [Integer] :size the page size
|
36
|
+
# @option params [Integer] :page the page number
|
37
|
+
#
|
38
|
+
# @return [OpenStruct]
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# @legal_content = session.shop.legal_contents(size: 5, page: 1)
|
42
|
+
#
|
43
|
+
def legal_contents(params = {})
|
44
|
+
response, status = BeyondApi::Request.get(@session, "/legal-content", params)
|
45
|
+
|
46
|
+
handle_response(response, status)
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# A +GET+ request is used to retrieve the details of the legal resource.
|
51
|
+
#
|
52
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/legal' -i -X GET \
|
53
|
+
# -H 'Authorization: Bearer <Access token>'
|
54
|
+
#
|
55
|
+
# @beyond_api.scopes +legl:r+
|
56
|
+
#
|
57
|
+
# @return [OpenStruct]
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# @legal_details = session.shop.legal_details
|
61
|
+
#
|
62
|
+
def legal_details
|
63
|
+
response, status = BeyondApi::Request.get(@session, "/shop/legal")
|
64
|
+
|
65
|
+
handle_response(response, status)
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# A +PUT+ request is used to update the content of a specific part of the legal content information. Changes on the properties type and mandatory will be ignored.
|
70
|
+
#
|
71
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/legal-notice' -i -X PUT \
|
72
|
+
# -H 'Content-Type: application/json' \
|
73
|
+
# -H 'Accept: application/json' \
|
74
|
+
# -H 'Authorization: Bearer <Access token>' \
|
75
|
+
# -d '{
|
76
|
+
# "content" : "new legal content"
|
77
|
+
# }'
|
78
|
+
#
|
79
|
+
# @beyond_api.scopes +lcnt:u+
|
80
|
+
#
|
81
|
+
# @param body [Hash] the request body
|
82
|
+
#
|
83
|
+
# @return [OpenStruct]
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# session.shop.update_legal_content(body)
|
87
|
+
#
|
88
|
+
def update_legal_content(body)
|
89
|
+
response, status = BeyondApi::Request.put(@session, "/legal-content/legal-notice")
|
90
|
+
|
91
|
+
handle_response(response, status)
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# A +PATCH+ request is used to update a legal resource partially with json content type.
|
96
|
+
#
|
97
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/legal' -i -X PATCH \
|
98
|
+
# -H 'Content-Type: application/json' \
|
99
|
+
# -H 'Accept: application/hal+json' \
|
100
|
+
# -H 'Authorization: Bearer <Access token>' \
|
101
|
+
# -d '{
|
102
|
+
# "vatId" : "GB 111111111"
|
103
|
+
# }'
|
104
|
+
#
|
105
|
+
# @beyond_api.scopes +legl:u+
|
106
|
+
#
|
107
|
+
# @param body [Hash] the request body
|
108
|
+
#
|
109
|
+
# @return [OpenStruct]
|
110
|
+
#
|
111
|
+
# @example
|
112
|
+
# body = {
|
113
|
+
# "vat_id" => "GB 111111111"
|
114
|
+
# }
|
115
|
+
#
|
116
|
+
# session.shop.update_legal_details(body)
|
117
|
+
#
|
118
|
+
def update_legal_details(body)
|
119
|
+
response, status = BeyondApi::Request.patch(@session, "/shop/legal")
|
120
|
+
|
121
|
+
handle_response(response, status)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|