surge_api 0.17.0 → 0.18.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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +51 -16
  4. data/lib/surge_api/client.rb +22 -1
  5. data/lib/surge_api/internal/transport/base_client.rb +5 -0
  6. data/lib/surge_api/internal/util.rb +22 -7
  7. data/lib/surge_api/models/account_archive_params.rb +9 -1
  8. data/lib/surge_api/models/account_retrieve_status_params.rb +9 -1
  9. data/lib/surge_api/models/account_update_params.rb +9 -1
  10. data/lib/surge_api/models/attachment_get_file_params.rb +9 -1
  11. data/lib/surge_api/models/audience_add_contact_params.rb +9 -1
  12. data/lib/surge_api/models/audience_create_params.rb +9 -1
  13. data/lib/surge_api/models/audience_list_contacts_params.rb +9 -1
  14. data/lib/surge_api/models/blast_create_params.rb +9 -1
  15. data/lib/surge_api/models/campaign_create_params.rb +6 -10
  16. data/lib/surge_api/models/campaign_list_params.rb +9 -1
  17. data/lib/surge_api/models/campaign_retrieve_params.rb +9 -1
  18. data/lib/surge_api/models/campaign_update_params.rb +6 -10
  19. data/lib/surge_api/models/contact_create_params.rb +9 -1
  20. data/lib/surge_api/models/contact_list_params.rb +9 -1
  21. data/lib/surge_api/models/contact_retrieve_params.rb +9 -1
  22. data/lib/surge_api/models/contact_update_params.rb +9 -1
  23. data/lib/surge_api/models/message.rb +1 -0
  24. data/lib/surge_api/models/message_create_params.rb +6 -11
  25. data/lib/surge_api/models/message_delivered_webhook_event.rb +1 -0
  26. data/lib/surge_api/models/message_failed_webhook_event.rb +1 -0
  27. data/lib/surge_api/models/message_list_params.rb +9 -1
  28. data/lib/surge_api/models/message_params.rb +74 -2
  29. data/lib/surge_api/models/message_received_webhook_event.rb +1 -0
  30. data/lib/surge_api/models/message_retrieve_params.rb +9 -1
  31. data/lib/surge_api/models/message_sent_webhook_event.rb +1 -0
  32. data/lib/surge_api/models/phone_number.rb +1 -1
  33. data/lib/surge_api/models/phone_number_list_params.rb +9 -1
  34. data/lib/surge_api/models/phone_number_purchase_params.rb +9 -1
  35. data/lib/surge_api/models/phone_number_release_params.rb +22 -0
  36. data/lib/surge_api/models/phone_number_update_params.rb +38 -0
  37. data/lib/surge_api/models/recording_delete_params.rb +9 -1
  38. data/lib/surge_api/models/recording_get_file_params.rb +9 -1
  39. data/lib/surge_api/models/recording_list_params.rb +9 -1
  40. data/lib/surge_api/models/recording_retrieve_params.rb +9 -1
  41. data/lib/surge_api/models/user_create_params.rb +9 -1
  42. data/lib/surge_api/models/user_create_token_params.rb +9 -1
  43. data/lib/surge_api/models/user_delete_params.rb +9 -1
  44. data/lib/surge_api/models/user_list_params.rb +9 -1
  45. data/lib/surge_api/models/user_retrieve_params.rb +9 -1
  46. data/lib/surge_api/models/user_update_params.rb +9 -1
  47. data/lib/surge_api/models/verification_check_params.rb +9 -1
  48. data/lib/surge_api/models/verification_create_params.rb +9 -1
  49. data/lib/surge_api/models.rb +4 -0
  50. data/lib/surge_api/resources/campaigns.rb +4 -14
  51. data/lib/surge_api/resources/messages.rb +6 -7
  52. data/lib/surge_api/resources/phone_numbers.rb +46 -0
  53. data/lib/surge_api/resources/verifications.rb +7 -4
  54. data/lib/surge_api/resources/webhooks.rb +11 -1
  55. data/lib/surge_api/version.rb +1 -1
  56. data/lib/surge_api.rb +3 -0
  57. data/rbi/surge_api/client.rbi +6 -0
  58. data/rbi/surge_api/internal/util.rbi +8 -0
  59. data/rbi/surge_api/models/account_archive_params.rbi +18 -5
  60. data/rbi/surge_api/models/account_retrieve_status_params.rbi +8 -0
  61. data/rbi/surge_api/models/account_update_params.rbi +8 -0
  62. data/rbi/surge_api/models/attachment_get_file_params.rbi +18 -5
  63. data/rbi/surge_api/models/audience_add_contact_params.rbi +12 -1
  64. data/rbi/surge_api/models/audience_create_params.rbi +12 -1
  65. data/rbi/surge_api/models/audience_list_contacts_params.rbi +8 -0
  66. data/rbi/surge_api/models/blast_create_params.rbi +8 -0
  67. data/rbi/surge_api/models/campaign_create_params.rbi +7 -27
  68. data/rbi/surge_api/models/campaign_list_params.rbi +8 -0
  69. data/rbi/surge_api/models/campaign_retrieve_params.rbi +18 -5
  70. data/rbi/surge_api/models/campaign_update_params.rbi +7 -27
  71. data/rbi/surge_api/models/contact_create_params.rbi +8 -0
  72. data/rbi/surge_api/models/contact_list_params.rbi +8 -0
  73. data/rbi/surge_api/models/contact_retrieve_params.rbi +18 -5
  74. data/rbi/surge_api/models/contact_update_params.rbi +8 -0
  75. data/rbi/surge_api/models/message.rbi +2 -0
  76. data/rbi/surge_api/models/message_create_params.rbi +7 -29
  77. data/rbi/surge_api/models/message_delivered_webhook_event.rbi +5 -0
  78. data/rbi/surge_api/models/message_failed_webhook_event.rbi +5 -0
  79. data/rbi/surge_api/models/message_list_params.rbi +8 -0
  80. data/rbi/surge_api/models/message_params.rbi +225 -6
  81. data/rbi/surge_api/models/message_received_webhook_event.rbi +5 -0
  82. data/rbi/surge_api/models/message_retrieve_params.rbi +18 -5
  83. data/rbi/surge_api/models/message_sent_webhook_event.rbi +5 -0
  84. data/rbi/surge_api/models/phone_number_list_params.rbi +8 -0
  85. data/rbi/surge_api/models/phone_number_purchase_params.rbi +8 -0
  86. data/rbi/surge_api/models/phone_number_release_params.rbi +40 -0
  87. data/rbi/surge_api/models/phone_number_update_params.rbi +65 -0
  88. data/rbi/surge_api/models/recording_delete_params.rbi +18 -5
  89. data/rbi/surge_api/models/recording_get_file_params.rbi +18 -5
  90. data/rbi/surge_api/models/recording_list_params.rbi +8 -0
  91. data/rbi/surge_api/models/recording_retrieve_params.rbi +18 -5
  92. data/rbi/surge_api/models/user_create_params.rbi +8 -0
  93. data/rbi/surge_api/models/user_create_token_params.rbi +8 -0
  94. data/rbi/surge_api/models/user_delete_params.rbi +18 -5
  95. data/rbi/surge_api/models/user_list_params.rbi +8 -0
  96. data/rbi/surge_api/models/user_retrieve_params.rbi +18 -5
  97. data/rbi/surge_api/models/user_update_params.rbi +8 -0
  98. data/rbi/surge_api/models/verification_check_params.rbi +12 -1
  99. data/rbi/surge_api/models/verification_create_params.rbi +12 -1
  100. data/rbi/surge_api/models.rbi +4 -0
  101. data/rbi/surge_api/resources/campaigns.rbi +10 -2
  102. data/rbi/surge_api/resources/messages.rbi +9 -1
  103. data/rbi/surge_api/resources/phone_numbers.rbi +34 -0
  104. data/rbi/surge_api/resources/verifications.rbi +5 -1
  105. data/rbi/surge_api/resources/webhooks.rbi +10 -2
  106. data/sig/surge_api/client.rbs +3 -0
  107. data/sig/surge_api/internal/util.rbs +4 -0
  108. data/sig/surge_api/models/account_archive_params.rbs +8 -3
  109. data/sig/surge_api/models/account_retrieve_status_params.rbs +5 -0
  110. data/sig/surge_api/models/account_update_params.rbs +5 -0
  111. data/sig/surge_api/models/attachment_get_file_params.rbs +11 -3
  112. data/sig/surge_api/models/audience_add_contact_params.rbs +10 -2
  113. data/sig/surge_api/models/audience_create_params.rbs +6 -1
  114. data/sig/surge_api/models/audience_list_contacts_params.rbs +5 -1
  115. data/sig/surge_api/models/blast_create_params.rbs +5 -0
  116. data/sig/surge_api/models/campaign_create_params.rbs +4 -9
  117. data/sig/surge_api/models/campaign_list_params.rbs +5 -1
  118. data/sig/surge_api/models/campaign_retrieve_params.rbs +8 -3
  119. data/sig/surge_api/models/campaign_update_params.rbs +4 -12
  120. data/sig/surge_api/models/contact_create_params.rbs +5 -0
  121. data/sig/surge_api/models/contact_list_params.rbs +5 -1
  122. data/sig/surge_api/models/contact_retrieve_params.rbs +8 -3
  123. data/sig/surge_api/models/contact_update_params.rbs +5 -0
  124. data/sig/surge_api/models/message.rbs +2 -1
  125. data/sig/surge_api/models/message_create_params.rbs +4 -9
  126. data/sig/surge_api/models/message_delivered_webhook_event.rbs +2 -1
  127. data/sig/surge_api/models/message_failed_webhook_event.rbs +2 -1
  128. data/sig/surge_api/models/message_list_params.rbs +5 -1
  129. data/sig/surge_api/models/message_params.rbs +88 -6
  130. data/sig/surge_api/models/message_received_webhook_event.rbs +2 -1
  131. data/sig/surge_api/models/message_retrieve_params.rbs +8 -3
  132. data/sig/surge_api/models/message_sent_webhook_event.rbs +2 -1
  133. data/sig/surge_api/models/phone_number_list_params.rbs +5 -1
  134. data/sig/surge_api/models/phone_number_purchase_params.rbs +5 -0
  135. data/sig/surge_api/models/phone_number_release_params.rbs +20 -0
  136. data/sig/surge_api/models/phone_number_update_params.rbs +36 -0
  137. data/sig/surge_api/models/recording_delete_params.rbs +8 -3
  138. data/sig/surge_api/models/recording_get_file_params.rbs +11 -3
  139. data/sig/surge_api/models/recording_list_params.rbs +5 -1
  140. data/sig/surge_api/models/recording_retrieve_params.rbs +8 -3
  141. data/sig/surge_api/models/user_create_params.rbs +5 -0
  142. data/sig/surge_api/models/user_create_token_params.rbs +5 -1
  143. data/sig/surge_api/models/user_delete_params.rbs +8 -3
  144. data/sig/surge_api/models/user_list_params.rbs +5 -1
  145. data/sig/surge_api/models/user_retrieve_params.rbs +8 -3
  146. data/sig/surge_api/models/user_update_params.rbs +5 -0
  147. data/sig/surge_api/models/verification_check_params.rbs +6 -1
  148. data/sig/surge_api/models/verification_create_params.rbs +6 -1
  149. data/sig/surge_api/models.rbs +4 -0
  150. data/sig/surge_api/resources/campaigns.rbs +2 -2
  151. data/sig/surge_api/resources/messages.rbs +1 -1
  152. data/sig/surge_api/resources/phone_numbers.rbs +12 -0
  153. data/sig/surge_api/resources/verifications.rbs +1 -0
  154. data/sig/surge_api/resources/webhooks.rbs +3 -1
  155. metadata +22 -2
@@ -7,13 +7,21 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute id
11
+ # The ID of the verification to check against.
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
10
16
  # @!attribute code
11
17
  # The Verification code that was received.
12
18
  #
13
19
  # @return [String]
14
20
  required :code, String
15
21
 
16
- # @!method initialize(code:, request_options: {})
22
+ # @!method initialize(id:, code:, request_options: {})
23
+ # @param id [String] The ID of the verification to check against.
24
+ #
17
25
  # @param code [String] The Verification code that was received.
18
26
  #
19
27
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
@@ -7,13 +7,21 @@ module SurgeAPI
7
7
  extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
8
  include SurgeAPI::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute account_id
11
+ # The account to associate with the verification.
12
+ #
13
+ # @return [String]
14
+ required :account_id, String
15
+
10
16
  # @!attribute phone_number
11
17
  # The phone number to be verified. In E.164 format.
12
18
  #
13
19
  # @return [String]
14
20
  required :phone_number, String
15
21
 
16
- # @!method initialize(phone_number:, request_options: {})
22
+ # @!method initialize(account_id:, phone_number:, request_options: {})
23
+ # @param account_id [String] The account to associate with the verification.
24
+ #
17
25
  # @param phone_number [String] The phone number to be verified. In E.164 format.
18
26
  #
19
27
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
@@ -129,6 +129,10 @@ module SurgeAPI
129
129
 
130
130
  PhoneNumberPurchaseParams = SurgeAPI::Models::PhoneNumberPurchaseParams
131
131
 
132
+ PhoneNumberReleaseParams = SurgeAPI::Models::PhoneNumberReleaseParams
133
+
134
+ PhoneNumberUpdateParams = SurgeAPI::Models::PhoneNumberUpdateParams
135
+
132
136
  RecordingCompletedWebhookEvent = SurgeAPI::Models::RecordingCompletedWebhookEvent
133
137
 
134
138
  RecordingDeleteParams = SurgeAPI::Models::RecordingDeleteParams
@@ -12,7 +12,7 @@ module SurgeAPI
12
12
  #
13
13
  # @param account_id [String] The account for which the campaign should be created.
14
14
  #
15
- # @param campaign_params [SurgeAPI::CampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
15
+ # @param campaign_params [SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
16
16
  #
17
17
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
18
18
  #
@@ -21,15 +21,10 @@ module SurgeAPI
21
21
  # @see SurgeAPI::Models::CampaignCreateParams
22
22
  def create(account_id, params)
23
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
29
24
  @client.request(
30
25
  method: :post,
31
26
  path: ["accounts/%1$s/campaigns", account_id],
32
- body: parsed,
27
+ body: parsed[:campaign_params],
33
28
  model: SurgeAPI::Campaign,
34
29
  options: options
35
30
  )
@@ -67,7 +62,7 @@ module SurgeAPI
67
62
  #
68
63
  # @param id [String] The ID of the campaign to update.
69
64
  #
70
- # @param campaign_params [SurgeAPI::CampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
65
+ # @param campaign_params [SurgeAPI::Models::CampaignParams::StandardCampaignParams, SurgeAPI::Models::CampaignParams::ExternalCampaignParams] Parameters for creating a new campaign. Either provide full campaign details or
71
66
  #
72
67
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
73
68
  #
@@ -76,15 +71,10 @@ module SurgeAPI
76
71
  # @see SurgeAPI::Models::CampaignUpdateParams
77
72
  def update(id, params)
78
73
  parsed, options = SurgeAPI::CampaignUpdateParams.dump_request(params)
79
- case parsed
80
- in {campaign_params: Hash => union, **rest}
81
- parsed = {**rest, **union}
82
- else
83
- end
84
74
  @client.request(
85
75
  method: :patch,
86
76
  path: ["campaigns/%1$s", id],
87
- body: parsed,
77
+ body: parsed[:campaign_params],
88
78
  model: SurgeAPI::Campaign,
89
79
  options: options
90
80
  )
@@ -32,11 +32,15 @@ module SurgeAPI
32
32
  # `conversation` field, and `conversation.phone_number` should be specified
33
33
  # instead.
34
34
  #
35
+ # Optionally, you can pass a `settings` object to override account-level settings
36
+ # for this message. Currently the only supported setting is `link_shortening`,
37
+ # which accepts `"enabled"` or `"disabled"`.
38
+ #
35
39
  # @overload create(account_id, message_params:, request_options: {})
36
40
  #
37
41
  # @param account_id [String] The account from which the message should be sent.
38
42
  #
39
- # @param message_params [SurgeAPI::MessageParams] Payload for creating a message. Either an attachment or the body must be given.
43
+ # @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.
40
44
  #
41
45
  # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
42
46
  #
@@ -45,15 +49,10 @@ module SurgeAPI
45
49
  # @see SurgeAPI::Models::MessageCreateParams
46
50
  def create(account_id, params)
47
51
  parsed, options = SurgeAPI::MessageCreateParams.dump_request(params)
48
- case parsed
49
- in {message_params: Hash => union, **rest}
50
- parsed = {**rest, **union}
51
- else
52
- end
53
52
  @client.request(
54
53
  method: :post,
55
54
  path: ["accounts/%1$s/messages", account_id],
56
- body: parsed,
55
+ body: parsed[:message_params],
57
56
  model: SurgeAPI::Message,
58
57
  options: options
59
58
  )
@@ -3,6 +3,32 @@
3
3
  module SurgeAPI
4
4
  module Resources
5
5
  class PhoneNumbers
6
+ # Updates a phone number's details.
7
+ #
8
+ # @overload update(id, campaign_id: nil, name: nil, request_options: {})
9
+ #
10
+ # @param id [String] The ID of the phone number to update.
11
+ #
12
+ # @param campaign_id [String] Campaign ID to attach this number to (`cpn_...`).
13
+ #
14
+ # @param name [String] A human-readable name for the phone number.
15
+ #
16
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
17
+ #
18
+ # @return [SurgeAPI::Models::PhoneNumber]
19
+ #
20
+ # @see SurgeAPI::Models::PhoneNumberUpdateParams
21
+ def update(id, params = {})
22
+ parsed, options = SurgeAPI::PhoneNumberUpdateParams.dump_request(params)
23
+ @client.request(
24
+ method: :patch,
25
+ path: ["phone_numbers/%1$s", id],
26
+ body: parsed,
27
+ model: SurgeAPI::PhoneNumber,
28
+ options: options
29
+ )
30
+ end
31
+
6
32
  # Some parameter documentations has been truncated, see
7
33
  # {SurgeAPI::Models::PhoneNumberListParams} for more details.
8
34
  #
@@ -70,6 +96,26 @@ module SurgeAPI
70
96
  )
71
97
  end
72
98
 
99
+ # Releases a phone number from the account.
100
+ #
101
+ # @overload release(id, request_options: {})
102
+ #
103
+ # @param id [String] The ID of the phone number to release.
104
+ #
105
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
106
+ #
107
+ # @return [SurgeAPI::Models::PhoneNumber]
108
+ #
109
+ # @see SurgeAPI::Models::PhoneNumberReleaseParams
110
+ def release(id, params = {})
111
+ @client.request(
112
+ method: :delete,
113
+ path: ["phone_numbers/%1$s", id],
114
+ model: SurgeAPI::PhoneNumber,
115
+ options: params[:request_options]
116
+ )
117
+ end
118
+
73
119
  # @api private
74
120
  #
75
121
  # @param client [SurgeAPI::Client]
@@ -3,9 +3,12 @@
3
3
  module SurgeAPI
4
4
  module Resources
5
5
  class Verifications
6
- # Creates a new Verification and sends the code to the given phone number.
6
+ # Creates a new Verification for an account and sends the code to the given phone
7
+ # number.
7
8
  #
8
- # @overload create(phone_number:, request_options: {})
9
+ # @overload create(account_id, phone_number:, request_options: {})
10
+ #
11
+ # @param account_id [String] The account to associate with the verification.
9
12
  #
10
13
  # @param phone_number [String] The phone number to be verified. In E.164 format.
11
14
  #
@@ -14,11 +17,11 @@ module SurgeAPI
14
17
  # @return [SurgeAPI::Models::Verification]
15
18
  #
16
19
  # @see SurgeAPI::Models::VerificationCreateParams
17
- def create(params)
20
+ def create(account_id, params)
18
21
  parsed, options = SurgeAPI::VerificationCreateParams.dump_request(params)
19
22
  @client.request(
20
23
  method: :post,
21
- path: "verifications",
24
+ path: ["accounts/%1$s/verifications", account_id],
22
25
  body: parsed,
23
26
  model: SurgeAPI::Verification,
24
27
  options: options
@@ -5,8 +5,18 @@ module SurgeAPI
5
5
  class Webhooks
6
6
  # @param payload [String] The raw webhook payload as a string
7
7
  #
8
+ # @param headers [Hash{String=>String}] The raw HTTP headers that came with the payload
9
+ #
10
+ # @param key [String, nil] The webhook signing key
11
+ #
8
12
  # @return [SurgeAPI::Models::CallEndedWebhookEvent, SurgeAPI::Models::CampaignApprovedWebhookEvent, SurgeAPI::Models::ContactOptedInWebhookEvent, SurgeAPI::Models::ContactOptedOutWebhookEvent, SurgeAPI::Models::ConversationCreatedWebhookEvent, SurgeAPI::Models::LinkFollowedWebhookEvent, SurgeAPI::Models::MessageDeliveredWebhookEvent, SurgeAPI::Models::MessageFailedWebhookEvent, SurgeAPI::Models::MessageReceivedWebhookEvent, SurgeAPI::Models::MessageSentWebhookEvent, SurgeAPI::Models::PhoneNumberAttachedToCampaignWebhookEvent, SurgeAPI::Models::RecordingCompletedWebhookEvent, SurgeAPI::Models::VoicemailReceivedWebhookEvent]
9
- def unwrap(payload)
13
+ def unwrap(payload, headers:, key: @client.webhook_signing_secret)
14
+ if key.nil?
15
+ raise ArgumentError.new("Cannot verify a webhook without a key on either the client's webhook_signing_secret or passed in as an argument")
16
+ end
17
+
18
+ ::StandardWebhooks::Webhook.new(key).verify(payload, headers)
19
+
10
20
  parsed = JSON.parse(payload, symbolize_names: true)
11
21
  SurgeAPI::Internal::Type::Converter.coerce(SurgeAPI::Models::UnwrapWebhookEvent, parsed)
12
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SurgeAPI
4
- VERSION = "0.17.0"
4
+ VERSION = "0.18.0"
5
5
  end
data/lib/surge_api.rb CHANGED
@@ -30,6 +30,7 @@ end
30
30
 
31
31
  # Gems.
32
32
  require "connection_pool"
33
+ require "standardwebhooks"
33
34
 
34
35
  # Package files.
35
36
  require_relative "surge_api/version"
@@ -100,6 +101,8 @@ require_relative "surge_api/models/phone_number"
100
101
  require_relative "surge_api/models/phone_number_attached_to_campaign_webhook_event"
101
102
  require_relative "surge_api/models/phone_number_list_params"
102
103
  require_relative "surge_api/models/phone_number_purchase_params"
104
+ require_relative "surge_api/models/phone_number_release_params"
105
+ require_relative "surge_api/models/phone_number_update_params"
103
106
  require_relative "surge_api/models/recording_completed_webhook_event"
104
107
  require_relative "surge_api/models/recording_delete_params"
105
108
  require_relative "surge_api/models/recording_delete_response"
@@ -13,6 +13,9 @@ module SurgeAPI
13
13
  sig { returns(String) }
14
14
  attr_reader :api_key
15
15
 
16
+ sig { returns(T.nilable(String)) }
17
+ attr_reader :webhook_signing_secret
18
+
16
19
  sig { returns(SurgeAPI::Resources::Accounts) }
17
20
  attr_reader :accounts
18
21
 
@@ -58,6 +61,7 @@ module SurgeAPI
58
61
  sig do
59
62
  params(
60
63
  api_key: T.nilable(String),
64
+ webhook_signing_secret: T.nilable(String),
61
65
  base_url: T.nilable(String),
62
66
  max_retries: Integer,
63
67
  timeout: Float,
@@ -68,6 +72,8 @@ module SurgeAPI
68
72
  def self.new(
69
73
  # Defaults to `ENV["SURGE_API_KEY"]`
70
74
  api_key: ENV["SURGE_API_KEY"],
75
+ # Defaults to `ENV["SURGE_WEBHOOK_SIGNING_SECRET"]`
76
+ webhook_signing_secret: ENV["SURGE_WEBHOOK_SIGNING_SECRET"],
71
77
  # Override the default base URL for the API, e.g.,
72
78
  # `"https://api.example.com/v2/"`. Defaults to `ENV["SURGE_BASE_URL"]`
73
79
  base_url: ENV["SURGE_BASE_URL"],
@@ -148,12 +148,20 @@ module SurgeAPI
148
148
  end
149
149
  end
150
150
 
151
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
152
+ RFC_3986_NOT_PCHARS = T.let(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/, Regexp)
153
+
151
154
  class << self
152
155
  # @api private
153
156
  sig { params(uri: URI::Generic).returns(String) }
154
157
  def uri_origin(uri)
155
158
  end
156
159
 
160
+ # @api private
161
+ sig { params(path: T.any(String, Integer)).returns(String) }
162
+ def encode_path(path)
163
+ end
164
+
157
165
  # @api private
158
166
  sig { params(path: T.any(String, T::Array[String])).returns(String) }
159
167
  def interpolate_path(path)
@@ -11,15 +11,28 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::AccountArchiveParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
+ # The ID of the account to archive.
15
+ sig { returns(String) }
16
+ attr_accessor :id
17
+
14
18
  sig do
15
- params(request_options: SurgeAPI::RequestOptions::OrHash).returns(
16
- T.attached_class
17
- )
19
+ params(
20
+ id: String,
21
+ request_options: SurgeAPI::RequestOptions::OrHash
22
+ ).returns(T.attached_class)
18
23
  end
19
- def self.new(request_options: {})
24
+ def self.new(
25
+ # The ID of the account to archive.
26
+ id:,
27
+ request_options: {}
28
+ )
20
29
  end
21
30
 
22
- sig { override.returns({ request_options: SurgeAPI::RequestOptions }) }
31
+ sig do
32
+ override.returns(
33
+ { id: String, request_options: SurgeAPI::RequestOptions }
34
+ )
35
+ end
23
36
  def to_hash
24
37
  end
25
38
  end
@@ -14,6 +14,10 @@ module SurgeAPI
14
14
  )
15
15
  end
16
16
 
17
+ # ID of the account to check
18
+ sig { returns(String) }
19
+ attr_accessor :account_id
20
+
17
21
  # capabilities about which to check the status
18
22
  sig do
19
23
  returns(
@@ -38,6 +42,7 @@ module SurgeAPI
38
42
 
39
43
  sig do
40
44
  params(
45
+ account_id: String,
41
46
  capabilities:
42
47
  T::Array[
43
48
  SurgeAPI::AccountRetrieveStatusParams::Capability::OrSymbol
@@ -46,6 +51,8 @@ module SurgeAPI
46
51
  ).returns(T.attached_class)
47
52
  end
48
53
  def self.new(
54
+ # ID of the account to check
55
+ account_id:,
49
56
  # capabilities about which to check the status
50
57
  capabilities: nil,
51
58
  request_options: {}
@@ -55,6 +62,7 @@ module SurgeAPI
55
62
  sig do
56
63
  override.returns(
57
64
  {
65
+ account_id: String,
58
66
  capabilities:
59
67
  T::Array[
60
68
  SurgeAPI::AccountRetrieveStatusParams::Capability::OrSymbol
@@ -11,6 +11,10 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::AccountUpdateParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
+ # The ID for the account to update.
15
+ sig { returns(String) }
16
+ attr_accessor :id
17
+
14
18
  # The name by which the people this account communicates with know it. If not
15
19
  # provided, this will match the name field.
16
20
  sig { returns(T.nilable(String)) }
@@ -48,6 +52,7 @@ module SurgeAPI
48
52
 
49
53
  sig do
50
54
  params(
55
+ id: String,
51
56
  brand_name: String,
52
57
  name: String,
53
58
  organization: SurgeAPI::AccountUpdateParams::Organization::OrHash,
@@ -56,6 +61,8 @@ module SurgeAPI
56
61
  ).returns(T.attached_class)
57
62
  end
58
63
  def self.new(
64
+ # The ID for the account to update.
65
+ id:,
59
66
  # The name by which the people this account communicates with know it. If not
60
67
  # provided, this will match the name field.
61
68
  brand_name: nil,
@@ -77,6 +84,7 @@ module SurgeAPI
77
84
  sig do
78
85
  override.returns(
79
86
  {
87
+ id: String,
80
88
  brand_name: String,
81
89
  name: String,
82
90
  organization: SurgeAPI::AccountUpdateParams::Organization,
@@ -11,15 +11,28 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::AttachmentGetFileParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
+ # The ID of the attachment.
15
+ sig { returns(String) }
16
+ attr_accessor :attachment_id
17
+
14
18
  sig do
15
- params(request_options: SurgeAPI::RequestOptions::OrHash).returns(
16
- T.attached_class
17
- )
19
+ params(
20
+ attachment_id: String,
21
+ request_options: SurgeAPI::RequestOptions::OrHash
22
+ ).returns(T.attached_class)
18
23
  end
19
- def self.new(request_options: {})
24
+ def self.new(
25
+ # The ID of the attachment.
26
+ attachment_id:,
27
+ request_options: {}
28
+ )
20
29
  end
21
30
 
22
- sig { override.returns({ request_options: SurgeAPI::RequestOptions }) }
31
+ sig do
32
+ override.returns(
33
+ { attachment_id: String, request_options: SurgeAPI::RequestOptions }
34
+ )
35
+ end
23
36
  def to_hash
24
37
  end
25
38
  end
@@ -11,6 +11,10 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::AudienceAddContactParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
+ # The audience ID to add the contact to.
15
+ sig { returns(String) }
16
+ attr_accessor :audience_id
17
+
14
18
  # The ID of the contact to add. The contact must belong to the same account as the
15
19
  # audience.
16
20
  sig { returns(String) }
@@ -18,11 +22,14 @@ module SurgeAPI
18
22
 
19
23
  sig do
20
24
  params(
25
+ audience_id: String,
21
26
  id: String,
22
27
  request_options: SurgeAPI::RequestOptions::OrHash
23
28
  ).returns(T.attached_class)
24
29
  end
25
30
  def self.new(
31
+ # The audience ID to add the contact to.
32
+ audience_id:,
26
33
  # The ID of the contact to add. The contact must belong to the same account as the
27
34
  # audience.
28
35
  id:,
@@ -32,7 +39,11 @@ module SurgeAPI
32
39
 
33
40
  sig do
34
41
  override.returns(
35
- { id: String, request_options: SurgeAPI::RequestOptions }
42
+ {
43
+ audience_id: String,
44
+ id: String,
45
+ request_options: SurgeAPI::RequestOptions
46
+ }
36
47
  )
37
48
  end
38
49
  def to_hash
@@ -11,17 +11,24 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::AudienceCreateParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
+ # The account for which the audience should be created.
15
+ sig { returns(String) }
16
+ attr_accessor :account_id
17
+
14
18
  # The audience name.
15
19
  sig { returns(String) }
16
20
  attr_accessor :name
17
21
 
18
22
  sig do
19
23
  params(
24
+ account_id: String,
20
25
  name: String,
21
26
  request_options: SurgeAPI::RequestOptions::OrHash
22
27
  ).returns(T.attached_class)
23
28
  end
24
29
  def self.new(
30
+ # The account for which the audience should be created.
31
+ account_id:,
25
32
  # The audience name.
26
33
  name:,
27
34
  request_options: {}
@@ -30,7 +37,11 @@ module SurgeAPI
30
37
 
31
38
  sig do
32
39
  override.returns(
33
- { name: String, request_options: SurgeAPI::RequestOptions }
40
+ {
41
+ account_id: String,
42
+ name: String,
43
+ request_options: SurgeAPI::RequestOptions
44
+ }
34
45
  )
35
46
  end
36
47
  def to_hash
@@ -14,6 +14,10 @@ module SurgeAPI
14
14
  )
15
15
  end
16
16
 
17
+ # The audience ID to list contacts for.
18
+ sig { returns(String) }
19
+ attr_accessor :audience_id
20
+
17
21
  # Cursor for forward pagination. Use the next_cursor from a previous response.
18
22
  sig { returns(T.nilable(String)) }
19
23
  attr_reader :after
@@ -31,12 +35,15 @@ module SurgeAPI
31
35
 
32
36
  sig do
33
37
  params(
38
+ audience_id: String,
34
39
  after: String,
35
40
  before: String,
36
41
  request_options: SurgeAPI::RequestOptions::OrHash
37
42
  ).returns(T.attached_class)
38
43
  end
39
44
  def self.new(
45
+ # The audience ID to list contacts for.
46
+ audience_id:,
40
47
  # Cursor for forward pagination. Use the next_cursor from a previous response.
41
48
  after: nil,
42
49
  # Cursor for backward pagination. Use the previous_cursor from a previous
@@ -49,6 +56,7 @@ module SurgeAPI
49
56
  sig do
50
57
  override.returns(
51
58
  {
59
+ audience_id: String,
52
60
  after: String,
53
61
  before: String,
54
62
  request_options: SurgeAPI::RequestOptions
@@ -11,6 +11,10 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::BlastCreateParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
+ # The account for which the blast should be sent.
15
+ sig { returns(String) }
16
+ attr_accessor :account_id
17
+
14
18
  sig do
15
19
  returns(T.nilable(T::Array[SurgeAPI::BlastCreateParams::Attachment]))
16
20
  end
@@ -74,6 +78,7 @@ module SurgeAPI
74
78
 
75
79
  sig do
76
80
  params(
81
+ account_id: String,
77
82
  attachments:
78
83
  T::Array[SurgeAPI::BlastCreateParams::Attachment::OrHash],
79
84
  body: T.nilable(String),
@@ -87,6 +92,8 @@ module SurgeAPI
87
92
  ).returns(T.attached_class)
88
93
  end
89
94
  def self.new(
95
+ # The account for which the blast should be sent.
96
+ account_id:,
90
97
  attachments: nil,
91
98
  # The message body.
92
99
  body: nil,
@@ -112,6 +119,7 @@ module SurgeAPI
112
119
  sig do
113
120
  override.returns(
114
121
  {
122
+ account_id: String,
115
123
  attachments: T::Array[SurgeAPI::BlastCreateParams::Attachment],
116
124
  body: T.nilable(String),
117
125
  contacts: T::Array[String],
@@ -11,46 +11,26 @@ module SurgeAPI
11
11
  T.any(SurgeAPI::CampaignCreateParams, SurgeAPI::Internal::AnyHash)
12
12
  end
13
13
 
14
- # Parameters for creating a new campaign. Either provide full campaign details or
15
- # import using a TCR ID.
16
- sig do
17
- returns(
18
- T.any(
19
- SurgeAPI::CampaignParams::StandardCampaignParams,
20
- SurgeAPI::CampaignParams::ExternalCampaignParams
21
- )
22
- )
23
- end
24
- attr_accessor :campaign_params
14
+ # The account for which the campaign should be created.
15
+ sig { returns(String) }
16
+ attr_accessor :account_id
25
17
 
26
18
  sig do
27
19
  params(
28
- campaign_params:
29
- T.any(
30
- SurgeAPI::CampaignParams::StandardCampaignParams::OrHash,
31
- SurgeAPI::CampaignParams::ExternalCampaignParams::OrHash
32
- ),
20
+ account_id: String,
33
21
  request_options: SurgeAPI::RequestOptions::OrHash
34
22
  ).returns(T.attached_class)
35
23
  end
36
24
  def self.new(
37
- # Parameters for creating a new campaign. Either provide full campaign details or
38
- # import using a TCR ID.
39
- campaign_params:,
25
+ # The account for which the campaign should be created.
26
+ account_id:,
40
27
  request_options: {}
41
28
  )
42
29
  end
43
30
 
44
31
  sig do
45
32
  override.returns(
46
- {
47
- campaign_params:
48
- T.any(
49
- SurgeAPI::CampaignParams::StandardCampaignParams,
50
- SurgeAPI::CampaignParams::ExternalCampaignParams
51
- ),
52
- request_options: SurgeAPI::RequestOptions
53
- }
33
+ { account_id: String, request_options: SurgeAPI::RequestOptions }
54
34
  )
55
35
  end
56
36
  def to_hash