surge_api 0.16.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +56 -21
- data/lib/surge_api/client.rb +22 -1
- data/lib/surge_api/internal/cursor.rb +2 -2
- data/lib/surge_api/internal/transport/base_client.rb +5 -0
- data/lib/surge_api/internal/util.rb +22 -7
- data/lib/surge_api/models/account_archive_params.rb +9 -1
- data/lib/surge_api/models/account_list_params.rb +34 -0
- data/lib/surge_api/models/account_retrieve_status_params.rb +9 -1
- data/lib/surge_api/models/account_update_params.rb +9 -1
- data/lib/surge_api/models/attachment_get_file_params.rb +9 -1
- data/lib/surge_api/models/audience_add_contact_params.rb +9 -1
- data/lib/surge_api/models/audience_create_params.rb +9 -1
- data/lib/surge_api/models/audience_list_contacts_params.rb +9 -1
- data/lib/surge_api/models/blast_create_params.rb +9 -1
- data/lib/surge_api/models/campaign_create_params.rb +6 -10
- data/lib/surge_api/models/campaign_list_params.rb +9 -1
- data/lib/surge_api/models/campaign_retrieve_params.rb +9 -1
- data/lib/surge_api/models/campaign_update_params.rb +6 -10
- data/lib/surge_api/models/contact_create_params.rb +9 -1
- data/lib/surge_api/models/contact_list_params.rb +9 -1
- data/lib/surge_api/models/contact_retrieve_params.rb +9 -1
- data/lib/surge_api/models/contact_update_params.rb +9 -1
- data/lib/surge_api/models/message.rb +1 -0
- data/lib/surge_api/models/message_create_params.rb +6 -11
- data/lib/surge_api/models/message_delivered_webhook_event.rb +1 -0
- data/lib/surge_api/models/message_failed_webhook_event.rb +1 -0
- data/lib/surge_api/models/message_list_params.rb +9 -1
- data/lib/surge_api/models/message_params.rb +74 -2
- data/lib/surge_api/models/message_received_webhook_event.rb +1 -0
- data/lib/surge_api/models/message_retrieve_params.rb +9 -1
- data/lib/surge_api/models/message_sent_webhook_event.rb +1 -0
- data/lib/surge_api/models/phone_number.rb +1 -1
- data/lib/surge_api/models/phone_number_list_params.rb +9 -1
- data/lib/surge_api/models/phone_number_purchase_params.rb +9 -1
- data/lib/surge_api/models/phone_number_release_params.rb +22 -0
- data/lib/surge_api/models/phone_number_update_params.rb +38 -0
- data/lib/surge_api/models/recording_delete_params.rb +9 -1
- data/lib/surge_api/models/recording_get_file_params.rb +9 -1
- data/lib/surge_api/models/recording_list_params.rb +9 -1
- data/lib/surge_api/models/recording_retrieve_params.rb +9 -1
- data/lib/surge_api/models/user_create_params.rb +9 -1
- data/lib/surge_api/models/user_create_token_params.rb +9 -1
- data/lib/surge_api/models/user_delete_params.rb +9 -1
- data/lib/surge_api/models/user_list_params.rb +9 -1
- data/lib/surge_api/models/user_retrieve_params.rb +9 -1
- data/lib/surge_api/models/user_update_params.rb +9 -1
- data/lib/surge_api/models/verification_check_params.rb +9 -1
- data/lib/surge_api/models/verification_create_params.rb +9 -1
- data/lib/surge_api/models.rb +6 -0
- data/lib/surge_api/resources/accounts.rb +29 -0
- data/lib/surge_api/resources/campaigns.rb +4 -14
- data/lib/surge_api/resources/messages.rb +6 -7
- data/lib/surge_api/resources/phone_numbers.rb +46 -0
- data/lib/surge_api/resources/verifications.rb +7 -4
- data/lib/surge_api/resources/webhooks.rb +11 -1
- data/lib/surge_api/version.rb +1 -1
- data/lib/surge_api.rb +4 -0
- data/rbi/surge_api/client.rbi +6 -0
- data/rbi/surge_api/internal/util.rbi +8 -0
- data/rbi/surge_api/models/account_archive_params.rbi +18 -5
- data/rbi/surge_api/models/account_list_params.rbi +59 -0
- data/rbi/surge_api/models/account_retrieve_status_params.rbi +8 -0
- data/rbi/surge_api/models/account_update_params.rbi +8 -0
- data/rbi/surge_api/models/attachment_get_file_params.rbi +18 -5
- data/rbi/surge_api/models/audience_add_contact_params.rbi +12 -1
- data/rbi/surge_api/models/audience_create_params.rbi +12 -1
- data/rbi/surge_api/models/audience_list_contacts_params.rbi +8 -0
- data/rbi/surge_api/models/blast_create_params.rbi +8 -0
- data/rbi/surge_api/models/campaign_create_params.rbi +7 -27
- data/rbi/surge_api/models/campaign_list_params.rbi +8 -0
- data/rbi/surge_api/models/campaign_retrieve_params.rbi +18 -5
- data/rbi/surge_api/models/campaign_update_params.rbi +7 -27
- data/rbi/surge_api/models/contact_create_params.rbi +8 -0
- data/rbi/surge_api/models/contact_list_params.rbi +8 -0
- data/rbi/surge_api/models/contact_retrieve_params.rbi +18 -5
- data/rbi/surge_api/models/contact_update_params.rbi +8 -0
- data/rbi/surge_api/models/message.rbi +2 -0
- data/rbi/surge_api/models/message_create_params.rbi +7 -29
- data/rbi/surge_api/models/message_delivered_webhook_event.rbi +5 -0
- data/rbi/surge_api/models/message_failed_webhook_event.rbi +5 -0
- data/rbi/surge_api/models/message_list_params.rbi +8 -0
- data/rbi/surge_api/models/message_params.rbi +225 -6
- data/rbi/surge_api/models/message_received_webhook_event.rbi +5 -0
- data/rbi/surge_api/models/message_retrieve_params.rbi +18 -5
- data/rbi/surge_api/models/message_sent_webhook_event.rbi +5 -0
- data/rbi/surge_api/models/phone_number_list_params.rbi +8 -0
- data/rbi/surge_api/models/phone_number_purchase_params.rbi +8 -0
- data/rbi/surge_api/models/phone_number_release_params.rbi +40 -0
- data/rbi/surge_api/models/phone_number_update_params.rbi +65 -0
- data/rbi/surge_api/models/recording_delete_params.rbi +18 -5
- data/rbi/surge_api/models/recording_get_file_params.rbi +18 -5
- data/rbi/surge_api/models/recording_list_params.rbi +8 -0
- data/rbi/surge_api/models/recording_retrieve_params.rbi +18 -5
- data/rbi/surge_api/models/user_create_params.rbi +8 -0
- data/rbi/surge_api/models/user_create_token_params.rbi +8 -0
- data/rbi/surge_api/models/user_delete_params.rbi +18 -5
- data/rbi/surge_api/models/user_list_params.rbi +8 -0
- data/rbi/surge_api/models/user_retrieve_params.rbi +18 -5
- data/rbi/surge_api/models/user_update_params.rbi +8 -0
- data/rbi/surge_api/models/verification_check_params.rbi +12 -1
- data/rbi/surge_api/models/verification_create_params.rbi +12 -1
- data/rbi/surge_api/models.rbi +6 -0
- data/rbi/surge_api/resources/accounts.rbi +18 -0
- data/rbi/surge_api/resources/campaigns.rbi +10 -2
- data/rbi/surge_api/resources/messages.rbi +9 -1
- data/rbi/surge_api/resources/phone_numbers.rbi +34 -0
- data/rbi/surge_api/resources/verifications.rbi +5 -1
- data/rbi/surge_api/resources/webhooks.rbi +10 -2
- data/sig/surge_api/client.rbs +3 -0
- data/sig/surge_api/internal/util.rbs +4 -0
- data/sig/surge_api/models/account_archive_params.rbs +8 -3
- data/sig/surge_api/models/account_list_params.rbs +32 -0
- data/sig/surge_api/models/account_retrieve_status_params.rbs +5 -0
- data/sig/surge_api/models/account_update_params.rbs +5 -0
- data/sig/surge_api/models/attachment_get_file_params.rbs +11 -3
- data/sig/surge_api/models/audience_add_contact_params.rbs +10 -2
- data/sig/surge_api/models/audience_create_params.rbs +6 -1
- data/sig/surge_api/models/audience_list_contacts_params.rbs +5 -1
- data/sig/surge_api/models/blast_create_params.rbs +5 -0
- data/sig/surge_api/models/campaign_create_params.rbs +4 -9
- data/sig/surge_api/models/campaign_list_params.rbs +5 -1
- data/sig/surge_api/models/campaign_retrieve_params.rbs +8 -3
- data/sig/surge_api/models/campaign_update_params.rbs +4 -12
- data/sig/surge_api/models/contact_create_params.rbs +5 -0
- data/sig/surge_api/models/contact_list_params.rbs +5 -1
- data/sig/surge_api/models/contact_retrieve_params.rbs +8 -3
- data/sig/surge_api/models/contact_update_params.rbs +5 -0
- data/sig/surge_api/models/message.rbs +2 -1
- data/sig/surge_api/models/message_create_params.rbs +4 -9
- data/sig/surge_api/models/message_delivered_webhook_event.rbs +2 -1
- data/sig/surge_api/models/message_failed_webhook_event.rbs +2 -1
- data/sig/surge_api/models/message_list_params.rbs +5 -1
- data/sig/surge_api/models/message_params.rbs +88 -6
- data/sig/surge_api/models/message_received_webhook_event.rbs +2 -1
- data/sig/surge_api/models/message_retrieve_params.rbs +8 -3
- data/sig/surge_api/models/message_sent_webhook_event.rbs +2 -1
- data/sig/surge_api/models/phone_number_list_params.rbs +5 -1
- data/sig/surge_api/models/phone_number_purchase_params.rbs +5 -0
- data/sig/surge_api/models/phone_number_release_params.rbs +20 -0
- data/sig/surge_api/models/phone_number_update_params.rbs +36 -0
- data/sig/surge_api/models/recording_delete_params.rbs +8 -3
- data/sig/surge_api/models/recording_get_file_params.rbs +11 -3
- data/sig/surge_api/models/recording_list_params.rbs +5 -1
- data/sig/surge_api/models/recording_retrieve_params.rbs +8 -3
- data/sig/surge_api/models/user_create_params.rbs +5 -0
- data/sig/surge_api/models/user_create_token_params.rbs +5 -1
- data/sig/surge_api/models/user_delete_params.rbs +8 -3
- data/sig/surge_api/models/user_list_params.rbs +5 -1
- data/sig/surge_api/models/user_retrieve_params.rbs +8 -3
- data/sig/surge_api/models/user_update_params.rbs +5 -0
- data/sig/surge_api/models/verification_check_params.rbs +6 -1
- data/sig/surge_api/models/verification_create_params.rbs +6 -1
- data/sig/surge_api/models.rbs +6 -0
- data/sig/surge_api/resources/accounts.rbs +6 -0
- data/sig/surge_api/resources/campaigns.rbs +2 -2
- data/sig/surge_api/resources/messages.rbs +1 -1
- data/sig/surge_api/resources/phone_numbers.rbs +12 -0
- data/sig/surge_api/resources/verifications.rbs +1 -0
- data/sig/surge_api/resources/webhooks.rbs +3 -1
- metadata +25 -2
|
@@ -7,6 +7,12 @@ 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 ID to list users for.
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
required :account_id, String
|
|
15
|
+
|
|
10
16
|
# @!attribute after
|
|
11
17
|
# Cursor for forward pagination. Use the next_cursor from a previous response.
|
|
12
18
|
#
|
|
@@ -20,10 +26,12 @@ module SurgeAPI
|
|
|
20
26
|
# @return [String, nil]
|
|
21
27
|
optional :before, String
|
|
22
28
|
|
|
23
|
-
# @!method initialize(after: nil, before: nil, request_options: {})
|
|
29
|
+
# @!method initialize(account_id:, after: nil, before: nil, request_options: {})
|
|
24
30
|
# Some parameter documentations has been truncated, see
|
|
25
31
|
# {SurgeAPI::Models::UserListParams} for more details.
|
|
26
32
|
#
|
|
33
|
+
# @param account_id [String] The account ID to list users for.
|
|
34
|
+
#
|
|
27
35
|
# @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
|
|
28
36
|
#
|
|
29
37
|
# @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
|
|
@@ -7,7 +7,15 @@ module SurgeAPI
|
|
|
7
7
|
extend SurgeAPI::Internal::Type::RequestParameters::Converter
|
|
8
8
|
include SurgeAPI::Internal::Type::RequestParameters
|
|
9
9
|
|
|
10
|
-
# @!
|
|
10
|
+
# @!attribute id
|
|
11
|
+
# The ID of the user to retrieve.
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
required :id, String
|
|
15
|
+
|
|
16
|
+
# @!method initialize(id:, request_options: {})
|
|
17
|
+
# @param id [String] The ID of the user to retrieve.
|
|
18
|
+
#
|
|
11
19
|
# @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
|
|
12
20
|
end
|
|
13
21
|
end
|
|
@@ -7,6 +7,12 @@ 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 user to update.
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
required :id, String
|
|
15
|
+
|
|
10
16
|
# @!attribute first_name
|
|
11
17
|
# The user's first name.
|
|
12
18
|
#
|
|
@@ -31,7 +37,9 @@ module SurgeAPI
|
|
|
31
37
|
# @return [String, nil]
|
|
32
38
|
optional :photo_url, String
|
|
33
39
|
|
|
34
|
-
# @!method initialize(first_name:, last_name: nil, metadata: nil, photo_url: nil, request_options: {})
|
|
40
|
+
# @!method initialize(id:, first_name:, last_name: nil, metadata: nil, photo_url: nil, request_options: {})
|
|
41
|
+
# @param id [String] The ID of the user to update.
|
|
42
|
+
#
|
|
35
43
|
# @param first_name [String] The user's first name.
|
|
36
44
|
#
|
|
37
45
|
# @param last_name [String] The user's last name.
|
|
@@ -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}]
|
data/lib/surge_api/models.rb
CHANGED
|
@@ -45,6 +45,8 @@ module SurgeAPI
|
|
|
45
45
|
|
|
46
46
|
AccountCreateParams = SurgeAPI::Models::AccountCreateParams
|
|
47
47
|
|
|
48
|
+
AccountListParams = SurgeAPI::Models::AccountListParams
|
|
49
|
+
|
|
48
50
|
AccountRetrieveStatusParams = SurgeAPI::Models::AccountRetrieveStatusParams
|
|
49
51
|
|
|
50
52
|
AccountStatus = SurgeAPI::Models::AccountStatus
|
|
@@ -127,6 +129,10 @@ module SurgeAPI
|
|
|
127
129
|
|
|
128
130
|
PhoneNumberPurchaseParams = SurgeAPI::Models::PhoneNumberPurchaseParams
|
|
129
131
|
|
|
132
|
+
PhoneNumberReleaseParams = SurgeAPI::Models::PhoneNumberReleaseParams
|
|
133
|
+
|
|
134
|
+
PhoneNumberUpdateParams = SurgeAPI::Models::PhoneNumberUpdateParams
|
|
135
|
+
|
|
130
136
|
RecordingCompletedWebhookEvent = SurgeAPI::Models::RecordingCompletedWebhookEvent
|
|
131
137
|
|
|
132
138
|
RecordingDeleteParams = SurgeAPI::Models::RecordingDeleteParams
|
|
@@ -67,6 +67,35 @@ module SurgeAPI
|
|
|
67
67
|
)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
# Some parameter documentations has been truncated, see
|
|
71
|
+
# {SurgeAPI::Models::AccountListParams} for more details.
|
|
72
|
+
#
|
|
73
|
+
# List all accounts for the calling platform with cursor-based pagination.
|
|
74
|
+
#
|
|
75
|
+
# @overload list(after: nil, before: nil, request_options: {})
|
|
76
|
+
#
|
|
77
|
+
# @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
|
|
78
|
+
#
|
|
79
|
+
# @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
|
|
80
|
+
#
|
|
81
|
+
# @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
82
|
+
#
|
|
83
|
+
# @return [SurgeAPI::Internal::Cursor<SurgeAPI::Models::Account>]
|
|
84
|
+
#
|
|
85
|
+
# @see SurgeAPI::Models::AccountListParams
|
|
86
|
+
def list(params = {})
|
|
87
|
+
parsed, options = SurgeAPI::AccountListParams.dump_request(params)
|
|
88
|
+
query = SurgeAPI::Internal::Util.encode_query_params(parsed)
|
|
89
|
+
@client.request(
|
|
90
|
+
method: :get,
|
|
91
|
+
path: "accounts",
|
|
92
|
+
query: query,
|
|
93
|
+
page: SurgeAPI::Internal::Cursor,
|
|
94
|
+
model: SurgeAPI::Account,
|
|
95
|
+
options: options
|
|
96
|
+
)
|
|
97
|
+
end
|
|
98
|
+
|
|
70
99
|
# Archives an account and releases all associated resources.
|
|
71
100
|
#
|
|
72
101
|
# **Warning**: This action will:
|
|
@@ -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
|
|
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
|
data/lib/surge_api/version.rb
CHANGED
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"
|
|
@@ -58,6 +59,7 @@ require_relative "surge_api/models/message_params"
|
|
|
58
59
|
require_relative "surge_api/models/account"
|
|
59
60
|
require_relative "surge_api/models/account_archive_params"
|
|
60
61
|
require_relative "surge_api/models/account_create_params"
|
|
62
|
+
require_relative "surge_api/models/account_list_params"
|
|
61
63
|
require_relative "surge_api/models/account_retrieve_status_params"
|
|
62
64
|
require_relative "surge_api/models/account_status"
|
|
63
65
|
require_relative "surge_api/models/account_update_params"
|
|
@@ -99,6 +101,8 @@ require_relative "surge_api/models/phone_number"
|
|
|
99
101
|
require_relative "surge_api/models/phone_number_attached_to_campaign_webhook_event"
|
|
100
102
|
require_relative "surge_api/models/phone_number_list_params"
|
|
101
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"
|
|
102
106
|
require_relative "surge_api/models/recording_completed_webhook_event"
|
|
103
107
|
require_relative "surge_api/models/recording_delete_params"
|
|
104
108
|
require_relative "surge_api/models/recording_delete_response"
|
data/rbi/surge_api/client.rbi
CHANGED
|
@@ -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(
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
params(
|
|
20
|
+
id: String,
|
|
21
|
+
request_options: SurgeAPI::RequestOptions::OrHash
|
|
22
|
+
).returns(T.attached_class)
|
|
18
23
|
end
|
|
19
|
-
def self.new(
|
|
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
|
|
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
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module SurgeAPI
|
|
4
|
+
module Models
|
|
5
|
+
class AccountListParams < SurgeAPI::Internal::Type::BaseModel
|
|
6
|
+
extend SurgeAPI::Internal::Type::RequestParameters::Converter
|
|
7
|
+
include SurgeAPI::Internal::Type::RequestParameters
|
|
8
|
+
|
|
9
|
+
OrHash =
|
|
10
|
+
T.type_alias do
|
|
11
|
+
T.any(SurgeAPI::AccountListParams, SurgeAPI::Internal::AnyHash)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Cursor for forward pagination. Use the next_cursor from a previous response.
|
|
15
|
+
sig { returns(T.nilable(String)) }
|
|
16
|
+
attr_reader :after
|
|
17
|
+
|
|
18
|
+
sig { params(after: String).void }
|
|
19
|
+
attr_writer :after
|
|
20
|
+
|
|
21
|
+
# Cursor for backward pagination. Use the previous_cursor from a previous
|
|
22
|
+
# response.
|
|
23
|
+
sig { returns(T.nilable(String)) }
|
|
24
|
+
attr_reader :before
|
|
25
|
+
|
|
26
|
+
sig { params(before: String).void }
|
|
27
|
+
attr_writer :before
|
|
28
|
+
|
|
29
|
+
sig do
|
|
30
|
+
params(
|
|
31
|
+
after: String,
|
|
32
|
+
before: String,
|
|
33
|
+
request_options: SurgeAPI::RequestOptions::OrHash
|
|
34
|
+
).returns(T.attached_class)
|
|
35
|
+
end
|
|
36
|
+
def self.new(
|
|
37
|
+
# Cursor for forward pagination. Use the next_cursor from a previous response.
|
|
38
|
+
after: nil,
|
|
39
|
+
# Cursor for backward pagination. Use the previous_cursor from a previous
|
|
40
|
+
# response.
|
|
41
|
+
before: nil,
|
|
42
|
+
request_options: {}
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
sig do
|
|
47
|
+
override.returns(
|
|
48
|
+
{
|
|
49
|
+
after: String,
|
|
50
|
+
before: String,
|
|
51
|
+
request_options: SurgeAPI::RequestOptions
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
def to_hash
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
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(
|
|
16
|
-
|
|
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(
|
|
24
|
+
def self.new(
|
|
25
|
+
# The ID of the attachment.
|
|
26
|
+
attachment_id:,
|
|
27
|
+
request_options: {}
|
|
28
|
+
)
|
|
20
29
|
end
|
|
21
30
|
|
|
22
|
-
sig
|
|
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
|