Class: Courier::Resources::PreferenceSections::Topics
- Inherits:
-
Object
- Object
- Courier::Resources::PreferenceSections::Topics
- Defined in:
- lib/courier/resources/preference_sections/topics.rb
Instance Method Summary collapse
-
#archive(topic_id, section_id:, request_options: {}) ⇒ nil
Archive a topic and remove it from its section.
-
#create(section_id, default_status:, name:, allowed_preferences: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {}) ⇒ Courier::Models::PreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::PreferenceSections::TopicCreateParams for more details.
-
#initialize(client:) ⇒ Topics
constructor
private
A new instance of Topics.
-
#list(section_id, request_options: {}) ⇒ Courier::Models::PreferenceTopicListResponse
List the topics in a preference section.
-
#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::PreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::PreferenceSections::TopicReplaceParams for more details.
-
#retrieve(topic_id, section_id:, request_options: {}) ⇒ Courier::Models::PreferenceTopicGetResponse
Retrieve a topic within a section.
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.
167 168 169 |
# File 'lib/courier/resources/preference_sections/topics.rb', line 167 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 section. Same 404 rules as GET.
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/courier/resources/preference_sections/topics.rb', line 106 def archive(topic_id, params) parsed, = Courier::PreferenceSections::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, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {}) ⇒ Courier::Models::PreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::PreferenceSections::TopicCreateParams for more details.
Create a subscription preference topic inside a section. Fails with 404 if the section does not exist. The topic id is generated and returned.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/courier/resources/preference_sections/topics.rb', line 34 def create(section_id, params) parsed, = Courier::PreferenceSections::TopicCreateParams.dump_request(params) @client.request( method: :post, path: ["preferences/sections/%1$s/topics", section_id], body: parsed, model: Courier::PreferenceTopicGetResponse, options: ) end |
#list(section_id, request_options: {}) ⇒ Courier::Models::PreferenceTopicListResponse
List the topics in a preference section.
84 85 86 87 88 89 90 91 |
# File 'lib/courier/resources/preference_sections/topics.rb', line 84 def list(section_id, params = {}) @client.request( method: :get, path: ["preferences/sections/%1$s/topics", section_id], model: Courier::PreferenceTopicListResponse, 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::PreferenceTopicGetResponse
Some parameter documentations has been truncated, see Models::PreferenceSections::TopicReplaceParams for more details.
Replace a topic within a section. Full document replacement; missing optional fields are cleared. Same 404 rules as GET.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/courier/resources/preference_sections/topics.rb', line 149 def replace(topic_id, params) parsed, = Courier::PreferenceSections::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::PreferenceTopicGetResponse, options: ) end |
#retrieve(topic_id, section_id:, request_options: {}) ⇒ Courier::Models::PreferenceTopicGetResponse
Retrieve a topic within a section. Returns 404 if the section does not exist, the topic does not exist, or the topic belongs to a different section.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/courier/resources/preference_sections/topics.rb', line 59 def retrieve(topic_id, params) parsed, = Courier::PreferenceSections::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::PreferenceTopicGetResponse, options: ) end |