11# Sent Dm TypeScript API Library
22
3- [ ![ NPM version] ( < https://img.shields.io/npm/v/sentdm .svg?label=npm%20(stable) > )] ( https://npmjs.org/package/sentdm ) ![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/sentdm )
3+ [ ![ NPM version] ( < https://img.shields.io/npm/v/sent-dm .svg?label=npm%20(stable) > )] ( https://npmjs.org/package/sent-dm ) ![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/sent-dm )
44
55This library provides convenient access to the Sent Dm REST API from server-side TypeScript or JavaScript.
66
@@ -11,16 +11,19 @@ It is generated with [Stainless](https://www.stainless.com/).
1111## Installation
1212
1313``` sh
14- npm install sentdm
14+ npm install git+ssh://git@github.com:stainless-sdks/sent-dm-typescript.git
1515```
1616
17+ > [ !NOTE]
18+ > Once this package is [ published to npm] ( https://www.stainless.com/docs/guides/publish ) , this will become: ` npm install sent-dm `
19+
1720## Usage
1821
1922The full API of this library can be found in [ api.md] ( api.md ) .
2023
2124<!-- prettier-ignore -->
2225``` js
23- import SentDm from ' sentdm ' ;
26+ import SentDm from ' sent-dm ' ;
2427
2528const client = new SentDm ({
2629 apiKey: process .env [' SENT_DM_API_KEY' ], // This is the default and can be omitted
@@ -30,7 +33,6 @@ const client = new SentDm({
3033await client .messages .sendToPhone ({
3134 phoneNumber: ' +1234567890' ,
3235 templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
33- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
3436});
3537```
3638
@@ -40,7 +42,7 @@ This library includes TypeScript definitions for all request params and response
4042
4143<!-- prettier-ignore -->
4244``` ts
43- import SentDm from ' sentdm ' ;
45+ import SentDm from ' sent-dm ' ;
4446
4547const client = new SentDm ({
4648 apiKey: process .env [' SENT_DM_API_KEY' ], // This is the default and can be omitted
@@ -50,7 +52,6 @@ const client = new SentDm({
5052const params: SentDm .MessageSendToPhoneParams = {
5153 phoneNumber: ' +1234567890' ,
5254 templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
53- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
5455};
5556await client .messages .sendToPhone (params );
5657```
@@ -66,11 +67,7 @@ a subclass of `APIError` will be thrown:
6667<!-- prettier-ignore -->
6768``` ts
6869const response = await client .messages
69- .sendToPhone ({
70- phoneNumber: ' +1234567890' ,
71- templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
72- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
73- })
70+ .sendToPhone ({ phoneNumber: ' +1234567890' , templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
7471 .catch (async (err ) => {
7572 if (err instanceof SentDm .APIError ) {
7673 console .log (err .status ); // 400
@@ -111,11 +108,7 @@ const client = new SentDm({
111108});
112109
113110// Or, configure per-request:
114- await client .messages .sendToPhone ({
115- phoneNumber: ' +1234567890' ,
116- templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
117- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
118- }, {
111+ await client .messages .sendToPhone ({ phoneNumber: ' +1234567890' , templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' }, {
119112 maxRetries: 5 ,
120113});
121114```
@@ -132,11 +125,7 @@ const client = new SentDm({
132125});
133126
134127// Override per-request:
135- await client .messages .sendToPhone ({
136- phoneNumber: ' +1234567890' ,
137- templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
138- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
139- }, {
128+ await client .messages .sendToPhone ({ phoneNumber: ' +1234567890' , templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' }, {
140129 timeout: 5 * 1000 ,
141130});
142131```
@@ -160,21 +149,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
160149const client = new SentDm ();
161150
162151const response = await client .messages
163- .sendToPhone ({
164- phoneNumber: ' +1234567890' ,
165- templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
166- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
167- })
152+ .sendToPhone ({ phoneNumber: ' +1234567890' , templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
168153 .asResponse ();
169154console .log (response .headers .get (' X-My-Header' ));
170155console .log (response .statusText ); // access the underlying Response object
171156
172157const { data : result, response : raw } = await client .messages
173- .sendToPhone ({
174- phoneNumber: ' +1234567890' ,
175- templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' ,
176- templateVariables: { name: ' John Doe' , order_id: ' 12345' },
177- })
158+ .sendToPhone ({ phoneNumber: ' +1234567890' , templateId: ' 7ba7b820-9dad-11d1-80b4-00c04fd430c8' })
178159 .withResponse ();
179160console .log (raw .headers .get (' X-My-Header' ));
180161console .log (result );
@@ -194,7 +175,7 @@ The log level can be configured in two ways:
1941752 . Using the ` logLevel ` client option (overrides the environment variable if set)
195176
196177``` ts
197- import SentDm from ' sentdm ' ;
178+ import SentDm from ' sent-dm ' ;
198179
199180const client = new SentDm ({
200181 logLevel: ' debug' , // Show all log messages
@@ -222,7 +203,7 @@ When providing a custom logger, the `logLevel` option still controls which messa
222203below the configured level will not be sent to your logger.
223204
224205``` ts
225- import SentDm from ' sentdm ' ;
206+ import SentDm from ' sent-dm ' ;
226207import pino from ' pino' ;
227208
228209const logger = pino ();
@@ -291,7 +272,7 @@ globalThis.fetch = fetch;
291272Or pass it to the client:
292273
293274``` ts
294- import SentDm from ' sentdm ' ;
275+ import SentDm from ' sent-dm ' ;
295276import fetch from ' my-fetch' ;
296277
297278const client = new SentDm ({ fetch });
@@ -302,7 +283,7 @@ const client = new SentDm({ fetch });
302283If you want to set custom ` fetch ` options without overriding the ` fetch ` function, you can provide a ` fetchOptions ` object when instantiating the client or making a request. (Request-specific options override client options.)
303284
304285``` ts
305- import SentDm from ' sentdm ' ;
286+ import SentDm from ' sent-dm ' ;
306287
307288const client = new SentDm ({
308289 fetchOptions: {
@@ -319,7 +300,7 @@ options to requests:
319300<img src =" https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg " align =" top " width =" 18 " height =" 21 " > ** Node** <sup >[[ docs] ( https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch )] </sup >
320301
321302``` ts
322- import SentDm from ' sentdm ' ;
303+ import SentDm from ' sent-dm ' ;
323304import * as undici from ' undici' ;
324305
325306const proxyAgent = new undici .ProxyAgent (' http://localhost:8888' );
@@ -333,7 +314,7 @@ const client = new SentDm({
333314<img src =" https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg " align =" top " width =" 18 " height =" 21 " > ** Bun** <sup >[[ docs] ( https://bun.sh/guides/http/proxy )] </sup >
334315
335316``` ts
336- import SentDm from ' sentdm ' ;
317+ import SentDm from ' sent-dm ' ;
337318
338319const client = new SentDm ({
339320 fetchOptions: {
@@ -345,7 +326,7 @@ const client = new SentDm({
345326<img src =" https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg " align =" top " width =" 18 " height =" 21 " > ** Deno** <sup >[[ docs] ( https://docs.deno.com/api/deno/~/Deno.createHttpClient )] </sup >
346327
347328``` ts
348- import SentDm from ' npm:sentdm ' ;
329+ import SentDm from ' npm:sent-dm ' ;
349330
350331const httpClient = Deno .createHttpClient ({ proxy: { url: ' http://localhost:8888' } });
351332const client = new SentDm ({
@@ -367,7 +348,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
367348
368349We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
369350
370- We are keen for your feedback; please open an [ issue] ( https://www.github.com/sentdm /sent-dm-typescript/issues ) with questions, bugs, or suggestions.
351+ We are keen for your feedback; please open an [ issue] ( https://www.github.com/stainless-sdks /sent-dm-typescript/issues ) with questions, bugs, or suggestions.
371352
372353## Requirements
373354
0 commit comments