|
1 | | -# node-module-boilerplate |
| 1 | +# httpsms-node |
2 | 2 |
|
3 | | -> Boilerplate to kickstart creating a Node.js module |
| 3 | +[](https://www.npmjs.org/package/httpsms) |
| 4 | +[](https://github.com/NdoleStudio/httpsms-node/actions/workflows/main.yml) |
| 5 | +[](https://codecov.io/gh/NdoleStudio/httpsms-node) |
| 6 | +[](https://github.com/NdoleStudio/httpsms-node/graphs/contributors) |
| 7 | +[](https://github.com/NdoleStudio/httpsms-node/blob/master/LICENSE) |
| 8 | +[](https://www.npmjs.com/package/httpsms) |
4 | 9 |
|
5 | | -This is what I use for [my own modules](https://www.npmjs.com/~sindresorhus). |
| 10 | +This httpSMS library provides a server side javascript and typescript client for the [httpSMS](https://httpsms.com/) API. |
6 | 11 |
|
7 | | -Also check out [`node-cli-boilerplate`](https://github.com/sindresorhus/node-cli-boilerplate). |
8 | | - |
9 | | -## Getting started |
10 | | - |
11 | | -**Click the "Use this template" button.** |
12 | | - |
13 | | -Alternatively, create a new directory and then run: |
| 12 | +## Install |
14 | 13 |
|
15 | 14 | ```sh |
16 | | -curl -fsSL https://github.com/sindresorhus/node-module-boilerplate/archive/main.tar.gz | tar -xz --strip-components=1 |
| 15 | +pnpm install httpsms-node |
| 16 | +# or |
| 17 | +npm install httpsms-node |
| 18 | +# or |
| 19 | +yarn install httpsms-node |
17 | 20 | ``` |
18 | 21 |
|
19 | | -There's also a [Yeoman generator](https://github.com/sindresorhus/generator-nm). |
| 22 | +## Implemented |
20 | 23 |
|
21 | | ---- |
| 24 | +- [x] **[MessageService](#messages)** |
| 25 | + - [x] `POST /v1/messages/send`: Send a new SMS |
| 26 | +- [x] **Cipher** |
| 27 | + - [x] `Encrypt`: Encrypt the content of a message to cipher text |
| 28 | + - [x] `Decrypt`: Decrypt an encrypted message content to plain text |
22 | 29 |
|
23 | | -**Remove everything from here and above** |
| 30 | +## Usage |
24 | 31 |
|
25 | | ---- |
| 32 | +### Initializing the Client |
26 | 33 |
|
27 | | -# unicorn-fun |
| 34 | +An instance of the client can be created using `httpsms.New()`. |
28 | 35 |
|
29 | | -> My awesome module |
| 36 | +```go |
| 37 | +package main |
30 | 38 |
|
31 | | -## Install |
| 39 | +import ( |
| 40 | + "github.com/NdoleStudio/httpsms-go" |
| 41 | +) |
32 | 42 |
|
33 | | -```sh |
34 | | -npm install unicorn-fun |
| 43 | +func main() { |
| 44 | + client := htpsms.New(htpsms.WithDelay(200)) |
| 45 | +} |
35 | 46 | ``` |
36 | 47 |
|
37 | | -## Usage |
| 48 | +### Error handling |
38 | 49 |
|
39 | | -```js |
40 | | -import unicornFun from 'unicorn-fun'; |
| 50 | +All API calls return an `error` as the last return object. All successful calls will return a `nil` error. |
41 | 51 |
|
42 | | -unicornFun('unicorns'); |
43 | | -//=> 'unicorns & rainbows' |
| 52 | +```go |
| 53 | +_, response, err := client.MessageService.Send(context.Background()) |
| 54 | +if err != nil { |
| 55 | + //handle error |
| 56 | +} |
44 | 57 | ``` |
45 | 58 |
|
46 | | -## API |
| 59 | +### MessageService |
47 | 60 |
|
48 | | -### unicornFun(input, options?) |
| 61 | +#### `POST /v1/messages/send`: Send a new SMS Message |
49 | 62 |
|
50 | | -#### input |
| 63 | +```go |
| 64 | +message, response, err := client.MessageService.Send(context.Background(), &MessageSendParams{ |
| 65 | + Content: "This is a sample text message", |
| 66 | + From: "+18005550199", |
| 67 | + To: "+18005550100", |
| 68 | +}) |
51 | 69 |
|
52 | | -Type: `string` |
| 70 | +if err != nil { |
| 71 | + log.Fatal(err) |
| 72 | +} |
53 | 73 |
|
54 | | -Lorem ipsum. |
| 74 | +log.Println(message.Code) // 202 |
| 75 | +``` |
55 | 76 |
|
56 | | -#### options |
| 77 | +## Testing |
57 | 78 |
|
58 | | -Type: `object` |
| 79 | +You can run the unit tests for this client from the root directory using the command below: |
59 | 80 |
|
60 | | -##### postfix |
| 81 | +```bash |
| 82 | +go test -v |
| 83 | +``` |
61 | 84 |
|
62 | | -Type: `string`\ |
63 | | -Default: `'rainbows'` |
| 85 | +## License |
64 | 86 |
|
65 | | -Lorem ipsum. |
| 87 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details |
0 commit comments