surge_api 0.1.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 (212) hide show
  1. checksums.yaml +7 -0
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +28 -0
  4. data/README.md +286 -0
  5. data/SECURITY.md +27 -0
  6. data/lib/surge_api/client.rb +106 -0
  7. data/lib/surge_api/errors.rb +228 -0
  8. data/lib/surge_api/file_part.rb +55 -0
  9. data/lib/surge_api/internal/transport/base_client.rb +567 -0
  10. data/lib/surge_api/internal/transport/pooled_net_requester.rb +201 -0
  11. data/lib/surge_api/internal/type/array_of.rb +168 -0
  12. data/lib/surge_api/internal/type/base_model.rb +531 -0
  13. data/lib/surge_api/internal/type/base_page.rb +55 -0
  14. data/lib/surge_api/internal/type/boolean.rb +77 -0
  15. data/lib/surge_api/internal/type/converter.rb +327 -0
  16. data/lib/surge_api/internal/type/enum.rb +131 -0
  17. data/lib/surge_api/internal/type/file_input.rb +108 -0
  18. data/lib/surge_api/internal/type/hash_of.rb +188 -0
  19. data/lib/surge_api/internal/type/request_parameters.rb +42 -0
  20. data/lib/surge_api/internal/type/union.rb +250 -0
  21. data/lib/surge_api/internal/type/unknown.rb +81 -0
  22. data/lib/surge_api/internal/util.rb +915 -0
  23. data/lib/surge_api/internal.rb +20 -0
  24. data/lib/surge_api/models/account.rb +60 -0
  25. data/lib/surge_api/models/account_create_params.rb +481 -0
  26. data/lib/surge_api/models/account_retrieve_status_params.rb +32 -0
  27. data/lib/surge_api/models/account_status.rb +104 -0
  28. data/lib/surge_api/models/account_update_params.rb +480 -0
  29. data/lib/surge_api/models/blast.rb +61 -0
  30. data/lib/surge_api/models/blast_create_params.rb +90 -0
  31. data/lib/surge_api/models/call_ended_webhook_event.rb +106 -0
  32. data/lib/surge_api/models/campaign.rb +208 -0
  33. data/lib/surge_api/models/campaign_approved_webhook_event.rb +74 -0
  34. data/lib/surge_api/models/campaign_create_params.rb +202 -0
  35. data/lib/surge_api/models/contact.rb +59 -0
  36. data/lib/surge_api/models/contact_create_params.rb +54 -0
  37. data/lib/surge_api/models/contact_retrieve_params.rb +14 -0
  38. data/lib/surge_api/models/contact_update_params.rb +54 -0
  39. data/lib/surge_api/models/conversation_created_webhook_event.rb +70 -0
  40. data/lib/surge_api/models/error.rb +34 -0
  41. data/lib/surge_api/models/message.rb +146 -0
  42. data/lib/surge_api/models/message_create_params.rb +153 -0
  43. data/lib/surge_api/models/message_delivered_webhook_event.rb +159 -0
  44. data/lib/surge_api/models/message_failed_webhook_event.rb +167 -0
  45. data/lib/surge_api/models/message_received_webhook_event.rb +159 -0
  46. data/lib/surge_api/models/message_sent_webhook_event.rb +159 -0
  47. data/lib/surge_api/models/organization.rb +419 -0
  48. data/lib/surge_api/models/phone_number.rb +48 -0
  49. data/lib/surge_api/models/phone_number_purchase_params.rb +65 -0
  50. data/lib/surge_api/models/unwrap_webhook_event.rb +26 -0
  51. data/lib/surge_api/models/user.rb +51 -0
  52. data/lib/surge_api/models/user_create_params.rb +46 -0
  53. data/lib/surge_api/models/user_create_token_params.rb +22 -0
  54. data/lib/surge_api/models/user_retrieve_params.rb +14 -0
  55. data/lib/surge_api/models/user_token_response.rb +19 -0
  56. data/lib/surge_api/models/user_update_params.rb +46 -0
  57. data/lib/surge_api/models/verification.rb +58 -0
  58. data/lib/surge_api/models/verification_check.rb +43 -0
  59. data/lib/surge_api/models/verification_check_params.rb +22 -0
  60. data/lib/surge_api/models/verification_create_params.rb +22 -0
  61. data/lib/surge_api/models/webhook_unwrap_params.rb +14 -0
  62. data/lib/surge_api/models.rb +117 -0
  63. data/lib/surge_api/request_options.rb +77 -0
  64. data/lib/surge_api/resources/accounts.rb +102 -0
  65. data/lib/surge_api/resources/blasts.rb +53 -0
  66. data/lib/surge_api/resources/campaigns.rb +57 -0
  67. data/lib/surge_api/resources/contacts.rb +99 -0
  68. data/lib/surge_api/resources/messages.rb +75 -0
  69. data/lib/surge_api/resources/phone_numbers.rb +48 -0
  70. data/lib/surge_api/resources/users.rb +119 -0
  71. data/lib/surge_api/resources/verifications.rb +60 -0
  72. data/lib/surge_api/resources/webhooks.rb +22 -0
  73. data/lib/surge_api/version.rb +5 -0
  74. data/lib/surge_api.rb +100 -0
  75. data/manifest.yaml +15 -0
  76. data/rbi/surge_api/client.rbi +73 -0
  77. data/rbi/surge_api/errors.rbi +205 -0
  78. data/rbi/surge_api/file_part.rbi +37 -0
  79. data/rbi/surge_api/internal/transport/base_client.rbi +292 -0
  80. data/rbi/surge_api/internal/transport/pooled_net_requester.rbi +79 -0
  81. data/rbi/surge_api/internal/type/array_of.rbi +104 -0
  82. data/rbi/surge_api/internal/type/base_model.rbi +302 -0
  83. data/rbi/surge_api/internal/type/base_page.rbi +42 -0
  84. data/rbi/surge_api/internal/type/boolean.rbi +58 -0
  85. data/rbi/surge_api/internal/type/converter.rbi +216 -0
  86. data/rbi/surge_api/internal/type/enum.rbi +82 -0
  87. data/rbi/surge_api/internal/type/file_input.rbi +59 -0
  88. data/rbi/surge_api/internal/type/hash_of.rbi +104 -0
  89. data/rbi/surge_api/internal/type/request_parameters.rbi +29 -0
  90. data/rbi/surge_api/internal/type/union.rbi +128 -0
  91. data/rbi/surge_api/internal/type/unknown.rbi +58 -0
  92. data/rbi/surge_api/internal/util.rbi +487 -0
  93. data/rbi/surge_api/internal.rbi +16 -0
  94. data/rbi/surge_api/models/account.rbi +83 -0
  95. data/rbi/surge_api/models/account_create_params.rbi +1104 -0
  96. data/rbi/surge_api/models/account_retrieve_status_params.rbi +96 -0
  97. data/rbi/surge_api/models/account_status.rbi +185 -0
  98. data/rbi/surge_api/models/account_update_params.rbi +1105 -0
  99. data/rbi/surge_api/models/blast.rbi +108 -0
  100. data/rbi/surge_api/models/blast_create_params.rbi +145 -0
  101. data/rbi/surge_api/models/call_ended_webhook_event.rbi +205 -0
  102. data/rbi/surge_api/models/campaign.rbi +331 -0
  103. data/rbi/surge_api/models/campaign_approved_webhook_event.rbi +149 -0
  104. data/rbi/surge_api/models/campaign_create_params.rbi +386 -0
  105. data/rbi/surge_api/models/contact.rbi +88 -0
  106. data/rbi/surge_api/models/contact_create_params.rbi +87 -0
  107. data/rbi/surge_api/models/contact_retrieve_params.rbi +27 -0
  108. data/rbi/surge_api/models/contact_update_params.rbi +87 -0
  109. data/rbi/surge_api/models/conversation_created_webhook_event.rbi +129 -0
  110. data/rbi/surge_api/models/error.rbi +51 -0
  111. data/rbi/surge_api/models/message.rbi +283 -0
  112. data/rbi/surge_api/models/message_create_params.rbi +281 -0
  113. data/rbi/surge_api/models/message_delivered_webhook_event.rbi +331 -0
  114. data/rbi/surge_api/models/message_failed_webhook_event.rbi +335 -0
  115. data/rbi/surge_api/models/message_received_webhook_event.rbi +331 -0
  116. data/rbi/surge_api/models/message_sent_webhook_event.rbi +322 -0
  117. data/rbi/surge_api/models/organization.rbi +649 -0
  118. data/rbi/surge_api/models/phone_number.rbi +72 -0
  119. data/rbi/surge_api/models/phone_number_purchase_params.rbi +122 -0
  120. data/rbi/surge_api/models/unwrap_webhook_event.rbi +26 -0
  121. data/rbi/surge_api/models/user.rbi +80 -0
  122. data/rbi/surge_api/models/user_create_params.rbi +76 -0
  123. data/rbi/surge_api/models/user_create_token_params.rbi +46 -0
  124. data/rbi/surge_api/models/user_retrieve_params.rbi +27 -0
  125. data/rbi/surge_api/models/user_token_response.rbi +31 -0
  126. data/rbi/surge_api/models/user_update_params.rbi +76 -0
  127. data/rbi/surge_api/models/verification.rbi +86 -0
  128. data/rbi/surge_api/models/verification_check.rbi +84 -0
  129. data/rbi/surge_api/models/verification_check_params.rbi +40 -0
  130. data/rbi/surge_api/models/verification_create_params.rbi +40 -0
  131. data/rbi/surge_api/models/webhook_unwrap_params.rbi +27 -0
  132. data/rbi/surge_api/models.rbi +80 -0
  133. data/rbi/surge_api/request_options.rbi +59 -0
  134. data/rbi/surge_api/resources/accounts.rbi +94 -0
  135. data/rbi/surge_api/resources/blasts.rbi +48 -0
  136. data/rbi/surge_api/resources/campaigns.rbi +115 -0
  137. data/rbi/surge_api/resources/contacts.rbi +85 -0
  138. data/rbi/surge_api/resources/messages.rbi +72 -0
  139. data/rbi/surge_api/resources/phone_numbers.rbi +43 -0
  140. data/rbi/surge_api/resources/users.rbi +96 -0
  141. data/rbi/surge_api/resources/verifications.rbi +43 -0
  142. data/rbi/surge_api/resources/webhooks.rbi +31 -0
  143. data/rbi/surge_api/version.rbi +5 -0
  144. data/sig/surge_api/client.rbs +42 -0
  145. data/sig/surge_api/errors.rbs +117 -0
  146. data/sig/surge_api/file_part.rbs +21 -0
  147. data/sig/surge_api/internal/transport/base_client.rbs +131 -0
  148. data/sig/surge_api/internal/transport/pooled_net_requester.rbs +45 -0
  149. data/sig/surge_api/internal/type/array_of.rbs +48 -0
  150. data/sig/surge_api/internal/type/base_model.rbs +102 -0
  151. data/sig/surge_api/internal/type/base_page.rbs +24 -0
  152. data/sig/surge_api/internal/type/boolean.rbs +26 -0
  153. data/sig/surge_api/internal/type/converter.rbs +79 -0
  154. data/sig/surge_api/internal/type/enum.rbs +32 -0
  155. data/sig/surge_api/internal/type/file_input.rbs +25 -0
  156. data/sig/surge_api/internal/type/hash_of.rbs +48 -0
  157. data/sig/surge_api/internal/type/request_parameters.rbs +17 -0
  158. data/sig/surge_api/internal/type/union.rbs +52 -0
  159. data/sig/surge_api/internal/type/unknown.rbs +26 -0
  160. data/sig/surge_api/internal/util.rbs +185 -0
  161. data/sig/surge_api/internal.rbs +9 -0
  162. data/sig/surge_api/models/account.rbs +40 -0
  163. data/sig/surge_api/models/account_create_params.rbs +433 -0
  164. data/sig/surge_api/models/account_retrieve_status_params.rbs +40 -0
  165. data/sig/surge_api/models/account_status.rbs +71 -0
  166. data/sig/surge_api/models/account_update_params.rbs +435 -0
  167. data/sig/surge_api/models/blast.rbs +64 -0
  168. data/sig/surge_api/models/blast_create_params.rbs +82 -0
  169. data/sig/surge_api/models/call_ended_webhook_event.rbs +99 -0
  170. data/sig/surge_api/models/campaign.rbs +122 -0
  171. data/sig/surge_api/models/campaign_approved_webhook_event.rbs +67 -0
  172. data/sig/surge_api/models/campaign_create_params.rbs +127 -0
  173. data/sig/surge_api/models/contact.rbs +53 -0
  174. data/sig/surge_api/models/contact_create_params.rbs +54 -0
  175. data/sig/surge_api/models/contact_retrieve_params.rbs +15 -0
  176. data/sig/surge_api/models/contact_update_params.rbs +54 -0
  177. data/sig/surge_api/models/conversation_created_webhook_event.rbs +62 -0
  178. data/sig/surge_api/models/error.rbs +27 -0
  179. data/sig/surge_api/models/message.rbs +138 -0
  180. data/sig/surge_api/models/message_create_params.rbs +140 -0
  181. data/sig/surge_api/models/message_delivered_webhook_event.rbs +143 -0
  182. data/sig/surge_api/models/message_failed_webhook_event.rbs +148 -0
  183. data/sig/surge_api/models/message_received_webhook_event.rbs +143 -0
  184. data/sig/surge_api/models/message_sent_webhook_event.rbs +143 -0
  185. data/sig/surge_api/models/organization.rbs +385 -0
  186. data/sig/surge_api/models/phone_number.rbs +37 -0
  187. data/sig/surge_api/models/phone_number_purchase_params.rbs +62 -0
  188. data/sig/surge_api/models/unwrap_webhook_event.rbs +18 -0
  189. data/sig/surge_api/models/user.rbs +48 -0
  190. data/sig/surge_api/models/user_create_params.rbs +47 -0
  191. data/sig/surge_api/models/user_create_token_params.rbs +26 -0
  192. data/sig/surge_api/models/user_retrieve_params.rbs +15 -0
  193. data/sig/surge_api/models/user_token_response.rbs +15 -0
  194. data/sig/surge_api/models/user_update_params.rbs +47 -0
  195. data/sig/surge_api/models/verification.rbs +48 -0
  196. data/sig/surge_api/models/verification_check.rbs +45 -0
  197. data/sig/surge_api/models/verification_check_params.rbs +23 -0
  198. data/sig/surge_api/models/verification_create_params.rbs +23 -0
  199. data/sig/surge_api/models/webhook_unwrap_params.rbs +15 -0
  200. data/sig/surge_api/models.rbs +77 -0
  201. data/sig/surge_api/request_options.rbs +34 -0
  202. data/sig/surge_api/resources/accounts.rbs +30 -0
  203. data/sig/surge_api/resources/blasts.rbs +19 -0
  204. data/sig/surge_api/resources/campaigns.rbs +21 -0
  205. data/sig/surge_api/resources/contacts.rbs +32 -0
  206. data/sig/surge_api/resources/messages.rbs +18 -0
  207. data/sig/surge_api/resources/phone_numbers.rbs +16 -0
  208. data/sig/surge_api/resources/users.rbs +36 -0
  209. data/sig/surge_api/resources/verifications.rbs +18 -0
  210. data/sig/surge_api/resources/webhooks.rbs +17 -0
  211. data/sig/surge_api/version.rbs +3 -0
  212. metadata +269 -0
@@ -0,0 +1,72 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Resources
5
+ class Messages
6
+ # Creates and enqueues a new message to be sent.
7
+ #
8
+ # Messages are always sent asynchronously. When you hit this endpoint, the message
9
+ # will be created within Surge's system and enqueued for sending, and then the id
10
+ # for the new message will be returned. When the message is actually sent, a
11
+ # `message.sent` webhook event will be triggered and sent to any webhook endpoints
12
+ # that you have subscribed to this event type. Then a `message.delivered` webhook
13
+ # event will be triggered when the carrier sends us a delivery receipt.
14
+ #
15
+ # By default all messages will be sent immediately. If you would like to schedule
16
+ # sending for some time up to 60 days in the future, you can do that by providing
17
+ # a value for the `send_at` field. This should be formatted as an ISO8601 datetime
18
+ # like `2028-10-14T18:06:00Z`.
19
+ #
20
+ # You must include either a `body` or `attachments` field (or both) in the request
21
+ # body. The `body` field should contain the text of the message you want to send,
22
+ # and the `attachments` field should be an array of objects with a `url` field
23
+ # pointing to the file you want to attach. Surge will download these files and
24
+ # send them as attachments in the message.
25
+ #
26
+ # You can provide either a `conversation` object or a `to` field to specify the
27
+ # intended recipient of the message, but an error will be returned if both fields
28
+ # are provided. Similarly the `from` field cannot be used together with the
29
+ # `conversation` field, and `conversation.phone_number` should be specified
30
+ # instead.
31
+ sig do
32
+ params(
33
+ account_id: String,
34
+ conversation: SurgeAPI::MessageCreateParams::Conversation::OrHash,
35
+ to: String,
36
+ attachments:
37
+ T::Array[SurgeAPI::MessageCreateParams::Attachment::OrHash],
38
+ body: String,
39
+ send_at: Time,
40
+ from: String,
41
+ request_options: SurgeAPI::RequestOptions::OrHash
42
+ ).returns(SurgeAPI::Message)
43
+ end
44
+ def create(
45
+ # The account from which the message should be sent.
46
+ account_id,
47
+ # Params for selecting or creating a new conversation. Either the id or the
48
+ # Contact must be given.
49
+ conversation:,
50
+ # The recipient's phone number in E.164 format. Cannot be used together with
51
+ # 'conversation'.
52
+ to:,
53
+ attachments: nil,
54
+ # The message body.
55
+ body: nil,
56
+ # An optional datetime for scheduling message up to a couple of months in the
57
+ # future.
58
+ send_at: nil,
59
+ # The sender's phone number in E.164 format or phone number ID. If omitted, uses
60
+ # the account's default phone number. Cannot be used together with 'conversation'.
61
+ from: nil,
62
+ request_options: {}
63
+ )
64
+ end
65
+
66
+ # @api private
67
+ sig { params(client: SurgeAPI::Client).returns(T.attached_class) }
68
+ def self.new(client:)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,43 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Resources
5
+ class PhoneNumbers
6
+ # Purchase a new phone number for the account. You can specify search criteria or
7
+ # let the system select a random number.
8
+ sig do
9
+ params(
10
+ account_id: String,
11
+ area_code: String,
12
+ latitude: Float,
13
+ longitude: Float,
14
+ type: SurgeAPI::PhoneNumberPurchaseParams::Type::OrSymbol,
15
+ request_options: SurgeAPI::RequestOptions::OrHash
16
+ ).returns(SurgeAPI::PhoneNumber)
17
+ end
18
+ def purchase(
19
+ # The account for which the phone number should be created.
20
+ account_id,
21
+ # The desired area code for this phone number. If provided without type, the type
22
+ # will be inferred.
23
+ area_code: nil,
24
+ # Latitude to search for nearby phone numbers. Must be used with longitude. If
25
+ # provided without type, type will be inferred as 'local'.
26
+ latitude: nil,
27
+ # Longitude to search for nearby phone numbers. Must be used with latitude. If
28
+ # provided without type, type will be inferred as 'local'.
29
+ longitude: nil,
30
+ # Whether the phone number is local or toll-free. Can be omitted if area_code or
31
+ # latitude/longitude are provided.
32
+ type: nil,
33
+ request_options: {}
34
+ )
35
+ end
36
+
37
+ # @api private
38
+ sig { params(client: SurgeAPI::Client).returns(T.attached_class) }
39
+ def self.new(client:)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,96 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Resources
5
+ class Users
6
+ # Creates a new User object.
7
+ sig do
8
+ params(
9
+ account_id: String,
10
+ first_name: String,
11
+ last_name: String,
12
+ metadata: T::Hash[Symbol, String],
13
+ photo_url: String,
14
+ request_options: SurgeAPI::RequestOptions::OrHash
15
+ ).returns(SurgeAPI::User)
16
+ end
17
+ def create(
18
+ # The account for which the user should be created.
19
+ account_id,
20
+ # The user's first name.
21
+ first_name:,
22
+ # The user's last name.
23
+ last_name: nil,
24
+ # Set of key-value pairs that will be stored with the object.
25
+ metadata: nil,
26
+ # URL of a photo to be used as the user's avatar.
27
+ photo_url: nil,
28
+ request_options: {}
29
+ )
30
+ end
31
+
32
+ # Retrieves a User object.
33
+ sig do
34
+ params(
35
+ id: String,
36
+ request_options: SurgeAPI::RequestOptions::OrHash
37
+ ).returns(SurgeAPI::User)
38
+ end
39
+ def retrieve(
40
+ # The ID of the user to retrieve.
41
+ id,
42
+ request_options: {}
43
+ )
44
+ end
45
+
46
+ # Updates an existing User object.
47
+ sig do
48
+ params(
49
+ id: String,
50
+ first_name: String,
51
+ last_name: String,
52
+ metadata: T::Hash[Symbol, String],
53
+ photo_url: String,
54
+ request_options: SurgeAPI::RequestOptions::OrHash
55
+ ).returns(SurgeAPI::User)
56
+ end
57
+ def update(
58
+ # The ID of the user to update.
59
+ id,
60
+ # The user's first name.
61
+ first_name:,
62
+ # The user's last name.
63
+ last_name: nil,
64
+ # Set of key-value pairs that will be stored with the object.
65
+ metadata: nil,
66
+ # URL of a photo to be used as the user's avatar.
67
+ photo_url: nil,
68
+ request_options: {}
69
+ )
70
+ end
71
+
72
+ # Provides a mechanism for having Surge create a signed token for embeds instead
73
+ # of signing with your own signing key.
74
+ sig do
75
+ params(
76
+ user_id: String,
77
+ duration_seconds: Integer,
78
+ request_options: SurgeAPI::RequestOptions::OrHash
79
+ ).returns(SurgeAPI::UserTokenResponse)
80
+ end
81
+ def create_token(
82
+ # The user for which the token represents authentication.
83
+ user_id,
84
+ # For how many seconds the token should be accepted. Defaults to 15 minutes.
85
+ duration_seconds: nil,
86
+ request_options: {}
87
+ )
88
+ end
89
+
90
+ # @api private
91
+ sig { params(client: SurgeAPI::Client).returns(T.attached_class) }
92
+ def self.new(client:)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,43 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Resources
5
+ class Verifications
6
+ # Creates a new Verification and sends the code to the given phone number.
7
+ sig do
8
+ params(
9
+ phone_number: String,
10
+ request_options: SurgeAPI::RequestOptions::OrHash
11
+ ).returns(SurgeAPI::Verification)
12
+ end
13
+ def create(
14
+ # The phone number to be verified. In E.164 format.
15
+ phone_number:,
16
+ request_options: {}
17
+ )
18
+ end
19
+
20
+ # Checks the code against a verification.
21
+ sig do
22
+ params(
23
+ id: String,
24
+ code: String,
25
+ request_options: SurgeAPI::RequestOptions::OrHash
26
+ ).returns(SurgeAPI::VerificationCheck)
27
+ end
28
+ def check(
29
+ # The ID of the verification to check against.
30
+ id,
31
+ # The Verification code that was received.
32
+ code:,
33
+ request_options: {}
34
+ )
35
+ end
36
+
37
+ # @api private
38
+ sig { params(client: SurgeAPI::Client).returns(T.attached_class) }
39
+ def self.new(client:)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,31 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Resources
5
+ class Webhooks
6
+ sig do
7
+ params(payload: String).returns(
8
+ T.any(
9
+ SurgeAPI::CallEndedWebhookEvent,
10
+ SurgeAPI::CampaignApprovedWebhookEvent,
11
+ SurgeAPI::ConversationCreatedWebhookEvent,
12
+ SurgeAPI::MessageDeliveredWebhookEvent,
13
+ SurgeAPI::MessageFailedWebhookEvent,
14
+ SurgeAPI::MessageReceivedWebhookEvent,
15
+ SurgeAPI::MessageSentWebhookEvent
16
+ )
17
+ )
18
+ end
19
+ def unwrap(
20
+ # The raw webhook payload as a string
21
+ payload
22
+ )
23
+ end
24
+
25
+ # @api private
26
+ sig { params(client: SurgeAPI::Client).returns(T.attached_class) }
27
+ def self.new(client:)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ VERSION = T.let(T.unsafe(nil), String)
5
+ end
@@ -0,0 +1,42 @@
1
+ module SurgeAPI
2
+ class Client < SurgeAPI::Internal::Transport::BaseClient
3
+ DEFAULT_MAX_RETRIES: 2
4
+
5
+ DEFAULT_TIMEOUT_IN_SECONDS: Float
6
+
7
+ DEFAULT_INITIAL_RETRY_DELAY: Float
8
+
9
+ DEFAULT_MAX_RETRY_DELAY: Float
10
+
11
+ attr_reader api_key: String
12
+
13
+ attr_reader accounts: SurgeAPI::Resources::Accounts
14
+
15
+ attr_reader blasts: SurgeAPI::Resources::Blasts
16
+
17
+ attr_reader campaigns: SurgeAPI::Resources::Campaigns
18
+
19
+ attr_reader contacts: SurgeAPI::Resources::Contacts
20
+
21
+ attr_reader messages: SurgeAPI::Resources::Messages
22
+
23
+ attr_reader phone_numbers: SurgeAPI::Resources::PhoneNumbers
24
+
25
+ attr_reader users: SurgeAPI::Resources::Users
26
+
27
+ attr_reader verifications: SurgeAPI::Resources::Verifications
28
+
29
+ attr_reader webhooks: SurgeAPI::Resources::Webhooks
30
+
31
+ private def auth_headers: -> ::Hash[String, String]
32
+
33
+ def initialize: (
34
+ ?api_key: String?,
35
+ ?base_url: String?,
36
+ ?max_retries: Integer,
37
+ ?timeout: Float,
38
+ ?initial_retry_delay: Float,
39
+ ?max_retry_delay: Float
40
+ ) -> void
41
+ end
42
+ end
@@ -0,0 +1,117 @@
1
+ module SurgeAPI
2
+ module Errors
3
+ class Error < StandardError
4
+ attr_accessor cause: StandardError?
5
+ end
6
+
7
+ class ConversionError < SurgeAPI::Errors::Error
8
+ def cause: -> StandardError?
9
+
10
+ def initialize: (
11
+ on: Class,
12
+ method: Symbol,
13
+ target: top,
14
+ value: top,
15
+ ?cause: StandardError?
16
+ ) -> void
17
+ end
18
+
19
+ class APIError < SurgeAPI::Errors::Error
20
+ attr_accessor url: URI::Generic
21
+
22
+ attr_accessor status: Integer?
23
+
24
+ attr_accessor headers: ::Hash[String, String]?
25
+
26
+ attr_accessor body: top?
27
+
28
+ def initialize: (
29
+ url: URI::Generic,
30
+ ?status: Integer?,
31
+ ?headers: ::Hash[String, String]?,
32
+ ?body: Object?,
33
+ ?request: nil,
34
+ ?response: nil,
35
+ ?message: String?
36
+ ) -> void
37
+ end
38
+
39
+ class APIConnectionError < SurgeAPI::Errors::APIError
40
+ def initialize: (
41
+ url: URI::Generic,
42
+ ?status: nil,
43
+ ?headers: ::Hash[String, String]?,
44
+ ?body: nil,
45
+ ?request: nil,
46
+ ?response: nil,
47
+ ?message: String?
48
+ ) -> void
49
+ end
50
+
51
+ class APITimeoutError < SurgeAPI::Errors::APIConnectionError
52
+ def initialize: (
53
+ url: URI::Generic,
54
+ ?status: nil,
55
+ ?headers: ::Hash[String, String]?,
56
+ ?body: nil,
57
+ ?request: nil,
58
+ ?response: nil,
59
+ ?message: String?
60
+ ) -> void
61
+ end
62
+
63
+ class APIStatusError < SurgeAPI::Errors::APIError
64
+ def self.for: (
65
+ url: URI::Generic,
66
+ status: Integer,
67
+ headers: ::Hash[String, String]?,
68
+ body: Object?,
69
+ request: nil,
70
+ response: nil,
71
+ ?message: String?
72
+ ) -> instance
73
+
74
+ def initialize: (
75
+ url: URI::Generic,
76
+ status: Integer,
77
+ headers: ::Hash[String, String]?,
78
+ body: Object?,
79
+ request: nil,
80
+ response: nil,
81
+ ?message: String?
82
+ ) -> void
83
+ end
84
+
85
+ class BadRequestError < SurgeAPI::Errors::APIStatusError
86
+ HTTP_STATUS: 400
87
+ end
88
+
89
+ class AuthenticationError < SurgeAPI::Errors::APIStatusError
90
+ HTTP_STATUS: 401
91
+ end
92
+
93
+ class PermissionDeniedError < SurgeAPI::Errors::APIStatusError
94
+ HTTP_STATUS: 403
95
+ end
96
+
97
+ class NotFoundError < SurgeAPI::Errors::APIStatusError
98
+ HTTP_STATUS: 404
99
+ end
100
+
101
+ class ConflictError < SurgeAPI::Errors::APIStatusError
102
+ HTTP_STATUS: 409
103
+ end
104
+
105
+ class UnprocessableEntityError < SurgeAPI::Errors::APIStatusError
106
+ HTTP_STATUS: 422
107
+ end
108
+
109
+ class RateLimitError < SurgeAPI::Errors::APIStatusError
110
+ HTTP_STATUS: 429
111
+ end
112
+
113
+ class InternalServerError < SurgeAPI::Errors::APIStatusError
114
+ HTTP_STATUS: Range[Integer]
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,21 @@
1
+ module SurgeAPI
2
+ class FilePart
3
+ attr_reader content: Pathname | StringIO | IO | String
4
+
5
+ attr_reader content_type: String?
6
+
7
+ attr_reader filename: String?
8
+
9
+ private def read: -> String
10
+
11
+ def to_json: (*top a) -> String
12
+
13
+ def to_yaml: (*top a) -> String
14
+
15
+ def initialize: (
16
+ Pathname | StringIO | IO | String content,
17
+ ?filename: String?,
18
+ ?content_type: String?
19
+ ) -> void
20
+ end
21
+ end
@@ -0,0 +1,131 @@
1
+ module SurgeAPI
2
+ module Internal
3
+ module Transport
4
+ class BaseClient
5
+ extend SurgeAPI::Internal::Util::SorbetRuntimeSupport
6
+
7
+ type request_components =
8
+ {
9
+ method: Symbol,
10
+ path: String | ::Array[String],
11
+ query: ::Hash[String, (::Array[String] | String)?]?,
12
+ headers: ::Hash[String, (String
13
+ | Integer
14
+ | ::Array[(String | Integer)?])?]?,
15
+ body: top?,
16
+ unwrap: (Symbol
17
+ | Integer
18
+ | ::Array[(Symbol | Integer)]
19
+ | (^(top arg0) -> top))?,
20
+ page: Class?,
21
+ stream: Class?,
22
+ model: SurgeAPI::Internal::Type::Converter::input?,
23
+ options: SurgeAPI::request_opts?
24
+ }
25
+ type request_input =
26
+ {
27
+ method: Symbol,
28
+ url: URI::Generic,
29
+ headers: ::Hash[String, String],
30
+ body: top,
31
+ max_retries: Integer,
32
+ timeout: Float
33
+ }
34
+
35
+ MAX_REDIRECTS: 20
36
+
37
+ PLATFORM_HEADERS: ::Hash[String, String]
38
+
39
+ def self.validate!: (
40
+ SurgeAPI::Internal::Transport::BaseClient::request_components req
41
+ ) -> void
42
+
43
+ def self.should_retry?: (
44
+ Integer status,
45
+ headers: ::Hash[String, String]
46
+ ) -> bool
47
+
48
+ def self.follow_redirect: (
49
+ SurgeAPI::Internal::Transport::BaseClient::request_input request,
50
+ status: Integer,
51
+ response_headers: ::Hash[String, String]
52
+ ) -> SurgeAPI::Internal::Transport::BaseClient::request_input
53
+
54
+ def self.reap_connection!: (
55
+ Integer | SurgeAPI::Errors::APIConnectionError status,
56
+ stream: Enumerable[String]?
57
+ ) -> void
58
+
59
+ attr_reader base_url: URI::Generic
60
+
61
+ attr_reader timeout: Float
62
+
63
+ attr_reader max_retries: Integer
64
+
65
+ attr_reader initial_retry_delay: Float
66
+
67
+ attr_reader max_retry_delay: Float
68
+
69
+ attr_reader headers: ::Hash[String, String]
70
+
71
+ attr_reader idempotency_header: String?
72
+
73
+ # @api private
74
+ attr_reader requester: SurgeAPI::Internal::Transport::PooledNetRequester
75
+
76
+ def initialize: (
77
+ base_url: String,
78
+ ?timeout: Float,
79
+ ?max_retries: Integer,
80
+ ?initial_retry_delay: Float,
81
+ ?max_retry_delay: Float,
82
+ ?headers: ::Hash[String, (String
83
+ | Integer
84
+ | ::Array[(String | Integer)?])?],
85
+ ?idempotency_header: String?
86
+ ) -> void
87
+
88
+ private def auth_headers: -> ::Hash[String, String]
89
+
90
+ private def generate_idempotency_key: -> String
91
+
92
+ private def build_request: (
93
+ SurgeAPI::Internal::Transport::BaseClient::request_components req,
94
+ SurgeAPI::request_options opts
95
+ ) -> SurgeAPI::Internal::Transport::BaseClient::request_input
96
+
97
+ private def retry_delay: (
98
+ ::Hash[String, String] headers,
99
+ retry_count: Integer
100
+ ) -> Float
101
+
102
+ def send_request: (
103
+ SurgeAPI::Internal::Transport::BaseClient::request_input request,
104
+ redirect_count: Integer,
105
+ retry_count: Integer,
106
+ send_retry_header: bool
107
+ ) -> [Integer, top, Enumerable[String]]
108
+
109
+ def request: (
110
+ Symbol method,
111
+ String | ::Array[String] path,
112
+ ?query: ::Hash[String, (::Array[String] | String)?]?,
113
+ ?headers: ::Hash[String, (String
114
+ | Integer
115
+ | ::Array[(String | Integer)?])?]?,
116
+ ?body: top?,
117
+ ?unwrap: (Symbol
118
+ | Integer
119
+ | ::Array[(Symbol | Integer)]
120
+ | (^(top arg0) -> top))?,
121
+ ?page: Class?,
122
+ ?stream: Class?,
123
+ ?model: SurgeAPI::Internal::Type::Converter::input?,
124
+ ?options: SurgeAPI::request_opts?
125
+ ) -> top
126
+
127
+ def inspect: -> String
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,45 @@
1
+ module SurgeAPI
2
+ module Internal
3
+ module Transport
4
+ class PooledNetRequester
5
+ extend SurgeAPI::Internal::Util::SorbetRuntimeSupport
6
+
7
+ type request =
8
+ {
9
+ method: Symbol,
10
+ url: URI::Generic,
11
+ headers: ::Hash[String, String],
12
+ body: top,
13
+ deadline: Float
14
+ }
15
+
16
+ KEEP_ALIVE_TIMEOUT: 30
17
+
18
+ DEFAULT_MAX_CONNECTIONS: Integer
19
+
20
+ def self.connect: (URI::Generic url) -> top
21
+
22
+ def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
23
+
24
+ def self.build_request: (
25
+ SurgeAPI::Internal::Transport::PooledNetRequester::request request
26
+ ) {
27
+ (String arg0) -> void
28
+ } -> [top, (^-> void)]
29
+
30
+ private def with_pool: (
31
+ URI::Generic url,
32
+ deadline: Float
33
+ ) {
34
+ (top arg0) -> void
35
+ } -> void
36
+
37
+ def execute: (
38
+ SurgeAPI::Internal::Transport::PooledNetRequester::request request
39
+ ) -> [Integer, top, Enumerable[String]]
40
+
41
+ def initialize: (?size: Integer) -> void
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,48 @@
1
+ module SurgeAPI
2
+ module Internal
3
+ module Type
4
+ class ArrayOf[Elem]
5
+ include SurgeAPI::Internal::Type::Converter
6
+ include SurgeAPI::Internal::Util::SorbetRuntimeSupport
7
+
8
+ def self.[]: (
9
+ ::Hash[Symbol, top]
10
+ | ^-> SurgeAPI::Internal::Type::Converter::input
11
+ | SurgeAPI::Internal::Type::Converter::input type_info,
12
+ ?::Hash[Symbol, top] spec
13
+ ) -> instance
14
+
15
+ def ===: (top other) -> bool
16
+
17
+ def ==: (top other) -> bool
18
+
19
+ def hash: -> Integer
20
+
21
+ def coerce: (
22
+ ::Array[top] | top value,
23
+ state: SurgeAPI::Internal::Type::Converter::coerce_state
24
+ ) -> (::Array[top] | top)
25
+
26
+ def dump: (
27
+ ::Array[top] | top value,
28
+ state: SurgeAPI::Internal::Type::Converter::dump_state
29
+ ) -> (::Array[top] | top)
30
+
31
+ def to_sorbet_type: -> top
32
+
33
+ def item_type: -> Elem
34
+
35
+ def nilable?: -> bool
36
+
37
+ def initialize: (
38
+ ::Hash[Symbol, top]
39
+ | ^-> SurgeAPI::Internal::Type::Converter::input
40
+ | SurgeAPI::Internal::Type::Converter::input type_info,
41
+ ?::Hash[Symbol, top] spec
42
+ ) -> void
43
+
44
+ def inspect: (?depth: Integer) -> String
45
+ end
46
+ end
47
+ end
48
+ end