Class: Courier::Resources::WorkspacePreferences::Topics

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/workspace_preferences/topics.rb,
sig/courier/resources/workspace_preferences/topics.rbs

Instance Method Summary collapse

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.

Parameters:



255
256
257
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 255

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.

Parameters:

  • topic_id (String) —

    Id of the subscription preference topic.

  • section_id (String) —

    Id of the workspace preference.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



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, options = 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: options
  )
end

#create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, digest: 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.

Parameters:

  • section_id (String) —

    Path param: Id of the workspace preference to create the topic in.

  • default_status (Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::DefaultStatus) —

    Body param: The default subscription status applied when a recipient has not set

  • name (String) —

    Body param: Human-readable name for the preference topic.

  • allowed_preferences (Array<Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::AllowedPreference>, nil) —

    Body param: Preference controls a recipient may customize for this topic. Defaul

  • description (String, nil) —

    Body param: Optional description shown under the topic on the hosted preferences

  • digest (Courier::Models::WorkspacePreferenceTopicCreateRequest::Digest, nil) —

    Body param: A topic's digest, as supplied when the topic itself is created: the

  • include_unsubscribe_header (Boolean, nil) —

    Body param: Whether to include a list-unsubscribe header on emails for this topi

  • routing_options (Array<Symbol, Courier::Models::ChannelClassification>, nil) —

    Body param: Default channels delivered for this topic. Defaults to empty if omit

  • topic_data (Hash{Symbol=>Object}, nil) —

    Body param: Arbitrary metadata associated with the topic.

  • idempotency_key (String) —

    Header param: A unique key that makes this request idempotent. If Courier receiv

  • x_idempotency_expiration (String) —

    Header param: How long the idempotency key remains valid, as a Unix epoch timest

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end

#delete_digest(topic_id, section_id:, request_options: {}) ⇒ nil

Turn off a topic's digest, leaving the topic itself in place. The template is unlinked and the digest's schedules are removed along with their delivery rules. Equivalent to sending digest: null on a topic replace.

Parameters:

  • topic_id (String) —

    The preference topic whose digest to turn off.

  • section_id (String) —

    The preference section containing the topic.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 148

def delete_digest(topic_id, params)
  parsed, options = Courier::WorkspacePreferences::TopicDeleteDigestParams.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/digest", section_id, topic_id],
    model: NilClass,
    options: 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.

Parameters:

  • section_id (String) —

    Id of the workspace preference.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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

#release_digest(topic_id, section_id:, user_id:, tenant_id: nil, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::WorkspacePreferences::TopicReleaseDigestParams for more details.

Send one recipient's held digest now, instead of waiting for its schedule. Use it to preview what a digest will look like, or to let someone flush their own.

Keyed on the topic because that is how a held digest is stored: one per recipient per topic, with the schedule recorded on it rather than part of its identity. To flush every recipient on a schedule instead, use POST /digests/schedules/{schedule_id}/trigger.

Parameters:

  • topic_id (String) —

    Path param: The preference topic whose digest to release.

  • section_id (String) —

    Path param: The preference section containing the topic.

  • user_id (String) —

    Body param: The recipient whose digest to release. Required: there is no "releas

  • tenant_id (String) —

    Body param: The recipient's tenant, when they were sent to as part of one -- the

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 189

def release_digest(topic_id, params)
  parsed, options = Courier::WorkspacePreferences::TopicReleaseDigestParams.dump_request(params)
  section_id =
    parsed.delete(:section_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["preferences/sections/%1$s/topics/%2$s/digest/release", section_id, topic_id],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, description: nil, digest: 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.

Parameters:

  • topic_id (String) —

    Path param: Id of the subscription preference topic.

  • section_id (String) —

    Path param: Id of the workspace preference.

  • default_status (Symbol, Courier::Models::WorkspacePreferenceTopicReplaceRequest::DefaultStatus) —

    Body param: The default subscription status applied when a recipient has not set

  • name (String) —

    Body param: Human-readable name for the preference topic.

  • allowed_preferences (Array<Symbol, Courier::Models::WorkspacePreferenceTopicReplaceRequest::AllowedPreference>, nil) —

    Body param: Preference controls a recipient may customize. Omit to clear.

  • description (String, nil) —

    Body param: Optional description shown under the topic on the hosted preferences

  • digest (Courier::Models::TopicDigestRequest, nil) —

    Body param: A topic's digest configuration: the template that renders it, the ca

  • include_unsubscribe_header (Boolean, nil) —

    Body param: Whether to include a list-unsubscribe header on emails for this topi

  • routing_options (Array<Symbol, Courier::Models::ChannelClassification>, nil) —

    Body param: Default channels delivered for this topic. Omit to clear.

  • topic_data (Hash{Symbol=>Object}, nil) —

    Body param: Arbitrary metadata associated with the topic. Omit to clear.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 237

def replace(topic_id, params)
  parsed, options = 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: 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.

Parameters:

  • topic_id (String) —

    Id of the subscription preference topic.

  • section_id (String) —

    Id of the workspace preference.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end