@tc-libs/sms 3.5.0 → 3.6.1
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.
- package/README.md +63 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,63 @@
|
|
|
1
|
-
# sms
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
# @tc-libs/sms
|
|
2
|
+
|
|
3
|
+
Gateway SMS basato su AWS SNS.
|
|
4
|
+
|
|
5
|
+
Il package espone `SmsModule`, enum `SMS_TYPE`, interfaccia `ISmSService` e l'implementazione `SmSAwsSnsService`.
|
|
6
|
+
|
|
7
|
+
## Registrazione
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
SmsModule.register(
|
|
11
|
+
{
|
|
12
|
+
aws: {
|
|
13
|
+
credential: {
|
|
14
|
+
key: process.env.AWS_ACCESS_KEY_ID!,
|
|
15
|
+
secret: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
16
|
+
},
|
|
17
|
+
s3: {
|
|
18
|
+
region: process.env.AWS_REGION!,
|
|
19
|
+
bucket: '',
|
|
20
|
+
baseUrl: '',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
true,
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Nota: l'opzione si chiama `s3`, ma il servizio usa solo `region` per configurare SNS.
|
|
29
|
+
|
|
30
|
+
## Invio SMS
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const sent = await this.smsService.sendSmS(
|
|
34
|
+
'+391234567890',
|
|
35
|
+
'Codice OTP: 123456',
|
|
36
|
+
'MyApp',
|
|
37
|
+
SMS_TYPE.TRANSACTIONAL,
|
|
38
|
+
);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Il metodo:
|
|
42
|
+
|
|
43
|
+
- verifica prima se il numero e opt-out su SNS
|
|
44
|
+
- invia il messaggio con `SenderID`
|
|
45
|
+
- restituisce `true` o `false`
|
|
46
|
+
|
|
47
|
+
## Export pubblici
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import {
|
|
51
|
+
ISmSService,
|
|
52
|
+
SMS_TYPE,
|
|
53
|
+
SmSAwsSnsService,
|
|
54
|
+
SmsModule,
|
|
55
|
+
} from '@tc-libs/sms';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Sviluppo
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
nx build sms
|
|
62
|
+
nx test sms
|
|
63
|
+
```
|