Class: BeyondApi::NewsletterTarget
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/newsletter_target.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(submit_url) ⇒ OpenStruct
A
POST
request is used to create the newsletter target. -
#delete ⇒ Object
A
DELETE
request is used to delete the existing newsletter target. -
#find ⇒ OpenStruct
A
GET
request is used to retrieve the newsletter target. -
#update(submit_url) ⇒ OpenStruct
A
PUT
request is used to update the existing newsletter target.
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
#create(submit_url) ⇒ OpenStruct
A POST
request is used to create the newsletter target. Each shop can only have one newsletter target. You can update this target at any time, or delete the existing one and create a new target.
$ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"submitUrl": "https://example.org/cgi-bin/subscribe.php"
}'
30 31 32 33 34 35 36 |
# File 'lib/beyond_api/resources/newsletter_target.rb', line 30 def create(submit_url) response, status = BeyondApi::Request.post(@session, "/newsletter-target", { submit_url: submit_url }) handle_response(response, status) end |
#delete ⇒ Object
A DELETE
request is used to delete the existing newsletter target.
$ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X DELETE \
-H 'Authorization: Bearer <Access token>'
51 52 53 54 55 56 |
# File 'lib/beyond_api/resources/newsletter_target.rb', line 51 def delete response, status = BeyondApi::Request.delete(@session, "/newsletter-target") handle_response(response, status, respond_with_true: true) end |
#find ⇒ OpenStruct
A GET
request is used to retrieve the newsletter target.
$ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X GET
68 69 70 71 72 73 |
# File 'lib/beyond_api/resources/newsletter_target.rb', line 68 def find response, status = BeyondApi::Request.get(@session, "/newsletter-target") handle_response(response, status) end |
#update(submit_url) ⇒ OpenStruct
A PUT
request is used to update the existing newsletter target
$ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X PUT \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"submitUrl": "https://example.org/api/newsletter/subscription"
}'
95 96 97 98 99 100 101 |
# File 'lib/beyond_api/resources/newsletter_target.rb', line 95 def update(submit_url) response, status = BeyondApi::Request.put(@session, "/newsletter-target", { submit_url: submit_url }) handle_response(response, status) end |