Class: BeyondApi::ScriptTags
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/script_tags.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(params = {}) ⇒ OpenStruct
A
GET
request is used to retrieve a list of all script tags for a shop. -
#create(script_tag_url) ⇒ OpenStruct
A
POST
request is used to create a script tag. -
#delete(script_tag_id) ⇒ Object
A
DELETE
request is used to delete a script tag. -
#find(script_tag_id) ⇒ OpenStruct
A
GET
request is used to retrieve a single script tag. -
#update(script_tag_id, script_tag_url) ⇒ OpenStruct
A
PUT
request is used to update an existing script tag.
Methods included from Utils
#file_content_type, #handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct
Methods inherited from Base
Constructor Details
This class inherits a constructor from BeyondApi::Base
Instance Method Details
#all(params = {}) ⇒ OpenStruct
A GET
request is used to retrieve a list of all script tags for a shop.
$ curl 'https://api-shop.beyondshop.cloud/api/script-tags' -i -X GET \
-H 'Authorization: Bearer <Access token>'
25 26 27 28 29 30 31 |
# File 'lib/beyond_api/resources/script_tags.rb', line 25 def all(params = {}) path = "/script-tags" params.merge!(client_id: BeyondApi.configuration.client_id) if params[:only_own] handle_all_request(path, :script_tags, params) end |
#create(script_tag_url) ⇒ OpenStruct
A POST
request is used to create a script tag.
$ curl 'https://api-shop.beyondshop.cloud/api/script-tags' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"scriptUrl": "https://example.org/js/fancy-script.js"
}'
75 76 77 78 79 80 81 82 83 |
# File 'lib/beyond_api/resources/script_tags.rb', line 75 def create(script_tag_url) path = "/script-tags" response, status = BeyondApi::Request.post(@session, path, { script_url: script_tag_url }) handle_response(response, status) end |
#delete(script_tag_id) ⇒ Object
A DELETE
request is used to delete a script tag. You can only delete a script tag created by your app.
$ curl 'https://api-shop.beyondshop.cloud/api/script-tags/4a9f7776-d74d-4311-8ddb-121bd5407520' -i -X DELETE \
-H 'Authorization: Bearer <Access token>'
100 101 102 103 104 105 106 107 |
# File 'lib/beyond_api/resources/script_tags.rb', line 100 def delete(script_tag_id) path = "/script-tags/#{script_tag_id}" response, status = BeyondApi::Request.delete(@session, path) handle_response(response, status, respond_with_true: true) end |
#find(script_tag_id) ⇒ OpenStruct
A GET
request is used to retrieve a single script tag.
$ curl 'https://api-shop.beyondshop.cloud/api/script-tags/df170ab1-13ae-4955-8b51-2478246acf59' -i -X GET \
-H 'Authorization: Bearer <Access token>'
46 47 48 49 50 51 52 53 |
# File 'lib/beyond_api/resources/script_tags.rb', line 46 def find(script_tag_id) path = "/script-tags/#{script_tag_id}" response, status = BeyondApi::Request.get(@session, path) handle_response(response, status) end |
#update(script_tag_id, script_tag_url) ⇒ OpenStruct
A PUT
request is used to update an existing script tag. You can only update a script tag created by your app.
$ curl 'https://api-shop.beyondshop.cloud/api/script-tags/d6c7b3d2-4984-4fa6-b5f2-b0f5cfc63bd3' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"scriptUrl": "https://example.org/scripts/someOtherScript.js"
}'
130 131 132 133 134 135 136 137 138 |
# File 'lib/beyond_api/resources/script_tags.rb', line 130 def update(script_tag_id, script_tag_url) path = "/script-tags/#{script_tag_id}" response, status = BeyondApi::Request.put(@session, path, { script_url: script_tag_url }) handle_response(response, status) end |