@@ -26,11 +26,13 @@ gem "sent-dm", "~> 0.0.1"
2626require " bundler/setup"
2727require " 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
3537puts (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
4345begin
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+ )
4551rescue 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:
8288sent_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:
96109sent_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
104124On 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
131151result =
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
176198You 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
182208Or, 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
0 commit comments