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

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

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:



170
171
172
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 170

def initialize(client:)
  @client = client
end

Instance Method Details

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

Archive a topic and remove it from its workspace preference. Same 404 rules as GET.

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:



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 109

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, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicGetResponse

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

Create a subscription preference topic inside a workspace preference. Fails with 404 if the workspace preference does not exist. The topic id is generated and returned.

Parameters:

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 35

def create(section_id, params)
  parsed, options = Courier::WorkspacePreferences::TopicCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["preferences/sections/%1$s/topics", section_id],
    body: parsed,
    model: Courier::WorkspacePreferenceTopicGetResponse,
    options: options
  )
end

#list(section_id, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceTopicListResponse

List the topics in a workspace preference.

Parameters:

  • section_id (String)

    Id of the workspace preference.

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

Returns:

See Also:



86
87
88
89
90
91
92
93
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 86

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, 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.

  • 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:



152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 152

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

Retrieve a topic within a workspace preference. Returns 404 if the workspace preference does not exist, the topic does not exist, or the topic belongs to a different workspace preference.

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:



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/courier/resources/workspace_preferences/topics.rb', line 61

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