class GdsApi::EmailAlertApi
@api documented
@see github.com/alphagov/email-alert-api<br><br>Adapter for the Email Alert API
def authenticate_subscriber_by_govuk_account(govuk_account_session:)
-
(Hash)- subscriber
Parameters:
-
govuk_account_session(string) -- The request's session identifier
def authenticate_subscriber_by_govuk_account(govuk_account_session:) post_json( "#{endpoint}/subscribers/govuk-account", govuk_account_session:, ) end
def bulk_unsubscribe(slug:, govuk_request_id: nil, body: nil, sender_message_id: nil)
-
(optional)(string) -- sender_message_id A UUID to prevent multiple emails for the same event. Required if you want to send an email. -
(optional)(string) -- body Optional email body to send to alert users they are being unsubscribed. Required if you want to send an email -
(optional)(string) -- govuk_request_id An ID allowing us to trace requests across our infra. Required if you want to send an email by running out-of-band processes via asynchronous workers. -
slug(string) -- Identifier for the subscription list
def bulk_unsubscribe(slug:, govuk_request_id: nil, body: nil, sender_message_id: nil) post_json( "#{endpoint}/subscriber-lists/#{slug}/bulk-unsubscribe", { body:, sender_message_id:, }.compact, { "Govuk-Request-Id" => govuk_request_id, }.compact, ) end
def change_subscriber(id:, new_address:, on_conflict: nil)
-
(Hash)- subscriber
Parameters:
-
Subscriber(string) -- new_address -
Subscriber(integer) -- id
def change_subscriber(id:, new_address:, on_conflict: nil) patch_json( "#{endpoint}/subscribers/#{uri_encode(id)}", { new_address:, on_conflict: }.compact, ) end
def change_subscription(id:, frequency:)
-
(Hash)- subscription
Parameters:
-
Subscription(string) -- frequency -
Subscription(string) -- id
def change_subscription(id:, frequency:) patch_json( "#{endpoint}/subscriptions/#{uri_encode(id)}", frequency:, ) end
def create_content_change(content_change, headers = {})
-
content_change(Hash) -- Valid content change attributes
def create_content_change(content_change, headers = {}) post_json("#{endpoint}/content-changes", content_change, headers) end
def find_or_create_subscriber_list(attributes)
-
attributes(Hash) -- document_type, links, tags used to search existing subscriber lists
def find_or_create_subscriber_list(attributes) present_fields = [attributes["content_id"], attributes["links"], attributes["tags"]].compact.count if (present_fields > 1) && attributes["tags"] message = "Invalid attributes provided. Valid attributes are content_id only, tags only, links only, content_id AND links, or none." raise ArgumentError, message end post_json("#{endpoint}/subscriber-lists", attributes) end
def find_subscriber_by_govuk_account(govuk_account_id:)
-
(Hash)- subscriber
Parameters:
-
govuk_account_id(String) -- An ID for the account.
def find_subscriber_by_govuk_account(govuk_account_id:) get_json( "#{endpoint}/subscribers/govuk-account/#{govuk_account_id}", ) end
def find_subscriber_list(attributes)
-
attributes(Hash) -- document_type, links, tags used to search existing subscriber lists
def find_subscriber_list(attributes) query_string = nested_query_string(attributes) get_json("#{endpoint}/subscriber-lists?" + query_string) end
def get_latest_matching_subscription(id)
-
(Hash)- subscription: {
def get_latest_matching_subscription(id) get_json("#{endpoint}/subscriptions/#{uri_encode(id)}/latest") end
def get_subscriber_list(slug:)
-
(Hash)- subscriber_list: {
def get_subscriber_list(slug:) get_json("#{endpoint}/subscriber-lists/#{uri_encode(slug)}") end
def get_subscriber_list_metrics(path:)
def get_subscriber_list_metrics(path:) get_json("#{endpoint}/subscriber-lists/metrics#{path}") end
def get_subscription(id)
-
(Hash)- subscription: {
def get_subscription(id) get_json("#{endpoint}/subscriptions/#{uri_encode(id)}") end
def get_subscriptions(id:, order: nil)
-
(Hash)- subscriber, subscriptions
Parameters:
-
Subscription(string) -- order - title, created_at -
Subscriber(integer) -- id
def get_subscriptions(id:, order: nil) if order get_json("#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions?order=#{uri_encode(order)}") else get_json("#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions") end end
def link_subscriber_to_govuk_account(govuk_account_session:)
-
(Hash)- subscriber
Parameters:
-
govuk_account_session(string) -- The request's session identifier
def link_subscriber_to_govuk_account(govuk_account_session:) post_json( "#{endpoint}/subscribers/govuk-account/link", govuk_account_session:, ) end
def nested_query_string(params)
def nested_query_string(params) Rack::Utils.build_nested_query(params) end
def send_subscriber_verification_email(address:, destination:)
-
(Hash)- subscriber
Parameters:
-
destination(string) -- Path on GOV.UK that subscriber will be emailed -
address(string) -- Address to send verification email to
def send_subscriber_verification_email(address:, destination:) post_json( "#{endpoint}/subscribers/auth-token", address:, destination:, ) end
def send_subscription_verification_email(address:, frequency:, topic_id:)
-
topic_id(string) -- The slugs/ID for the topic being subscribed to -
frequency(string) -- How often the subscriber wishes to be notified of new items -
address(string) -- Address to send verification email to
def send_subscription_verification_email(address:, frequency:, topic_id:) post_json( "#{endpoint}/subscriptions/auth-token", address:, frequency:, topic_id:, ) end
def subscribe(subscriber_list_id:, address:, frequency: "immediately", skip_confirmation_email: false)
-
(Hash)- subscription_id
def subscribe(subscriber_list_id:, address:, frequency: "immediately", skip_confirmation_email: false) post_json( "#{endpoint}/subscriptions", subscriber_list_id:, address:, frequency:, skip_confirmation_email:, ) end
def topic_matches(attributes)
-
(Hash)- topics, enabled, disabled
Parameters:
-
attributes(Hash) -- tags, links, document_type,
def topic_matches(attributes) query_string = nested_query_string(attributes) get_json("#{endpoint}/topic-matches.json?#{query_string}") end
def unsubscribe(uuid)
-
(nil)-
Parameters:
-
Subscription(string) -- uuid
def unsubscribe(uuid) post_json("#{endpoint}/unsubscribe/#{uri_encode(uuid)}") end
def unsubscribe_subscriber(id)
-
(nil)-
Parameters:
-
Subscriber(integer) -- id
def unsubscribe_subscriber(id) delete_json("#{endpoint}/subscribers/#{uri_encode(id)}") end
def update_subscriber_list_details(slug:, params: {})
-
params(Hash) -- A hash of detail paramaters that can be updated. For example title.
def update_subscriber_list_details(slug:, params: {}) patch_json( "#{endpoint}/subscriber-lists/#{slug}", params, ) end