Class: Courier::Resources::WorkspacePreferences::Topics
- Inherits:
-
Object
- Object
- Courier::Resources::WorkspacePreferences::Topics
- Defined in:
- lib/courier/resources/workspace_preferences/topics.rb,
sig/courier/resources/workspace_preferences/topics.rbs
Overview
Manage the workspace catalog of subscription topics, the sections that group them, and publishing the preference page.
Instance Method Summary collapse
-
#archive(topic_id, section_id:, request_options: {}) ⇒ nil
Archives a subscription topic and removes it from its workspace preference, addressed by section id and topic id.
-
#create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferences::TopicCreateParams for more details.
-
#initialize(client:) ⇒ Topics
constructor
private
A new instance of Topics.
-
#list(section_id, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicListResponse
Returns the subscription topics inside a workspace preference, each with its default status and routing options.
-
#replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferences::TopicReplaceParams for more details.
-
#retrieve(topic_id, section_id:, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse
Returns one subscription topic with its default status, routing options, allowed preferences, and unsubscribe header setting.
Constructor Details
#initialize(client:) ⇒ Topics
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Topics.
182 183 184 |
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 182 def initialize(client:) @client = client end |
Instance Method Details
#archive(topic_id, section_id:, request_options: {}) ⇒ nil
Archives a subscription topic and removes it from its workspace preference, addressed by section id and topic id.
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 119 def archive(topic_id, params) parsed, = Courier::WorkspacePreferences::TopicArchiveParams.dump_request(params) section_id = parsed.delete(:section_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["preferences/sections/%1$s/topics/%2$s", section_id, topic_id], model: NilClass, options: ) end |
#create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferences::TopicCreateParams for more details.
Creates a subscription topic inside a workspace preference. The default status sets whether users start opted in, opted out, or required.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 42 def create(section_id, params) parsed, = Courier::WorkspacePreferences::TopicCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["preferences/sections/%1$s/topics", section_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::WorkspacePreferenceTopicGetResponse, options: ) end |
#list(section_id, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicListResponse
Returns the subscription topics inside a workspace preference, each with its default status and routing options.
96 97 98 99 100 101 102 103 |
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 96 def list(section_id, params = {}) @client.request( method: :get, path: ["preferences/sections/%1$s/topics", section_id], model: Courier::WorkspacePreferenceTopicListResponse, options: params[:request_options] ) end |
#replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferences::TopicReplaceParams for more details.
Replace a topic within a workspace preference. Full document replacement; missing optional fields are cleared. Same 404 rules as GET.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 164 def replace(topic_id, params) parsed, = Courier::WorkspacePreferences::TopicReplaceParams.dump_request(params) section_id = parsed.delete(:section_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["preferences/sections/%1$s/topics/%2$s", section_id, topic_id], body: parsed, model: Courier::WorkspacePreferenceTopicGetResponse, options: ) end |
#retrieve(topic_id, section_id:, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse
Returns one subscription topic with its default status, routing options, allowed preferences, and unsubscribe header setting.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 70 def retrieve(topic_id, params) parsed, = Courier::WorkspacePreferences::TopicRetrieveParams.dump_request(params) section_id = parsed.delete(:section_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["preferences/sections/%1$s/topics/%2$s", section_id, topic_id], model: Courier::WorkspacePreferenceTopicGetResponse, options: ) end |