Class: Courier::Resources::WorkspacePreferences
- Inherits:
-
Object
- Object
- Courier::Resources::WorkspacePreferences
- 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
Overview
Manage the workspace catalog of subscription topics, the sections that group them, and publishing the preference page.
Defined Under Namespace
Classes: Topics
Instance Attribute Summary collapse
-
#topics ⇒ Courier::Resources::WorkspacePreferences::Topics
readonly
Manage the workspace catalog of subscription topics, the sections that group them, and publishing the preference page.
Instance Method Summary collapse
-
#archive(section_id, request_options: {}) ⇒ nil
Archive a workspace preference.
-
#create(name:, description: nil, has_custom_routing: nil, routing_options: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferenceCreateParams for more details.
-
#initialize(client:) ⇒ WorkspacePreferences
constructor
private
A new instance of WorkspacePreferences.
-
#list(request_options: {}) ⇒ Courier::Models::WorkspacePreferenceListResponse
Returns the workspace's preferences, each embedding its subscription topics, routing options, and whether custom routing is allowed.
-
#publish(brand_id: nil, description: nil, heading: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::PublishPreferencesResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferencePublishParams for more details.
-
#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.
-
#retrieve(section_id, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse
Returns one workspace preference by id, including its subscription topics, routing options, and custom routing flag.
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.
187 188 189 190 |
# File 'lib/courier/resources/workspace_preferences.rb', line 187 def initialize(client:) @client = client @topics = Courier::Resources::WorkspacePreferences::Topics.new(client: client) end |
Instance Attribute Details
#topics ⇒ Courier::Resources::WorkspacePreferences::Topics (readonly)
Manage the workspace catalog of subscription topics, the sections that group them, and publishing the preference page.
11 12 13 |
# File 'lib/courier/resources/workspace_preferences.rb', line 11 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.
104 105 106 107 108 109 110 111 |
# File 'lib/courier/resources/workspace_preferences.rb', line 104 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, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferenceCreateParams for more details.
Creates a workspace preference and returns its generated id. Add subscription topics to it afterwards with the topics endpoint.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/courier/resources/workspace_preferences.rb', line 38 def create(params) parsed, = Courier::WorkspacePreferenceCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "preferences/sections", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::WorkspacePreferenceGetResponse, options: ) end |
#list(request_options: {}) ⇒ Courier::Models::WorkspacePreferenceListResponse
Returns the workspace's preferences, each embedding its subscription topics, routing options, and whether custom routing is allowed.
83 84 85 86 87 88 89 90 |
# File 'lib/courier/resources/workspace_preferences.rb', line 83 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, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::PublishPreferencesResponse
Some parameter documentations has been truncated, see Models::WorkspacePreferencePublishParams for more details.
Publishes the workspace preference page, snapshotting every preference and topic, and returns the page id and a preview URL.
136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/courier/resources/workspace_preferences.rb', line 136 def publish(params = {}) parsed, = Courier::WorkspacePreferencePublishParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: "preferences/publish", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::PublishPreferencesResponse, 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.
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/courier/resources/workspace_preferences.rb', line 173 def replace(section_id, params) parsed, = Courier::WorkspacePreferenceReplaceParams.dump_request(params) @client.request( method: :put, path: ["preferences/sections/%1$s", section_id], body: parsed, model: Courier::WorkspacePreferenceGetResponse, options: ) end |
#retrieve(section_id, request_options: {}) ⇒ Courier::Models::WorkspacePreferenceGetResponse
Returns one workspace preference by id, including its subscription topics, routing options, and custom routing flag.
64 65 66 67 68 69 70 71 |
# File 'lib/courier/resources/workspace_preferences.rb', line 64 def retrieve(section_id, params = {}) @client.request( method: :get, path: ["preferences/sections/%1$s", section_id], model: Courier::WorkspacePreferenceGetResponse, options: params[:request_options] ) end |