surge_api 0.2.0 → 0.2.1

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +12 -63
  4. data/lib/surge_api/internal/transport/pooled_net_requester.rb +30 -24
  5. data/lib/surge_api/internal/util.rb +5 -5
  6. data/lib/surge_api/models/account_create_params.rb +13 -6
  7. data/lib/surge_api/models/account_update_params.rb +13 -6
  8. data/lib/surge_api/models/campaign_create_params.rb +7 -183
  9. data/lib/surge_api/models/campaign_params.rb +228 -0
  10. data/lib/surge_api/models/message_create_params.rb +8 -134
  11. data/lib/surge_api/models/message_params.rb +216 -0
  12. data/lib/surge_api/models.rb +4 -0
  13. data/lib/surge_api/resources/campaigns.rb +7 -18
  14. data/lib/surge_api/resources/messages.rb +7 -12
  15. data/lib/surge_api/version.rb +1 -1
  16. data/lib/surge_api.rb +2 -0
  17. data/rbi/surge_api/models/account_create_params.rbi +19 -8
  18. data/rbi/surge_api/models/account_update_params.rbi +19 -8
  19. data/rbi/surge_api/models/campaign_create_params.rbi +20 -346
  20. data/rbi/surge_api/models/campaign_params.rbi +481 -0
  21. data/rbi/surge_api/models/message_create_params.rbi +24 -243
  22. data/rbi/surge_api/models/message_params.rbi +430 -0
  23. data/rbi/surge_api/models.rbi +4 -0
  24. data/rbi/surge_api/resources/campaigns.rbi +4 -89
  25. data/rbi/surge_api/resources/messages.rbi +5 -22
  26. data/sig/surge_api/models/campaign_create_params.rbs +7 -106
  27. data/sig/surge_api/models/campaign_params.rbs +141 -0
  28. data/sig/surge_api/models/message_create_params.rbs +7 -119
  29. data/sig/surge_api/models/message_params.rbs +189 -0
  30. data/sig/surge_api/models.rbs +4 -0
  31. data/sig/surge_api/resources/campaigns.rbs +1 -9
  32. data/sig/surge_api/resources/messages.rbs +1 -6
  33. metadata +8 -2
@@ -0,0 +1,228 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ # Parameters for creating a new campaign. Either provide full campaign details or
6
+ # import using a TCR ID.
7
+ module CampaignParams
8
+ extend SurgeAPI::Internal::Type::Union
9
+
10
+ # Full campaign details for standard registration through Surge
11
+ variant -> { SurgeAPI::CampaignParams::StandardCampaignParams }
12
+
13
+ # Import an externally registered campaign from The Campaign Registry (TCR)
14
+ variant -> { SurgeAPI::CampaignParams::ExternalCampaignParams }
15
+
16
+ class StandardCampaignParams < SurgeAPI::Internal::Type::BaseModel
17
+ # @!attribute consent_flow
18
+ # A string explaining the method through which end users will opt in to receive
19
+ # messages from the brand. Typically this should include URLs for opt-in forms or
20
+ # screenshots that might be helpful in explaining the flow to someone unfamiliar
21
+ # with the organization's purpose.
22
+ #
23
+ # @return [String]
24
+ required :consent_flow, String
25
+
26
+ # @!attribute description
27
+ # An explanation of the organization's purpose and how it will be using text
28
+ # messaging to accomplish that purpose.
29
+ #
30
+ # @return [String]
31
+ required :description, String
32
+
33
+ # @!attribute message_samples
34
+ # An array of 2-5 strings with examples of the messages that will be sent from
35
+ # this campaign. Typically the first sample should be a compliance message like
36
+ # `You are now opted in to messages from {brand name}. Frequency varies. Msg&data rates apply. Reply STOP to opt out.`
37
+ # These samples don't necessarily need to be the only templates that will be used
38
+ # for the campaign, but they should reflect the purpose of the messages that will
39
+ # be sent. Any variable content can be reflected by wrapping it in square brackets
40
+ # like `[customer name]`.
41
+ #
42
+ # @return [Array<String>]
43
+ required :message_samples, SurgeAPI::Internal::Type::ArrayOf[String]
44
+
45
+ # @!attribute privacy_policy_url
46
+ # The URL of the privacy policy for the brand in question. This may be a shared
47
+ # privacy policy if it's the policy that is displayed to end users when they opt
48
+ # in to messaging.
49
+ #
50
+ # @return [String]
51
+ required :privacy_policy_url, String
52
+
53
+ # @!attribute use_cases
54
+ # A list containing 1-5 types of messages that will be sent with this campaign.
55
+ #
56
+ # The following use cases are typically available to all brands:
57
+ #
58
+ # - `account_notification` - For sending reminders, alerts, and general
59
+ # account-related notifications like booking confirmations or appointment
60
+ # reminders.
61
+ # - `customer_care` - For account support, troubleshooting, and general customer
62
+ # service communication.
63
+ # - `delivery_notification` - For notifying customers about the status of product
64
+ # or service deliveries.
65
+ # - `fraud_alert` - For warning customers about suspicious or potentially
66
+ # fraudulent activity.
67
+ # - `higher_education` - For messaging related to colleges, universities, and
68
+ # school districts outside of K–12.
69
+ # - `marketing` - For promotional or advertising messages intended to market
70
+ # products or services.
71
+ # - `polling_voting` - For conducting surveys, polls, or voting-related messaging.
72
+ # - `public_service_announcement` - For raising awareness about social issues or
73
+ # important public information.
74
+ # - `security_alert` - For alerts related to potential security breaches or
75
+ # compromised systems requiring user action.
76
+ # - `two_factor_authentication` - For sending one-time passwords or verification
77
+ # codes for login or password reset.
78
+ #
79
+ # For access to special use cases not shown here, reach out to support@surge.app.
80
+ #
81
+ # @return [Array<Symbol, SurgeAPI::Models::CampaignParams::StandardCampaignParams::UseCase>]
82
+ required :use_cases,
83
+ -> { SurgeAPI::Internal::Type::ArrayOf[enum: SurgeAPI::CampaignParams::StandardCampaignParams::UseCase] }
84
+
85
+ # @!attribute volume
86
+ # This will be one of the following:
87
+ #
88
+ # - `low` - The campaign will be allowed to send up to 2000 SMS segments to
89
+ # T-Mobile customers each day. In this case your platform will be charged for
90
+ # the setup fee for a low volume number upon receipt of the API request.
91
+ # - `high` - The campaign will be allowed to send up to 200k SMS segments to
92
+ # T-Mobile customers each day, depending on the trust score assigned by The
93
+ # Campaign Registry. Your platform will be charged for the setup fee for a high
94
+ # volume number upon receipt of the API request, and phone numbers will be
95
+ # charged as high volume numbers going forward.
96
+ #
97
+ # @return [Symbol, SurgeAPI::Models::CampaignParams::StandardCampaignParams::Volume]
98
+ required :volume, enum: -> { SurgeAPI::CampaignParams::StandardCampaignParams::Volume }
99
+
100
+ # @!attribute includes
101
+ # A list of properties that this campaign should include. These properties can be
102
+ # any of the following values:
103
+ #
104
+ # - `links` - whether the campaign might send links in messages
105
+ # - `phone_numbers` - whether the campaign might send phone numbers in messages
106
+ # - `age_gated` - whether the campaign contains age gated content (controlled
107
+ # substances or adult content)
108
+ # - `direct_lending` - whether the campaign contains content related to direct
109
+ # lending or other loan arrangements
110
+ #
111
+ # @return [Array<Symbol, SurgeAPI::Models::CampaignParams::StandardCampaignParams::Include>, nil]
112
+ optional :includes,
113
+ -> { SurgeAPI::Internal::Type::ArrayOf[enum: SurgeAPI::CampaignParams::StandardCampaignParams::Include] }
114
+
115
+ # @!attribute link_sample
116
+ # A sample link that might be sent by this campaign. If links from other domains
117
+ # are sent through this campaign, they are much more likely to be filtered by the
118
+ # carriers. If link shortening is enabled for the account, the link shortener URL
119
+ # will be used instead of what is provided. Reach out to support if you would like
120
+ # to disable automatic link shortening.
121
+ #
122
+ # @return [String, nil]
123
+ optional :link_sample, String
124
+
125
+ # @!attribute terms_and_conditions_url
126
+ # The URL of the terms and conditions presented to end users when they opt in to
127
+ # messaging. These terms and conditions may be shared among all of a platform's
128
+ # customers if they're the terms that are presented to end users when they opt in
129
+ # to messaging.
130
+ #
131
+ # @return [String, nil]
132
+ optional :terms_and_conditions_url, String
133
+
134
+ # @!method initialize(consent_flow:, description:, message_samples:, privacy_policy_url:, use_cases:, volume:, includes: nil, link_sample: nil, terms_and_conditions_url: nil)
135
+ # Some parameter documentations has been truncated, see
136
+ # {SurgeAPI::Models::CampaignParams::StandardCampaignParams} for more details.
137
+ #
138
+ # Full campaign details for standard registration through Surge
139
+ #
140
+ # @param consent_flow [String] A string explaining the method through which end users will opt in to receive me
141
+ #
142
+ # @param description [String] An explanation of the organization's purpose and how it will be using text messa
143
+ #
144
+ # @param message_samples [Array<String>] An array of 2-5 strings with examples of the messages that will be sent from thi
145
+ #
146
+ # @param privacy_policy_url [String] The URL of the privacy policy for the brand in question. This may be a shared pr
147
+ #
148
+ # @param use_cases [Array<Symbol, SurgeAPI::Models::CampaignParams::StandardCampaignParams::UseCase>] A list containing 1-5 types of messages that will be sent with this campaign.
149
+ #
150
+ # @param volume [Symbol, SurgeAPI::Models::CampaignParams::StandardCampaignParams::Volume] This will be one of the following:
151
+ #
152
+ # @param includes [Array<Symbol, SurgeAPI::Models::CampaignParams::StandardCampaignParams::Include>] A list of properties that this campaign should include. These properties can be
153
+ #
154
+ # @param link_sample [String] A sample link that might be sent by this campaign. If links from other domains a
155
+ #
156
+ # @param terms_and_conditions_url [String] The URL of the terms and conditions presented to end users when they opt in to m
157
+
158
+ module UseCase
159
+ extend SurgeAPI::Internal::Type::Enum
160
+
161
+ ACCOUNT_NOTIFICATION = :account_notification
162
+ CUSTOMER_CARE = :customer_care
163
+ DELIVERY_NOTIFICATION = :delivery_notification
164
+ FRAUD_ALERT = :fraud_alert
165
+ HIGHER_EDUCATION = :higher_education
166
+ MARKETING = :marketing
167
+ POLLING_VOTING = :polling_voting
168
+ PUBLIC_SERVICE_ANNOUNCEMENT = :public_service_announcement
169
+ SECURITY_ALERT = :security_alert
170
+ TWO_FACTOR_AUTHENTICATION = :two_factor_authentication
171
+
172
+ # @!method self.values
173
+ # @return [Array<Symbol>]
174
+ end
175
+
176
+ # This will be one of the following:
177
+ #
178
+ # - `low` - The campaign will be allowed to send up to 2000 SMS segments to
179
+ # T-Mobile customers each day. In this case your platform will be charged for
180
+ # the setup fee for a low volume number upon receipt of the API request.
181
+ # - `high` - The campaign will be allowed to send up to 200k SMS segments to
182
+ # T-Mobile customers each day, depending on the trust score assigned by The
183
+ # Campaign Registry. Your platform will be charged for the setup fee for a high
184
+ # volume number upon receipt of the API request, and phone numbers will be
185
+ # charged as high volume numbers going forward.
186
+ #
187
+ # @see SurgeAPI::Models::CampaignParams::StandardCampaignParams#volume
188
+ module Volume
189
+ extend SurgeAPI::Internal::Type::Enum
190
+
191
+ HIGH = :high
192
+ LOW = :low
193
+
194
+ # @!method self.values
195
+ # @return [Array<Symbol>]
196
+ end
197
+
198
+ module Include
199
+ extend SurgeAPI::Internal::Type::Enum
200
+
201
+ LINKS = :links
202
+ PHONE_NUMBERS = :phone_numbers
203
+ AGE_GATED = :age_gated
204
+ DIRECT_LENDING = :direct_lending
205
+
206
+ # @!method self.values
207
+ # @return [Array<Symbol>]
208
+ end
209
+ end
210
+
211
+ class ExternalCampaignParams < SurgeAPI::Internal::Type::BaseModel
212
+ # @!attribute tcr_id
213
+ # The Campaign Registry (TCR) ID for the externally registered campaign
214
+ #
215
+ # @return [String]
216
+ required :tcr_id, String
217
+
218
+ # @!method initialize(tcr_id:)
219
+ # Import an externally registered campaign from The Campaign Registry (TCR)
220
+ #
221
+ # @param tcr_id [String] The Campaign Registry (TCR) ID for the externally registered campaign
222
+ end
223
+
224
+ # @!method self.variants
225
+ # @return [Array(SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams)]
226
+ end
227
+ end
228
+ end
@@ -7,147 +7,21 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
- # @!attribute conversation
11
- # Params for selecting or creating a new conversation. Either the id or the
12
- # Contact must be given.
10
+ # @!attribute message_params
11
+ # Payload for creating a message. Either an attachment or the body must be given.
12
+ # You can specify the recipient either using the 'conversation' parameter or the
13
+ # 'to'/'from' parameters, but not both.
13
14
  #
14
- # @return [SurgeAPI::Models::MessageCreateParams::Conversation]
15
- required :conversation, -> { SurgeAPI::MessageCreateParams::Conversation }
15
+ # @return [SurgeAPI::Models::MessageParams::MessageParamsWithConversation, SurgeAPI::Models::MessageParams::SimpleMessageParams]
16
+ required :message_params, union: -> { SurgeAPI::MessageParams }
16
17
 
17
- # @!attribute attachments
18
- #
19
- # @return [Array<SurgeAPI::Models::MessageCreateParams::Attachment>, nil]
20
- optional :attachments, -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageCreateParams::Attachment] }
21
-
22
- # @!attribute body
23
- # The message body.
24
- #
25
- # @return [String, nil]
26
- optional :body, String
27
-
28
- # @!attribute send_at
29
- # An optional datetime for scheduling message up to a couple of months in the
30
- # future.
31
- #
32
- # @return [Time, nil]
33
- optional :send_at, Time
34
-
35
- # @!attribute to
36
- # The recipient's phone number in E.164 format. Cannot be used together with
37
- # 'conversation'.
38
- #
39
- # @return [String]
40
- required :to, String
41
-
42
- # @!attribute from
43
- # The sender's phone number in E.164 format or phone number ID. If omitted, uses
44
- # the account's default phone number. Cannot be used together with 'conversation'.
45
- #
46
- # @return [String, nil]
47
- optional :from, String
48
-
49
- # @!method initialize(conversation:, to:, attachments: nil, body: nil, send_at: nil, from: nil, request_options: {})
18
+ # @!method initialize(message_params:, request_options: {})
50
19
  # Some parameter documentations has been truncated, see
51
20
  # {SurgeAPI::Models::MessageCreateParams} for more details.
52
21
  #
53
- # @param conversation [SurgeAPI::Models::MessageCreateParams::Conversation] Params for selecting or creating a new conversation. Either the id or the Contac
54
- #
55
- # @param to [String] The recipient's phone number in E.164 format. Cannot be used together with 'conv
56
- #
57
- # @param attachments [Array<SurgeAPI::Models::MessageCreateParams::Attachment>]
58
- #
59
- # @param body [String] The message body.
60
- #
61
- # @param send_at [Time] An optional datetime for scheduling message up to a couple of months in the futu
62
- #
63
- # @param from [String] The sender's phone number in E.164 format or phone number ID. If omitted, uses t
22
+ # @param message_params [SurgeAPI::Models::MessageParams::MessageParamsWithConversation, SurgeAPI::Models::MessageParams::SimpleMessageParams] Payload for creating a message. Either an attachment or the body must be given.
64
23
  #
65
24
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
66
-
67
- class Conversation < SurgeAPI::Internal::Type::BaseModel
68
- # @!attribute contact
69
- # Parameters for creating a contact
70
- #
71
- # @return [SurgeAPI::Models::MessageCreateParams::Conversation::Contact]
72
- required :contact, -> { SurgeAPI::MessageCreateParams::Conversation::Contact }
73
-
74
- # @!attribute phone_number
75
- # The phone number from which to send the message. This can be either the phone
76
- # number in E.164 format or a Surge phone number id.
77
- #
78
- # @return [String, nil]
79
- optional :phone_number, String
80
-
81
- # @!method initialize(contact:, phone_number: nil)
82
- # Some parameter documentations has been truncated, see
83
- # {SurgeAPI::Models::MessageCreateParams::Conversation} for more details.
84
- #
85
- # Params for selecting or creating a new conversation. Either the id or the
86
- # Contact must be given.
87
- #
88
- # @param contact [SurgeAPI::Models::MessageCreateParams::Conversation::Contact] Parameters for creating a contact
89
- #
90
- # @param phone_number [String] The phone number from which to send the message. This can be either the phone nu
91
-
92
- # @see SurgeAPI::Models::MessageCreateParams::Conversation#contact
93
- class Contact < SurgeAPI::Internal::Type::BaseModel
94
- # @!attribute phone_number
95
- # The contact's phone number in E.164 format.
96
- #
97
- # @return [String]
98
- required :phone_number, String
99
-
100
- # @!attribute email
101
- # The contact's email address.
102
- #
103
- # @return [String, nil]
104
- optional :email, String
105
-
106
- # @!attribute first_name
107
- # The contact's first name.
108
- #
109
- # @return [String, nil]
110
- optional :first_name, String
111
-
112
- # @!attribute last_name
113
- # The contact's last name.
114
- #
115
- # @return [String, nil]
116
- optional :last_name, String
117
-
118
- # @!attribute metadata
119
- # Set of key-value pairs that will be stored with the object.
120
- #
121
- # @return [Hash{Symbol=>String}, nil]
122
- optional :metadata, SurgeAPI::Internal::Type::HashOf[String]
123
-
124
- # @!method initialize(phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil)
125
- # Parameters for creating a contact
126
- #
127
- # @param phone_number [String] The contact's phone number in E.164 format.
128
- #
129
- # @param email [String] The contact's email address.
130
- #
131
- # @param first_name [String] The contact's first name.
132
- #
133
- # @param last_name [String] The contact's last name.
134
- #
135
- # @param metadata [Hash{Symbol=>String}] Set of key-value pairs that will be stored with the object.
136
- end
137
- end
138
-
139
- class Attachment < SurgeAPI::Internal::Type::BaseModel
140
- # @!attribute url
141
- # The URL of the attachment.
142
- #
143
- # @return [String]
144
- required :url, String
145
-
146
- # @!method initialize(url:)
147
- # Params for creating an attachment
148
- #
149
- # @param url [String] The URL of the attachment.
150
- end
151
25
  end
152
26
  end
153
27
  end
@@ -0,0 +1,216 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ # Payload for creating a message. Either an attachment or the body must be given.
6
+ # You can specify the recipient either using the 'conversation' parameter or the
7
+ # 'to'/'from' parameters, but not both.
8
+ module MessageParams
9
+ extend SurgeAPI::Internal::Type::Union
10
+
11
+ # Create a message while including parameters for the conversation in which the message should be sent.
12
+ variant -> { SurgeAPI::MessageParams::MessageParamsWithConversation }
13
+
14
+ # Create a basic message by specifying just the to/from phone numbers.
15
+ variant -> { SurgeAPI::MessageParams::SimpleMessageParams }
16
+
17
+ class MessageParamsWithConversation < SurgeAPI::Internal::Type::BaseModel
18
+ # @!attribute conversation
19
+ # Params for selecting or creating a new conversation. Either the id or the
20
+ # Contact must be given.
21
+ #
22
+ # @return [SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Conversation]
23
+ required :conversation, -> { SurgeAPI::MessageParams::MessageParamsWithConversation::Conversation }
24
+
25
+ # @!attribute attachments
26
+ #
27
+ # @return [Array<SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Attachment>, nil]
28
+ optional :attachments,
29
+ -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageParams::MessageParamsWithConversation::Attachment] }
30
+
31
+ # @!attribute body
32
+ # The message body.
33
+ #
34
+ # @return [String, nil]
35
+ optional :body, String
36
+
37
+ # @!attribute send_at
38
+ # An optional datetime for scheduling message up to a couple of months in the
39
+ # future.
40
+ #
41
+ # @return [Time, nil]
42
+ optional :send_at, Time
43
+
44
+ # @!method initialize(conversation:, attachments: nil, body: nil, send_at: nil)
45
+ # Some parameter documentations has been truncated, see
46
+ # {SurgeAPI::Models::MessageParams::MessageParamsWithConversation} for more
47
+ # details.
48
+ #
49
+ # Create a message while including parameters for the conversation in which the
50
+ # message should be sent.
51
+ #
52
+ # @param conversation [SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Conversation] Params for selecting or creating a new conversation. Either the id or the Contac
53
+ #
54
+ # @param attachments [Array<SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Attachment>]
55
+ #
56
+ # @param body [String] The message body.
57
+ #
58
+ # @param send_at [Time] An optional datetime for scheduling message up to a couple of months in the futu
59
+
60
+ # @see SurgeAPI::Models::MessageParams::MessageParamsWithConversation#conversation
61
+ class Conversation < SurgeAPI::Internal::Type::BaseModel
62
+ # @!attribute contact
63
+ # Parameters for creating a contact
64
+ #
65
+ # @return [SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Conversation::Contact]
66
+ required :contact, -> { SurgeAPI::MessageParams::MessageParamsWithConversation::Conversation::Contact }
67
+
68
+ # @!attribute phone_number
69
+ # The phone number from which to send the message. This can be either the phone
70
+ # number in E.164 format or a Surge phone number id.
71
+ #
72
+ # @return [String, nil]
73
+ optional :phone_number, String
74
+
75
+ # @!method initialize(contact:, phone_number: nil)
76
+ # Some parameter documentations has been truncated, see
77
+ # {SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Conversation}
78
+ # for more details.
79
+ #
80
+ # Params for selecting or creating a new conversation. Either the id or the
81
+ # Contact must be given.
82
+ #
83
+ # @param contact [SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Conversation::Contact] Parameters for creating a contact
84
+ #
85
+ # @param phone_number [String] The phone number from which to send the message. This can be either the phone nu
86
+
87
+ # @see SurgeAPI::Models::MessageParams::MessageParamsWithConversation::Conversation#contact
88
+ class Contact < SurgeAPI::Internal::Type::BaseModel
89
+ # @!attribute phone_number
90
+ # The contact's phone number in E.164 format.
91
+ #
92
+ # @return [String]
93
+ required :phone_number, String
94
+
95
+ # @!attribute email
96
+ # The contact's email address.
97
+ #
98
+ # @return [String, nil]
99
+ optional :email, String
100
+
101
+ # @!attribute first_name
102
+ # The contact's first name.
103
+ #
104
+ # @return [String, nil]
105
+ optional :first_name, String
106
+
107
+ # @!attribute last_name
108
+ # The contact's last name.
109
+ #
110
+ # @return [String, nil]
111
+ optional :last_name, String
112
+
113
+ # @!attribute metadata
114
+ # Set of key-value pairs that will be stored with the object.
115
+ #
116
+ # @return [Hash{Symbol=>String}, nil]
117
+ optional :metadata, SurgeAPI::Internal::Type::HashOf[String]
118
+
119
+ # @!method initialize(phone_number:, email: nil, first_name: nil, last_name: nil, metadata: nil)
120
+ # Parameters for creating a contact
121
+ #
122
+ # @param phone_number [String] The contact's phone number in E.164 format.
123
+ #
124
+ # @param email [String] The contact's email address.
125
+ #
126
+ # @param first_name [String] The contact's first name.
127
+ #
128
+ # @param last_name [String] The contact's last name.
129
+ #
130
+ # @param metadata [Hash{Symbol=>String}] Set of key-value pairs that will be stored with the object.
131
+ end
132
+ end
133
+
134
+ class Attachment < SurgeAPI::Internal::Type::BaseModel
135
+ # @!attribute url
136
+ # The URL of the attachment.
137
+ #
138
+ # @return [String]
139
+ required :url, String
140
+
141
+ # @!method initialize(url:)
142
+ # Params for creating an attachment
143
+ #
144
+ # @param url [String] The URL of the attachment.
145
+ end
146
+ end
147
+
148
+ class SimpleMessageParams < SurgeAPI::Internal::Type::BaseModel
149
+ # @!attribute to
150
+ # The recipient's phone number in E.164 format. Cannot be used together with
151
+ # 'conversation'.
152
+ #
153
+ # @return [String]
154
+ required :to, String
155
+
156
+ # @!attribute attachments
157
+ #
158
+ # @return [Array<SurgeAPI::Models::MessageParams::SimpleMessageParams::Attachment>, nil]
159
+ optional :attachments,
160
+ -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageParams::SimpleMessageParams::Attachment] }
161
+
162
+ # @!attribute body
163
+ # The message body.
164
+ #
165
+ # @return [String, nil]
166
+ optional :body, String
167
+
168
+ # @!attribute from
169
+ # The sender's phone number in E.164 format or phone number ID. If omitted, uses
170
+ # the account's default phone number. Cannot be used together with 'conversation'.
171
+ #
172
+ # @return [String, nil]
173
+ optional :from, String
174
+
175
+ # @!attribute send_at
176
+ # An optional datetime for scheduling message up to a couple of months in the
177
+ # future.
178
+ #
179
+ # @return [Time, nil]
180
+ optional :send_at, Time
181
+
182
+ # @!method initialize(to:, attachments: nil, body: nil, from: nil, send_at: nil)
183
+ # Some parameter documentations has been truncated, see
184
+ # {SurgeAPI::Models::MessageParams::SimpleMessageParams} for more details.
185
+ #
186
+ # Create a basic message by specifying just the to/from phone numbers.
187
+ #
188
+ # @param to [String] The recipient's phone number in E.164 format. Cannot be used together with 'conv
189
+ #
190
+ # @param attachments [Array<SurgeAPI::Models::MessageParams::SimpleMessageParams::Attachment>]
191
+ #
192
+ # @param body [String] The message body.
193
+ #
194
+ # @param from [String] The sender's phone number in E.164 format or phone number ID. If omitted, uses t
195
+ #
196
+ # @param send_at [Time] An optional datetime for scheduling message up to a couple of months in the futu
197
+
198
+ class Attachment < SurgeAPI::Internal::Type::BaseModel
199
+ # @!attribute url
200
+ # The URL of the attachment.
201
+ #
202
+ # @return [String]
203
+ required :url, String
204
+
205
+ # @!method initialize(url:)
206
+ # Params for creating an attachment
207
+ #
208
+ # @param url [String] The URL of the attachment.
209
+ end
210
+ end
211
+
212
+ # @!method self.variants
213
+ # @return [Array(SurgeAPI::Models::MessageParams::MessageParamsWithConversation, SurgeAPI::Models::MessageParams::SimpleMessageParams)]
214
+ end
215
+ end
216
+ end
@@ -61,6 +61,8 @@ module SurgeAPI
61
61
 
62
62
  CampaignCreateParams = SurgeAPI::Models::CampaignCreateParams
63
63
 
64
+ CampaignParams = SurgeAPI::Models::CampaignParams
65
+
64
66
  Contact = SurgeAPI::Models::Contact
65
67
 
66
68
  ContactCreateParams = SurgeAPI::Models::ContactCreateParams
@@ -85,6 +87,8 @@ module SurgeAPI
85
87
 
86
88
  MessageFailedWebhookEvent = SurgeAPI::Models::MessageFailedWebhookEvent
87
89
 
90
+ MessageParams = SurgeAPI::Models::MessageParams
91
+
88
92
  MessageReceivedWebhookEvent = SurgeAPI::Models::MessageReceivedWebhookEvent
89
93
 
90
94
  MessageSentWebhookEvent = SurgeAPI::Models::MessageSentWebhookEvent
@@ -8,27 +8,11 @@ module SurgeAPI
8
8
  #
9
9
  # Creates a campaign to register account to send text messages.
10
10
  #
11
- # @overload create(account_id, consent_flow:, description:, message_samples:, privacy_policy_url:, use_cases:, volume:, includes: nil, link_sample: nil, terms_and_conditions_url: nil, request_options: {})
11
+ # @overload create(account_id, campaign_params:, request_options: {})
12
12
  #
13
13
  # @param account_id [String] The account for which the campaign should be created.
14
14
  #
15
- # @param consent_flow [String] A string explaining the method through which end users will opt in to receive me
16
- #
17
- # @param description [String] An explanation of the organization's purpose and how it will be using text messa
18
- #
19
- # @param message_samples [Array<String>] An array of 2-5 strings with examples of the messages that will be sent from thi
20
- #
21
- # @param privacy_policy_url [String] The URL of the privacy policy for the brand in question. This may be a shared pr
22
- #
23
- # @param use_cases [Array<Symbol, SurgeAPI::Models::CampaignCreateParams::UseCase>] A list containing 1-5 types of messages that will be sent with this campaign.
24
- #
25
- # @param volume [Symbol, SurgeAPI::Models::CampaignCreateParams::Volume] This will be one of the following:
26
- #
27
- # @param includes [Array<Symbol, SurgeAPI::Models::CampaignCreateParams::Include>] A list of properties that this campaign should include. These properties can be
28
- #
29
- # @param link_sample [String] A sample link that might be sent by this campaign. If links from other domains a
30
- #
31
- # @param terms_and_conditions_url [String] The URL of the terms and conditions presented to end users when they opt in to m
15
+ # @param campaign_params [SurgeAPI::CampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
32
16
  #
33
17
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
34
18
  #
@@ -37,6 +21,11 @@ module SurgeAPI
37
21
  # @see SurgeAPI::Models::CampaignCreateParams
38
22
  def create(account_id, params)
39
23
  parsed, options = SurgeAPI::CampaignCreateParams.dump_request(params)
24
+ case parsed
25
+ in {campaign_params: Hash => union, **rest}
26
+ parsed = {**rest, **union}
27
+ else
28
+ end
40
29
  @client.request(
41
30
  method: :post,
42
31
  path: ["accounts/%1$s/campaigns", account_id],