trycourier 4.16.0 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/courier/client.rb +4 -0
  4. data/lib/courier/models/preference_section_archive_params.rb +20 -0
  5. data/lib/courier/models/preference_section_create_params.rb +14 -0
  6. data/lib/courier/models/preference_section_create_request.rb +36 -0
  7. data/lib/courier/models/preference_section_get_response.rb +83 -0
  8. data/lib/courier/models/preference_section_list_params.rb +14 -0
  9. data/lib/courier/models/preference_section_list_response.rb +18 -0
  10. data/lib/courier/models/preference_section_publish_params.rb +14 -0
  11. data/lib/courier/models/preference_section_replace_params.rb +20 -0
  12. data/lib/courier/models/preference_section_replace_request.rb +37 -0
  13. data/lib/courier/models/preference_section_retrieve_params.rb +20 -0
  14. data/lib/courier/models/preference_sections/topic_archive_params.rb +28 -0
  15. data/lib/courier/models/preference_sections/topic_create_params.rb +22 -0
  16. data/lib/courier/models/preference_sections/topic_list_params.rb +22 -0
  17. data/lib/courier/models/preference_sections/topic_replace_params.rb +28 -0
  18. data/lib/courier/models/preference_sections/topic_retrieve_params.rb +28 -0
  19. data/lib/courier/models/preference_topic_create_request.rb +93 -0
  20. data/lib/courier/models/preference_topic_get_response.rb +124 -0
  21. data/lib/courier/models/preference_topic_list_response.rb +17 -0
  22. data/lib/courier/models/preference_topic_replace_request.rb +90 -0
  23. data/lib/courier/models/publish_preferences_response.rb +51 -0
  24. data/lib/courier/models.rb +32 -0
  25. data/lib/courier/resources/preference_sections/topics.rb +173 -0
  26. data/lib/courier/resources/preference_sections.rb +155 -0
  27. data/lib/courier/version.rb +1 -1
  28. data/lib/courier.rb +22 -0
  29. data/rbi/courier/client.rbi +3 -0
  30. data/rbi/courier/models/preference_section_archive_params.rbi +38 -0
  31. data/rbi/courier/models/preference_section_create_params.rbi +30 -0
  32. data/rbi/courier/models/preference_section_create_request.rbi +61 -0
  33. data/rbi/courier/models/preference_section_get_response.rbi +106 -0
  34. data/rbi/courier/models/preference_section_list_params.rbi +30 -0
  35. data/rbi/courier/models/preference_section_list_response.rbi +35 -0
  36. data/rbi/courier/models/preference_section_publish_params.rbi +30 -0
  37. data/rbi/courier/models/preference_section_replace_params.rbi +38 -0
  38. data/rbi/courier/models/preference_section_replace_request.rbi +62 -0
  39. data/rbi/courier/models/preference_section_retrieve_params.rbi +38 -0
  40. data/rbi/courier/models/preference_sections/topic_archive_params.rbi +48 -0
  41. data/rbi/courier/models/preference_sections/topic_create_params.rbi +40 -0
  42. data/rbi/courier/models/preference_sections/topic_list_params.rbi +40 -0
  43. data/rbi/courier/models/preference_sections/topic_replace_params.rbi +48 -0
  44. data/rbi/courier/models/preference_sections/topic_retrieve_params.rbi +48 -0
  45. data/rbi/courier/models/preference_topic_create_request.rbi +181 -0
  46. data/rbi/courier/models/preference_topic_get_response.rbi +209 -0
  47. data/rbi/courier/models/preference_topic_list_response.rbi +35 -0
  48. data/rbi/courier/models/preference_topic_replace_request.rbi +180 -0
  49. data/rbi/courier/models/publish_preferences_response.rbi +70 -0
  50. data/rbi/courier/models.rbi +38 -0
  51. data/rbi/courier/resources/preference_sections/topics.rbi +149 -0
  52. data/rbi/courier/resources/preference_sections.rbi +113 -0
  53. data/sig/courier/client.rbs +2 -0
  54. data/sig/courier/models/preference_section_archive_params.rbs +23 -0
  55. data/sig/courier/models/preference_section_create_params.rbs +15 -0
  56. data/sig/courier/models/preference_section_create_request.rbs +30 -0
  57. data/sig/courier/models/preference_section_get_response.rbs +60 -0
  58. data/sig/courier/models/preference_section_list_params.rbs +15 -0
  59. data/sig/courier/models/preference_section_list_response.rbs +18 -0
  60. data/sig/courier/models/preference_section_publish_params.rbs +15 -0
  61. data/sig/courier/models/preference_section_replace_params.rbs +25 -0
  62. data/sig/courier/models/preference_section_replace_request.rbs +30 -0
  63. data/sig/courier/models/preference_section_retrieve_params.rbs +23 -0
  64. data/sig/courier/models/preference_sections/topic_archive_params.rbs +30 -0
  65. data/sig/courier/models/preference_sections/topic_create_params.rbs +27 -0
  66. data/sig/courier/models/preference_sections/topic_list_params.rbs +25 -0
  67. data/sig/courier/models/preference_sections/topic_replace_params.rbs +34 -0
  68. data/sig/courier/models/preference_sections/topic_retrieve_params.rbs +30 -0
  69. data/sig/courier/models/preference_topic_create_request.rbs +68 -0
  70. data/sig/courier/models/preference_topic_get_response.rbs +93 -0
  71. data/sig/courier/models/preference_topic_list_response.rbs +16 -0
  72. data/sig/courier/models/preference_topic_replace_request.rbs +68 -0
  73. data/sig/courier/models/publish_preferences_response.rbs +40 -0
  74. data/sig/courier/models.rbs +32 -0
  75. data/sig/courier/resources/preference_sections/topics.rbs +49 -0
  76. data/sig/courier/resources/preference_sections.rbs +42 -0
  77. metadata +68 -2
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ class PreferenceTopicGetResponse < Courier::Internal::Type::BaseModel
6
+ # @!attribute id
7
+ # The preference topic id.
8
+ #
9
+ # @return [String]
10
+ required :id, String
11
+
12
+ # @!attribute allowed_preferences
13
+ # Preference controls a recipient may customize. May be empty.
14
+ #
15
+ # @return [Array<Symbol, Courier::Models::PreferenceTopicGetResponse::AllowedPreference>]
16
+ required :allowed_preferences,
17
+ -> { Courier::Internal::Type::ArrayOf[enum: Courier::PreferenceTopicGetResponse::AllowedPreference] }
18
+
19
+ # @!attribute created
20
+ # ISO-8601 timestamp of when the topic was created.
21
+ #
22
+ # @return [String]
23
+ required :created, String
24
+
25
+ # @!attribute default_status
26
+ # The default subscription status applied when a recipient has not set their own.
27
+ #
28
+ # @return [Symbol, Courier::Models::PreferenceTopicGetResponse::DefaultStatus]
29
+ required :default_status, enum: -> { Courier::PreferenceTopicGetResponse::DefaultStatus }
30
+
31
+ # @!attribute include_unsubscribe_header
32
+ # Whether a list-unsubscribe header is included on emails for this topic.
33
+ #
34
+ # @return [Boolean]
35
+ required :include_unsubscribe_header, Courier::Internal::Type::Boolean
36
+
37
+ # @!attribute name
38
+ # Human-readable name.
39
+ #
40
+ # @return [String]
41
+ required :name, String
42
+
43
+ # @!attribute routing_options
44
+ # Default channels delivered for this topic. May be empty.
45
+ #
46
+ # @return [Array<Symbol, Courier::Models::ChannelClassification>]
47
+ required :routing_options, -> { Courier::Internal::Type::ArrayOf[enum: Courier::ChannelClassification] }
48
+
49
+ # @!attribute topic_data
50
+ # Arbitrary metadata associated with the topic.
51
+ #
52
+ # @return [Hash{Symbol=>Object}]
53
+ required :topic_data, Courier::Internal::Type::HashOf[Courier::Internal::Type::Unknown]
54
+
55
+ # @!attribute updated
56
+ # ISO-8601 timestamp of the last update.
57
+ #
58
+ # @return [String]
59
+ required :updated, String
60
+
61
+ # @!attribute creator
62
+ # Id of the creator.
63
+ #
64
+ # @return [String, nil]
65
+ optional :creator, String, nil?: true
66
+
67
+ # @!attribute updater
68
+ # Id of the last updater.
69
+ #
70
+ # @return [String, nil]
71
+ optional :updater, String, nil?: true
72
+
73
+ # @!method initialize(id:, allowed_preferences:, created:, default_status:, include_unsubscribe_header:, name:, routing_options:, topic_data:, updated:, creator: nil, updater: nil)
74
+ # A subscription preference topic in your workspace.
75
+ #
76
+ # @param id [String] The preference topic id.
77
+ #
78
+ # @param allowed_preferences [Array<Symbol, Courier::Models::PreferenceTopicGetResponse::AllowedPreference>] Preference controls a recipient may customize. May be empty.
79
+ #
80
+ # @param created [String] ISO-8601 timestamp of when the topic was created.
81
+ #
82
+ # @param default_status [Symbol, Courier::Models::PreferenceTopicGetResponse::DefaultStatus] The default subscription status applied when a recipient has not set their own.
83
+ #
84
+ # @param include_unsubscribe_header [Boolean] Whether a list-unsubscribe header is included on emails for this topic.
85
+ #
86
+ # @param name [String] Human-readable name.
87
+ #
88
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>] Default channels delivered for this topic. May be empty.
89
+ #
90
+ # @param topic_data [Hash{Symbol=>Object}] Arbitrary metadata associated with the topic.
91
+ #
92
+ # @param updated [String] ISO-8601 timestamp of the last update.
93
+ #
94
+ # @param creator [String, nil] Id of the creator.
95
+ #
96
+ # @param updater [String, nil] Id of the last updater.
97
+
98
+ # A preference control a recipient may customize for a topic.
99
+ module AllowedPreference
100
+ extend Courier::Internal::Type::Enum
101
+
102
+ SNOOZE = :snooze
103
+ CHANNEL_PREFERENCES = :channel_preferences
104
+
105
+ # @!method self.values
106
+ # @return [Array<Symbol>]
107
+ end
108
+
109
+ # The default subscription status applied when a recipient has not set their own.
110
+ #
111
+ # @see Courier::Models::PreferenceTopicGetResponse#default_status
112
+ module DefaultStatus
113
+ extend Courier::Internal::Type::Enum
114
+
115
+ OPTED_OUT = :OPTED_OUT
116
+ OPTED_IN = :OPTED_IN
117
+ REQUIRED = :REQUIRED
118
+
119
+ # @!method self.values
120
+ # @return [Array<Symbol>]
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ class PreferenceTopicListResponse < Courier::Internal::Type::BaseModel
6
+ # @!attribute results
7
+ #
8
+ # @return [Array<Courier::Models::PreferenceTopicGetResponse>]
9
+ required :results, -> { Courier::Internal::Type::ArrayOf[Courier::PreferenceTopicGetResponse] }
10
+
11
+ # @!method initialize(results:)
12
+ # Topics contained in a preference section.
13
+ #
14
+ # @param results [Array<Courier::Models::PreferenceTopicGetResponse>]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ class PreferenceTopicReplaceRequest < Courier::Internal::Type::BaseModel
6
+ # @!attribute default_status
7
+ # The default subscription status applied when a recipient has not set their own.
8
+ #
9
+ # @return [Symbol, Courier::Models::PreferenceTopicReplaceRequest::DefaultStatus]
10
+ required :default_status, enum: -> { Courier::PreferenceTopicReplaceRequest::DefaultStatus }
11
+
12
+ # @!attribute name
13
+ # Human-readable name for the preference topic.
14
+ #
15
+ # @return [String]
16
+ required :name, String
17
+
18
+ # @!attribute allowed_preferences
19
+ # Preference controls a recipient may customize. Omit to clear.
20
+ #
21
+ # @return [Array<Symbol, Courier::Models::PreferenceTopicReplaceRequest::AllowedPreference>, nil]
22
+ optional :allowed_preferences,
23
+ -> {
24
+ Courier::Internal::Type::ArrayOf[enum: Courier::PreferenceTopicReplaceRequest::AllowedPreference]
25
+ },
26
+ nil?: true
27
+
28
+ # @!attribute include_unsubscribe_header
29
+ # Whether to include a list-unsubscribe header on emails for this topic.
30
+ #
31
+ # @return [Boolean, nil]
32
+ optional :include_unsubscribe_header, Courier::Internal::Type::Boolean, nil?: true
33
+
34
+ # @!attribute routing_options
35
+ # Default channels delivered for this topic. Omit to clear.
36
+ #
37
+ # @return [Array<Symbol, Courier::Models::ChannelClassification>, nil]
38
+ optional :routing_options,
39
+ -> { Courier::Internal::Type::ArrayOf[enum: Courier::ChannelClassification] },
40
+ nil?: true
41
+
42
+ # @!attribute topic_data
43
+ # Arbitrary metadata associated with the topic. Omit to clear.
44
+ #
45
+ # @return [Hash{Symbol=>Object}, nil]
46
+ optional :topic_data, Courier::Internal::Type::HashOf[Courier::Internal::Type::Unknown], nil?: true
47
+
48
+ # @!method initialize(default_status:, name:, allowed_preferences: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil)
49
+ # Request body for replacing a preference topic. Full document replacement;
50
+ # missing optional fields are cleared.
51
+ #
52
+ # @param default_status [Symbol, Courier::Models::PreferenceTopicReplaceRequest::DefaultStatus] The default subscription status applied when a recipient has not set their own.
53
+ #
54
+ # @param name [String] Human-readable name for the preference topic.
55
+ #
56
+ # @param allowed_preferences [Array<Symbol, Courier::Models::PreferenceTopicReplaceRequest::AllowedPreference>, nil] Preference controls a recipient may customize. Omit to clear.
57
+ #
58
+ # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic.
59
+ #
60
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels delivered for this topic. Omit to clear.
61
+ #
62
+ # @param topic_data [Hash{Symbol=>Object}, nil] Arbitrary metadata associated with the topic. Omit to clear.
63
+
64
+ # The default subscription status applied when a recipient has not set their own.
65
+ #
66
+ # @see Courier::Models::PreferenceTopicReplaceRequest#default_status
67
+ module DefaultStatus
68
+ extend Courier::Internal::Type::Enum
69
+
70
+ OPTED_OUT = :OPTED_OUT
71
+ OPTED_IN = :OPTED_IN
72
+ REQUIRED = :REQUIRED
73
+
74
+ # @!method self.values
75
+ # @return [Array<Symbol>]
76
+ end
77
+
78
+ # A preference control a recipient may customize for a topic.
79
+ module AllowedPreference
80
+ extend Courier::Internal::Type::Enum
81
+
82
+ SNOOZE = :snooze
83
+ CHANNEL_PREFERENCES = :channel_preferences
84
+
85
+ # @!method self.values
86
+ # @return [Array<Symbol>]
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::PreferenceSections#publish
6
+ class PublishPreferencesResponse < Courier::Internal::Type::BaseModel
7
+ # @!attribute page_id
8
+ # Id of the published page snapshot.
9
+ #
10
+ # @return [String]
11
+ required :page_id, String
12
+
13
+ # @!attribute published_at
14
+ # ISO-8601 timestamp of the publish.
15
+ #
16
+ # @return [String]
17
+ required :published_at, String
18
+
19
+ # @!attribute published_version
20
+ # Monotonic published version (epoch milliseconds).
21
+ #
22
+ # @return [Float]
23
+ required :published_version, Float
24
+
25
+ # @!attribute preview_url
26
+ # Draft-mode hosted preferences page URL for previewing.
27
+ #
28
+ # @return [String, nil]
29
+ optional :preview_url, String, nil?: true
30
+
31
+ # @!attribute published_by
32
+ # Id of the publisher.
33
+ #
34
+ # @return [String, nil]
35
+ optional :published_by, String, nil?: true
36
+
37
+ # @!method initialize(page_id:, published_at:, published_version:, preview_url: nil, published_by: nil)
38
+ # Result of publishing the workspace's preferences page.
39
+ #
40
+ # @param page_id [String] Id of the published page snapshot.
41
+ #
42
+ # @param published_at [String] ISO-8601 timestamp of the publish.
43
+ #
44
+ # @param published_version [Float] Monotonic published version (epoch milliseconds).
45
+ #
46
+ # @param preview_url [String, nil] Draft-mode hosted preferences page URL for previewing.
47
+ #
48
+ # @param published_by [String, nil] Id of the publisher.
49
+ end
50
+ end
51
+ end
@@ -404,8 +404,38 @@ module Courier
404
404
 
405
405
  Preference = Courier::Models::Preference
406
406
 
407
+ PreferenceSectionArchiveParams = Courier::Models::PreferenceSectionArchiveParams
408
+
409
+ PreferenceSectionCreateParams = Courier::Models::PreferenceSectionCreateParams
410
+
411
+ PreferenceSectionCreateRequest = Courier::Models::PreferenceSectionCreateRequest
412
+
413
+ PreferenceSectionGetResponse = Courier::Models::PreferenceSectionGetResponse
414
+
415
+ PreferenceSectionListParams = Courier::Models::PreferenceSectionListParams
416
+
417
+ PreferenceSectionListResponse = Courier::Models::PreferenceSectionListResponse
418
+
419
+ PreferenceSectionPublishParams = Courier::Models::PreferenceSectionPublishParams
420
+
421
+ PreferenceSectionReplaceParams = Courier::Models::PreferenceSectionReplaceParams
422
+
423
+ PreferenceSectionReplaceRequest = Courier::Models::PreferenceSectionReplaceRequest
424
+
425
+ PreferenceSectionRetrieveParams = Courier::Models::PreferenceSectionRetrieveParams
426
+
427
+ PreferenceSections = Courier::Models::PreferenceSections
428
+
407
429
  PreferenceStatus = Courier::Models::PreferenceStatus
408
430
 
431
+ PreferenceTopicCreateRequest = Courier::Models::PreferenceTopicCreateRequest
432
+
433
+ PreferenceTopicGetResponse = Courier::Models::PreferenceTopicGetResponse
434
+
435
+ PreferenceTopicListResponse = Courier::Models::PreferenceTopicListResponse
436
+
437
+ PreferenceTopicReplaceRequest = Courier::Models::PreferenceTopicReplaceRequest
438
+
409
439
  ProfileCreateParams = Courier::Models::ProfileCreateParams
410
440
 
411
441
  ProfileDeleteParams = Courier::Models::ProfileDeleteParams
@@ -434,6 +464,8 @@ module Courier
434
464
 
435
465
  ProviderUpdateParams = Courier::Models::ProviderUpdateParams
436
466
 
467
+ PublishPreferencesResponse = Courier::Models::PublishPreferencesResponse
468
+
437
469
  PutSubscriptionsRecipient = Courier::Models::PutSubscriptionsRecipient
438
470
 
439
471
  PutTenantTemplateRequest = Courier::Models::PutTenantTemplateRequest
@@ -0,0 +1,173 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Resources
5
+ class PreferenceSections
6
+ class Topics
7
+ # Some parameter documentations has been truncated, see
8
+ # {Courier::Models::PreferenceSections::TopicCreateParams} for more details.
9
+ #
10
+ # Create a subscription preference topic inside a section. Fails with 404 if the
11
+ # section does not exist. The topic id is generated and returned.
12
+ #
13
+ # @overload create(section_id, default_status:, name:, allowed_preferences: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
14
+ #
15
+ # @param section_id [String] Id of the preference section to create the topic in.
16
+ #
17
+ # @param default_status [Symbol, Courier::Models::PreferenceTopicCreateRequest::DefaultStatus] The default subscription status applied when a recipient has not set their own.
18
+ #
19
+ # @param name [String] Human-readable name for the preference topic.
20
+ #
21
+ # @param allowed_preferences [Array<Symbol, Courier::Models::PreferenceTopicCreateRequest::AllowedPreference>, nil] Preference controls a recipient may customize for this topic. Defaults to empty
22
+ #
23
+ # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic.
24
+ #
25
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels delivered for this topic. Defaults to empty if omitted.
26
+ #
27
+ # @param topic_data [Hash{Symbol=>Object}, nil] Arbitrary metadata associated with the topic.
28
+ #
29
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
30
+ #
31
+ # @return [Courier::Models::PreferenceTopicGetResponse]
32
+ #
33
+ # @see Courier::Models::PreferenceSections::TopicCreateParams
34
+ def create(section_id, params)
35
+ parsed, options = Courier::PreferenceSections::TopicCreateParams.dump_request(params)
36
+ @client.request(
37
+ method: :post,
38
+ path: ["preferences/sections/%1$s/topics", section_id],
39
+ body: parsed,
40
+ model: Courier::PreferenceTopicGetResponse,
41
+ options: options
42
+ )
43
+ end
44
+
45
+ # Retrieve a topic within a section. Returns 404 if the section does not exist,
46
+ # the topic does not exist, or the topic belongs to a different section.
47
+ #
48
+ # @overload retrieve(topic_id, section_id:, request_options: {})
49
+ #
50
+ # @param topic_id [String] Id of the subscription preference topic.
51
+ #
52
+ # @param section_id [String] Id of the preference section.
53
+ #
54
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
55
+ #
56
+ # @return [Courier::Models::PreferenceTopicGetResponse]
57
+ #
58
+ # @see Courier::Models::PreferenceSections::TopicRetrieveParams
59
+ def retrieve(topic_id, params)
60
+ parsed, options = Courier::PreferenceSections::TopicRetrieveParams.dump_request(params)
61
+ section_id =
62
+ parsed.delete(:section_id) do
63
+ raise ArgumentError.new("missing required path argument #{_1}")
64
+ end
65
+ @client.request(
66
+ method: :get,
67
+ path: ["preferences/sections/%1$s/topics/%2$s", section_id, topic_id],
68
+ model: Courier::PreferenceTopicGetResponse,
69
+ options: options
70
+ )
71
+ end
72
+
73
+ # List the topics in a preference section.
74
+ #
75
+ # @overload list(section_id, request_options: {})
76
+ #
77
+ # @param section_id [String] Id of the preference section.
78
+ #
79
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
80
+ #
81
+ # @return [Courier::Models::PreferenceTopicListResponse]
82
+ #
83
+ # @see Courier::Models::PreferenceSections::TopicListParams
84
+ def list(section_id, params = {})
85
+ @client.request(
86
+ method: :get,
87
+ path: ["preferences/sections/%1$s/topics", section_id],
88
+ model: Courier::PreferenceTopicListResponse,
89
+ options: params[:request_options]
90
+ )
91
+ end
92
+
93
+ # Archive a topic and remove it from its section. Same 404 rules as GET.
94
+ #
95
+ # @overload archive(topic_id, section_id:, request_options: {})
96
+ #
97
+ # @param topic_id [String] Id of the subscription preference topic.
98
+ #
99
+ # @param section_id [String] Id of the preference section.
100
+ #
101
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
102
+ #
103
+ # @return [nil]
104
+ #
105
+ # @see Courier::Models::PreferenceSections::TopicArchiveParams
106
+ def archive(topic_id, params)
107
+ parsed, options = Courier::PreferenceSections::TopicArchiveParams.dump_request(params)
108
+ section_id =
109
+ parsed.delete(:section_id) do
110
+ raise ArgumentError.new("missing required path argument #{_1}")
111
+ end
112
+ @client.request(
113
+ method: :delete,
114
+ path: ["preferences/sections/%1$s/topics/%2$s", section_id, topic_id],
115
+ model: NilClass,
116
+ options: options
117
+ )
118
+ end
119
+
120
+ # Some parameter documentations has been truncated, see
121
+ # {Courier::Models::PreferenceSections::TopicReplaceParams} for more details.
122
+ #
123
+ # Replace a topic within a section. Full document replacement; missing optional
124
+ # fields are cleared. Same 404 rules as GET.
125
+ #
126
+ # @overload replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
127
+ #
128
+ # @param topic_id [String] Path param: Id of the subscription preference topic.
129
+ #
130
+ # @param section_id [String] Path param: Id of the preference section.
131
+ #
132
+ # @param default_status [Symbol, Courier::Models::PreferenceTopicReplaceRequest::DefaultStatus] Body param: The default subscription status applied when a recipient has not set
133
+ #
134
+ # @param name [String] Body param: Human-readable name for the preference topic.
135
+ #
136
+ # @param allowed_preferences [Array<Symbol, Courier::Models::PreferenceTopicReplaceRequest::AllowedPreference>, nil] Body param: Preference controls a recipient may customize. Omit to clear.
137
+ #
138
+ # @param include_unsubscribe_header [Boolean, nil] Body param: Whether to include a list-unsubscribe header on emails for this topi
139
+ #
140
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Body param: Default channels delivered for this topic. Omit to clear.
141
+ #
142
+ # @param topic_data [Hash{Symbol=>Object}, nil] Body param: Arbitrary metadata associated with the topic. Omit to clear.
143
+ #
144
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
145
+ #
146
+ # @return [Courier::Models::PreferenceTopicGetResponse]
147
+ #
148
+ # @see Courier::Models::PreferenceSections::TopicReplaceParams
149
+ def replace(topic_id, params)
150
+ parsed, options = Courier::PreferenceSections::TopicReplaceParams.dump_request(params)
151
+ section_id =
152
+ parsed.delete(:section_id) do
153
+ raise ArgumentError.new("missing required path argument #{_1}")
154
+ end
155
+ @client.request(
156
+ method: :put,
157
+ path: ["preferences/sections/%1$s/topics/%2$s", section_id, topic_id],
158
+ body: parsed,
159
+ model: Courier::PreferenceTopicGetResponse,
160
+ options: options
161
+ )
162
+ end
163
+
164
+ # @api private
165
+ #
166
+ # @param client [Courier::Client]
167
+ def initialize(client:)
168
+ @client = client
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,155 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Resources
5
+ class PreferenceSections
6
+ # @return [Courier::Resources::PreferenceSections::Topics]
7
+ attr_reader :topics
8
+
9
+ # Create a preference section in your workspace. The section id is generated and
10
+ # returned. Topics are created inside a section via POST
11
+ # /preferences/sections/{section_id}/topics.
12
+ #
13
+ # @overload create(name:, has_custom_routing: nil, routing_options: nil, request_options: {})
14
+ #
15
+ # @param name [String] Human-readable name for the section.
16
+ #
17
+ # @param has_custom_routing [Boolean, nil] Whether the section defines custom routing for its topics.
18
+ #
19
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels for the section. Defaults to empty if omitted.
20
+ #
21
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
22
+ #
23
+ # @return [Courier::Models::PreferenceSectionGetResponse]
24
+ #
25
+ # @see Courier::Models::PreferenceSectionCreateParams
26
+ def create(params)
27
+ parsed, options = Courier::PreferenceSectionCreateParams.dump_request(params)
28
+ @client.request(
29
+ method: :post,
30
+ path: "preferences/sections",
31
+ body: parsed,
32
+ model: Courier::PreferenceSectionGetResponse,
33
+ options: options
34
+ )
35
+ end
36
+
37
+ # Retrieve a preference section by id, including its topics.
38
+ #
39
+ # @overload retrieve(section_id, request_options: {})
40
+ #
41
+ # @param section_id [String] Id of the preference section.
42
+ #
43
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
44
+ #
45
+ # @return [Courier::Models::PreferenceSectionGetResponse]
46
+ #
47
+ # @see Courier::Models::PreferenceSectionRetrieveParams
48
+ def retrieve(section_id, params = {})
49
+ @client.request(
50
+ method: :get,
51
+ path: ["preferences/sections/%1$s", section_id],
52
+ model: Courier::PreferenceSectionGetResponse,
53
+ options: params[:request_options]
54
+ )
55
+ end
56
+
57
+ # List the workspace's preference sections. Each section embeds its topics. Scoped
58
+ # to the workspace of the API key.
59
+ #
60
+ # @overload list(request_options: {})
61
+ #
62
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
63
+ #
64
+ # @return [Courier::Models::PreferenceSectionListResponse]
65
+ #
66
+ # @see Courier::Models::PreferenceSectionListParams
67
+ def list(params = {})
68
+ @client.request(
69
+ method: :get,
70
+ path: "preferences/sections",
71
+ model: Courier::PreferenceSectionListResponse,
72
+ options: params[:request_options]
73
+ )
74
+ end
75
+
76
+ # Archive a preference section. The section must be empty: delete its topics
77
+ # first, otherwise the request fails with 409.
78
+ #
79
+ # @overload archive(section_id, request_options: {})
80
+ #
81
+ # @param section_id [String] Id of the preference section.
82
+ #
83
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
84
+ #
85
+ # @return [nil]
86
+ #
87
+ # @see Courier::Models::PreferenceSectionArchiveParams
88
+ def archive(section_id, params = {})
89
+ @client.request(
90
+ method: :delete,
91
+ path: ["preferences/sections/%1$s", section_id],
92
+ model: NilClass,
93
+ options: params[:request_options]
94
+ )
95
+ end
96
+
97
+ # Publish the workspace's preferences page. Takes a snapshot of every section with
98
+ # its topics under a new published version, making the current state visible on
99
+ # the hosted preferences page (non-draft).
100
+ #
101
+ # @overload publish(request_options: {})
102
+ #
103
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
104
+ #
105
+ # @return [Courier::Models::PublishPreferencesResponse]
106
+ #
107
+ # @see Courier::Models::PreferenceSectionPublishParams
108
+ def publish(params = {})
109
+ @client.request(
110
+ method: :post,
111
+ path: "preferences/publish",
112
+ model: Courier::PublishPreferencesResponse,
113
+ options: params[:request_options]
114
+ )
115
+ end
116
+
117
+ # Replace a preference section. Full document replacement; missing optional fields
118
+ # are cleared. Topics attached to the section are unaffected.
119
+ #
120
+ # @overload replace(section_id, name:, has_custom_routing: nil, routing_options: nil, request_options: {})
121
+ #
122
+ # @param section_id [String] Id of the preference section.
123
+ #
124
+ # @param name [String] Human-readable name for the section.
125
+ #
126
+ # @param has_custom_routing [Boolean, nil] Whether the section defines custom routing for its topics.
127
+ #
128
+ # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels for the section. Omit to clear.
129
+ #
130
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
131
+ #
132
+ # @return [Courier::Models::PreferenceSectionGetResponse]
133
+ #
134
+ # @see Courier::Models::PreferenceSectionReplaceParams
135
+ def replace(section_id, params)
136
+ parsed, options = Courier::PreferenceSectionReplaceParams.dump_request(params)
137
+ @client.request(
138
+ method: :put,
139
+ path: ["preferences/sections/%1$s", section_id],
140
+ body: parsed,
141
+ model: Courier::PreferenceSectionGetResponse,
142
+ options: options
143
+ )
144
+ end
145
+
146
+ # @api private
147
+ #
148
+ # @param client [Courier::Client]
149
+ def initialize(client:)
150
+ @client = client
151
+ @topics = Courier::Resources::PreferenceSections::Topics.new(client: client)
152
+ end
153
+ end
154
+ end
155
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Courier
4
- VERSION = "4.16.0"
4
+ VERSION = "4.17.0"
5
5
  end