Skip to content

Commit 2b888e6

Browse files
feat(api): manual updates
1 parent 41ff31c commit 2b888e6

File tree

69 files changed

+1117
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1117
-376
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 19
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-2526b6ca490323393bd93f041268aa85f1d36bed4a639ecb3e72e7cd6f51e40d.yml
33
openapi_spec_hash: 9f1e88c960a9057b40df68c059b640b8
4-
config_hash: 094d0205ec5660f35d72c520c81ae8eb
4+
config_hash: 558220e713f3aff5906078014139c92d

README.md

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ gem "sent-dm", "~> 0.0.1"
2626
require "bundler/setup"
2727
require "sent_dm"
2828

29-
sent_dm = SentDm::Client.new(
30-
customer_auth_scheme: ENV["SENT_DM_CUSTOMER_AUTH_SCHEME"] # This is the default and can be omitted
31-
)
29+
sent_dm = SentDm::Client.new(api_key: "My API Key", sender_id: "My Sender ID")
3230

33-
result = sent_dm.templates.delete("REPLACE_ME")
31+
result = sent_dm.messages.send_to_phone(
32+
phone_number: "+1234567890",
33+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
34+
x_sender_id: "00000000-0000-0000-0000-000000000000"
35+
)
3436

3537
puts(result)
3638
```
@@ -41,7 +43,11 @@ When the library is unable to connect to the API, or if the API returns a non-su
4143

4244
```ruby
4345
begin
44-
template = sent_dm.templates.delete("REPLACE_ME")
46+
message = sent_dm.messages.send_to_phone(
47+
phone_number: "+1234567890",
48+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
49+
x_sender_id: "00000000-0000-0000-0000-000000000000"
50+
)
4551
rescue SentDm::Errors::APIConnectionError => e
4652
puts("The server could not be reached")
4753
puts(e.cause) # an underlying Exception, likely raised within `net/http`
@@ -80,11 +86,18 @@ You can use the `max_retries` option to configure or disable this:
8086
```ruby
8187
# Configure the default for all requests:
8288
sent_dm = SentDm::Client.new(
83-
max_retries: 0 # default is 2
89+
max_retries: 0, # default is 2
90+
api_key: "My API Key",
91+
sender_id: "My Sender ID"
8492
)
8593

8694
# Or, configure per-request:
87-
sent_dm.templates.delete("REPLACE_ME", request_options: {max_retries: 5})
95+
sent_dm.messages.send_to_phone(
96+
phone_number: "+1234567890",
97+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
98+
x_sender_id: "00000000-0000-0000-0000-000000000000",
99+
request_options: {max_retries: 5}
100+
)
88101
```
89102

90103
### Timeouts
@@ -94,11 +107,18 @@ By default, requests will time out after 60 seconds. You can use the timeout opt
94107
```ruby
95108
# Configure the default for all requests:
96109
sent_dm = SentDm::Client.new(
97-
timeout: nil # default is 60
110+
timeout: nil, # default is 60
111+
api_key: "My API Key",
112+
sender_id: "My Sender ID"
98113
)
99114

100115
# Or, configure per-request:
101-
sent_dm.templates.delete("REPLACE_ME", request_options: {timeout: 5})
116+
sent_dm.messages.send_to_phone(
117+
phone_number: "+1234567890",
118+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
119+
x_sender_id: "00000000-0000-0000-0000-000000000000",
120+
request_options: {timeout: 5}
121+
)
102122
```
103123

104124
On timeout, `SentDm::Errors::APITimeoutError` is raised.
@@ -129,8 +149,10 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
129149

130150
```ruby
131151
result =
132-
sent_dm.templates.delete(
133-
"REPLACE_ME",
152+
sent_dm.messages.send_to_phone(
153+
phone_number: "+1234567890",
154+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
155+
x_sender_id: "00000000-0000-0000-0000-000000000000",
134156
request_options: {
135157
extra_query: {my_query_parameter: value},
136158
extra_body: {my_body_parameter: value},
@@ -176,18 +198,30 @@ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitio
176198
You can provide typesafe request parameters like so:
177199

178200
```ruby
179-
sent_dm.templates.delete("REPLACE_ME")
201+
sent_dm.messages.send_to_phone(
202+
phone_number: "+1234567890",
203+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
204+
x_sender_id: "00000000-0000-0000-0000-000000000000"
205+
)
180206
```
181207

182208
Or, equivalently:
183209

184210
```ruby
185211
# Hashes work, but are not typesafe:
186-
sent_dm.templates.delete("REPLACE_ME")
212+
sent_dm.messages.send_to_phone(
213+
phone_number: "+1234567890",
214+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
215+
x_sender_id: "00000000-0000-0000-0000-000000000000"
216+
)
187217

188218
# You can also splat a full Params class:
189-
params = SentDm::TemplateDeleteParams.new
190-
sent_dm.templates.delete("REPLACE_ME", **params)
219+
params = SentDm::MessageSendToPhoneParams.new(
220+
phone_number: "+1234567890",
221+
template_id: "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
222+
x_sender_id: "00000000-0000-0000-0000-000000000000"
223+
)
224+
sent_dm.messages.send_to_phone(**params)
191225
```
192226

193227
## Versioning

lib/sent_dm/client.rb

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Client < SentDm::Internal::Transport::BaseClient
1616
DEFAULT_MAX_RETRY_DELAY = 8.0
1717

1818
# @return [String]
19-
attr_reader :admin_auth_scheme
19+
attr_reader :api_key
2020

2121
# @return [String]
22-
attr_reader :customer_auth_scheme
22+
attr_reader :sender_id
2323

2424
# @return [SentDm::Resources::Templates]
2525
attr_reader :templates
@@ -36,32 +36,11 @@ class Client < SentDm::Internal::Transport::BaseClient
3636
# @return [SentDm::Resources::Organizations]
3737
attr_reader :organizations
3838

39-
# @api private
40-
#
41-
# @return [Hash{String=>String}]
42-
private def auth_headers
43-
{**admin_authentication_scheme, **customer_authentication_scheme}
44-
end
45-
46-
# @api private
47-
#
48-
# @return [Hash{String=>String}]
49-
private def admin_authentication_scheme
50-
{"x-api-key" => @admin_auth_scheme}
51-
end
52-
53-
# @api private
54-
#
55-
# @return [Hash{String=>String}]
56-
private def customer_authentication_scheme
57-
{"x-sender-id" => @customer_auth_scheme}
58-
end
59-
6039
# Creates and returns a new client for interacting with the API.
6140
#
62-
# @param admin_auth_scheme [String, nil] Defaults to `ENV["SENT_DM_ADMIN_AUTH_SCHEME"]`
41+
# @param api_key [String, nil] Defaults to `ENV["SENT_DM_API_KEY"]`
6342
#
64-
# @param customer_auth_scheme [String, nil] Defaults to `ENV["SENT_DM_CUSTOMER_AUTH_SCHEME"]`
43+
# @param sender_id [String, nil] Defaults to `ENV["SENT_DM_SENDER_ID"]`
6544
#
6645
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
6746
# `"https://api.example.com/v2/"`. Defaults to `ENV["SENT_DM_BASE_URL"]`
@@ -74,8 +53,8 @@ class Client < SentDm::Internal::Transport::BaseClient
7453
#
7554
# @param max_retry_delay [Float]
7655
def initialize(
77-
admin_auth_scheme: ENV["SENT_DM_ADMIN_AUTH_SCHEME"],
78-
customer_auth_scheme: ENV["SENT_DM_CUSTOMER_AUTH_SCHEME"],
56+
api_key: ENV["SENT_DM_API_KEY"],
57+
sender_id: ENV["SENT_DM_SENDER_ID"],
7958
base_url: ENV["SENT_DM_BASE_URL"],
8059
max_retries: self.class::DEFAULT_MAX_RETRIES,
8160
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
@@ -84,15 +63,15 @@ def initialize(
8463
)
8564
base_url ||= "https://api.sent.dm"
8665

87-
if admin_auth_scheme.nil?
88-
raise ArgumentError.new("admin_auth_scheme is required, and can be set via environ: \"SENT_DM_ADMIN_AUTH_SCHEME\"")
66+
if api_key.nil?
67+
raise ArgumentError.new("api_key is required, and can be set via environ: \"SENT_DM_API_KEY\"")
8968
end
90-
if customer_auth_scheme.nil?
91-
raise ArgumentError.new("customer_auth_scheme is required, and can be set via environ: \"SENT_DM_CUSTOMER_AUTH_SCHEME\"")
69+
if sender_id.nil?
70+
raise ArgumentError.new("sender_id is required, and can be set via environ: \"SENT_DM_SENDER_ID\"")
9271
end
9372

94-
@admin_auth_scheme = admin_auth_scheme.to_s
95-
@customer_auth_scheme = customer_auth_scheme.to_s
73+
@api_key = api_key.to_s
74+
@sender_id = sender_id.to_s
9675

9776
super(
9877
base_url: base_url,

lib/sent_dm/internal/transport/base_client.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ def initialize(
215215
@max_retry_delay = max_retry_delay
216216
end
217217

218-
# @api private
219-
#
220-
# @return [Hash{String=>String}]
221-
private def auth_headers = {}
222-
223218
# @api private
224219
#
225220
# @return [String]
@@ -276,7 +271,6 @@ def initialize(
276271

277272
headers = SentDm::Internal::Util.normalized_headers(
278273
@headers,
279-
auth_headers,
280274
req[:headers].to_h,
281275
opts[:extra_headers].to_h
282276
)

lib/sent_dm/models/contact_list_params.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,25 @@ class ContactListParams < SentDm::Internal::Type::BaseModel
1919
# @return [Integer]
2020
required :page_size, Integer
2121

22-
# @!method initialize(page:, page_size:, request_options: {})
22+
# @!attribute x_api_key
23+
#
24+
# @return [String]
25+
required :x_api_key, String
26+
27+
# @!attribute x_sender_id
28+
#
29+
# @return [String]
30+
required :x_sender_id, String
31+
32+
# @!method initialize(page:, page_size:, x_api_key:, x_sender_id:, request_options: {})
2333
# @param page [Integer] The page number (zero-indexed). Default is 0.
2434
#
2535
# @param page_size [Integer] The number of items per page. Default is 20.
2636
#
37+
# @param x_api_key [String]
38+
#
39+
# @param x_sender_id [String]
40+
#
2741
# @param request_options [SentDm::RequestOptions, Hash{Symbol=>Object}]
2842
end
2943
end

lib/sent_dm/models/contact_retrieve_by_phone_params.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,23 @@ class ContactRetrieveByPhoneParams < SentDm::Internal::Type::BaseModel
1313
# @return [String]
1414
required :phone_number, String
1515

16-
# @!method initialize(phone_number:, request_options: {})
16+
# @!attribute x_api_key
17+
#
18+
# @return [String]
19+
required :x_api_key, String
20+
21+
# @!attribute x_sender_id
22+
#
23+
# @return [String]
24+
required :x_sender_id, String
25+
26+
# @!method initialize(phone_number:, x_api_key:, x_sender_id:, request_options: {})
1727
# @param phone_number [String] The phone number in international format (e.g., +1234567890)
1828
#
29+
# @param x_api_key [String]
30+
#
31+
# @param x_sender_id [String]
32+
#
1933
# @param request_options [SentDm::RequestOptions, Hash{Symbol=>Object}]
2034
end
2135
end

lib/sent_dm/models/contact_retrieve_id_params.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,23 @@ class ContactRetrieveIDParams < SentDm::Internal::Type::BaseModel
1313
# @return [String]
1414
required :id, String
1515

16-
# @!method initialize(id:, request_options: {})
16+
# @!attribute x_api_key
17+
#
18+
# @return [String]
19+
required :x_api_key, String
20+
21+
# @!attribute x_sender_id
22+
#
23+
# @return [String]
24+
required :x_sender_id, String
25+
26+
# @!method initialize(id:, x_api_key:, x_sender_id:, request_options: {})
1727
# @param id [String] The unique identifier (GUID) of the resource to retrieve
1828
#
29+
# @param x_api_key [String]
30+
#
31+
# @param x_sender_id [String]
32+
#
1933
# @param request_options [SentDm::RequestOptions, Hash{Symbol=>Object}]
2034
end
2135
end

lib/sent_dm/models/message_retrieve_params.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ class MessageRetrieveParams < SentDm::Internal::Type::BaseModel
77
extend SentDm::Internal::Type::RequestParameters::Converter
88
include SentDm::Internal::Type::RequestParameters
99

10-
# @!method initialize(request_options: {})
10+
# @!attribute x_api_key
11+
#
12+
# @return [String]
13+
required :x_api_key, String
14+
15+
# @!attribute x_sender_id
16+
#
17+
# @return [String]
18+
required :x_sender_id, String
19+
20+
# @!method initialize(x_api_key:, x_sender_id:, request_options: {})
21+
# @param x_api_key [String]
22+
# @param x_sender_id [String]
1123
# @param request_options [SentDm::RequestOptions, Hash{Symbol=>Object}]
1224
end
1325
end

lib/sent_dm/models/message_send_quick_message_params.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,28 @@ class MessageSendQuickMessageParams < SentDm::Internal::Type::BaseModel
2020
# @return [String]
2121
required :phone_number, String, api_name: :phoneNumber
2222

23-
# @!method initialize(custom_message:, phone_number:, request_options: {})
23+
# @!attribute x_api_key
24+
#
25+
# @return [String]
26+
required :x_api_key, String
27+
28+
# @!attribute x_sender_id
29+
#
30+
# @return [String]
31+
required :x_sender_id, String
32+
33+
# @!method initialize(custom_message:, phone_number:, x_api_key:, x_sender_id:, request_options: {})
2434
# Some parameter documentations has been truncated, see
2535
# {SentDm::Models::MessageSendQuickMessageParams} for more details.
2636
#
2737
# @param custom_message [String] The custom message content to include in the template
2838
#
2939
# @param phone_number [String] The phone number to send the message to, in international format (e.g., +1234567
3040
#
41+
# @param x_api_key [String]
42+
#
43+
# @param x_sender_id [String]
44+
#
3145
# @param request_options [SentDm::RequestOptions, Hash{Symbol=>Object}]
3246
end
3347
end

lib/sent_dm/models/message_send_to_contact_params.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ class MessageSendToContactParams < SentDm::Internal::Type::BaseModel
1919
# @return [String]
2020
required :template_id, String, api_name: :templateId
2121

22+
# @!attribute x_api_key
23+
#
24+
# @return [String]
25+
required :x_api_key, String
26+
27+
# @!attribute x_sender_id
28+
#
29+
# @return [String]
30+
required :x_sender_id, String
31+
2232
# @!attribute template_variables
2333
# Optional key-value pairs of template variables to replace in the template body.
2434
# For example, if your template contains "Hello {{name}}", you would provide {
@@ -30,14 +40,18 @@ class MessageSendToContactParams < SentDm::Internal::Type::BaseModel
3040
api_name: :templateVariables,
3141
nil?: true
3242

33-
# @!method initialize(contact_id:, template_id:, template_variables: nil, request_options: {})
43+
# @!method initialize(contact_id:, template_id:, x_api_key:, x_sender_id:, template_variables: nil, request_options: {})
3444
# Some parameter documentations has been truncated, see
3545
# {SentDm::Models::MessageSendToContactParams} for more details.
3646
#
3747
# @param contact_id [String] The unique identifier of the contact to send the message to
3848
#
3949
# @param template_id [String] The unique identifier of the template to use for the message
4050
#
51+
# @param x_api_key [String]
52+
#
53+
# @param x_sender_id [String]
54+
#
4155
# @param template_variables [Hash{Symbol=>String}, nil] Optional key-value pairs of template variables to replace in the template body.
4256
#
4357
# @param request_options [SentDm::RequestOptions, Hash{Symbol=>Object}]

0 commit comments

Comments
 (0)