Class: Courier::Resources::WorkspacePreferences

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

Defined Under Namespace

Classes: Topics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ WorkspacePreferences

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

Parameters:



167
168
169
170
# File 'lib/courier/resources/workspace_preferences.rb', line 167

def initialize(client:)
  @client = client
  @topics = Courier::Resources::WorkspacePreferences::Topics.new(client: client)
end

Instance Attribute Details

#topicsCourier::Resources::WorkspacePreferences::Topics (readonly)



7
8
9
# File 'lib/courier/resources/workspace_preferences.rb', line 7

def topics
  @topics
end

Instance Method Details

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

Archive a workspace preference. The workspace preference must be empty: delete its topics first, otherwise the request fails with 409.

Parameters:

  • section_id (String)

    Id of the workspace preference.

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

Returns:

  • (nil)

See Also:



90
91
92
93
94
95
96
97
# File 'lib/courier/resources/workspace_preferences.rb', line 90

def archive(section_id, params = {})
  @client.request(
    method: :delete,
    path: ["preferences/sections/%1$s", section_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#create(name:, description: nil, has_custom_routing: nil, routing_options: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse

Create a workspace preference. The workspace preference id is generated and returned. Topics are created inside a workspace preference via POST /preferences/sections/section_id/topics.

Parameters:

  • name (String)

    Human-readable name for the workspace preference.

  • description (String, nil)

    Optional description shown under the section on the hosted preferences page.

  • has_custom_routing (Boolean, nil)

    Whether the workspace preference defines custom routing for its topics.

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

    Default channels for the workspace preference. Defaults to empty if omitted.

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

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
# File 'lib/courier/resources/workspace_preferences.rb', line 28

def create(params)
  parsed, options = Courier::WorkspacePreferenceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "preferences/sections",
    body: parsed,
    model: Courier::WorkspacePreferenceGetResponse,
    options: options
  )
end

#list(request_options: {}) ⇒ Courier::Models::WorkspacePreferenceListResponse

List the workspace's preferences. Each workspace preference embeds its topics. Scoped to the workspace of the API key.

Parameters:

Returns:

See Also:



69
70
71
72
73
74
75
76
# File 'lib/courier/resources/workspace_preferences.rb', line 69

def list(params = {})
  @client.request(
    method: :get,
    path: "preferences/sections",
    model: Courier::WorkspacePreferenceListResponse,
    options: params[:request_options]
  )
end

#publish(brand_id: nil, description: nil, heading: nil, request_options: {}) ⇒ Courier::Models::PublishPreferencesResponse

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

Publish the workspace's preferences page. Takes a snapshot of every workspace preference with its topics under a new published version, making the current state visible on the hosted preferences page (non-draft).

Parameters:

  • brand_id (String, nil)

    Brand for the hosted page - "default" (workspace default brand), "none" (no bran

  • description (String, nil)

    Description shown under the heading on the hosted preferences page.

  • heading (String, nil)

    Heading shown at the top of the hosted preferences page.

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

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
# File 'lib/courier/resources/workspace_preferences.rb', line 119

def publish(params = {})
  parsed, options = Courier::WorkspacePreferencePublishParams.dump_request(params)
  @client.request(
    method: :post,
    path: "preferences/publish",
    body: parsed,
    model: Courier::PublishPreferencesResponse,
    options: options
  )
end

#replace(section_id, name:, description: nil, has_custom_routing: nil, routing_options: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse

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

Replace a workspace preference. Full document replacement; missing optional fields are cleared. Topics attached to the workspace preference are unaffected.

Parameters:

  • section_id (String)

    Id of the workspace preference.

  • name (String)

    Human-readable name for the workspace preference.

  • description (String, nil)

    Optional description shown under the section on the hosted preferences page. Omi

  • has_custom_routing (Boolean, nil)

    Whether the workspace preference defines custom routing for its topics.

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

    Default channels for the workspace preference. Omit to clear.

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

Returns:

See Also:



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

def replace(section_id, params)
  parsed, options = Courier::WorkspacePreferenceReplaceParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["preferences/sections/%1$s", section_id],
    body: parsed,
    model: Courier::WorkspacePreferenceGetResponse,
    options: options
  )
end

#retrieve(section_id, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse

Retrieve a workspace preference by id, including its topics.

Parameters:

  • section_id (String)

    Id of the workspace preference.

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

Returns:

See Also:



50
51
52
53
54
55
56
57
# File 'lib/courier/resources/workspace_preferences.rb', line 50

def retrieve(section_id, params = {})
  @client.request(
    method: :get,
    path: ["preferences/sections/%1$s", section_id],
    model: Courier::WorkspacePreferenceGetResponse,
    options: params[:request_options]
  )
end