Class: BeyondApi::NewsletterTarget

Inherits:
Base
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/newsletter_target.rb

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods included from Utils

#handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct

Methods inherited from Base

#initialize

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"
}'

Examples:

session.newsletter_target.create({ submit_url: "https://example.org/cgi-bin/subscribe.php" })

Parameters:

  • submit_url (String)

    the URL stating where to submit the newsletter

Returns:

  • (OpenStruct)

Scopes:

  • nltg:m


30
31
32
33
34
# 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

#deleteObject

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>'

Examples:

session.newsletter_target.delete

Returns:

  • true

Scopes:

  • nltg:m


49
50
51
52
53
# File 'lib/beyond_api/resources/newsletter_target.rb', line 49

def delete
  response, status = BeyondApi::Request.delete(@session, "/newsletter-target")

  handle_response(response, status, respond_with_true: true)
end

#findOpenStruct

A GET request is used to retrieve the newsletter target.

$ curl 'https://api-shop.beyondshop.cloud/api/newsletter-target' -i -X GET

Examples:

@newsletter_target = session.newsletter_target.find

Returns:

  • (OpenStruct)

65
66
67
68
69
# File 'lib/beyond_api/resources/newsletter_target.rb', line 65

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"
}'

Examples:

session.newsletter_target.update({ submit_url: "https://example.org/cgi-bin/subscribe.php" })

Parameters:

  • submit_url (String)

    the URL stating where to submit the newsletter

Returns:

  • (OpenStruct)

Scopes:

  • nltg:m


91
92
93
94
95
# File 'lib/beyond_api/resources/newsletter_target.rb', line 91

def update(submit_url)
  response, status = BeyondApi::Request.put(@session, "/newsletter-target", { submit_url: submit_url })

  handle_response(response, status)
end