@payhos/api 2.3.0 → 2.3.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 +45 -53
- package/config.js +1 -1
- package/config.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,68 +4,60 @@
|
|
|
4
4
|
|
|
5
5
|
This API SDK is intended to assist web applications of any kind to interact with the PayHos API server by utilizing its simple schematics. For a more modular usage, this library is designed such that bundlers with tree-shaking is enhanced.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Install @payhos/api via npm by running the following command:
|
|
9
|
-
> `npm install @payhos/api --save`
|
|
7
|
+
# PayHos API SDK
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
Create an instance and call available methods from the instance created.
|
|
9
|
+
PayHos provides a small client SDK to interact with the PayHos API for sending email, SMS and requesting prerendered HTML pages.
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
import { PayHos } from '@payhos/api';
|
|
11
|
+
## Install
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install @payhos/api --save
|
|
15
|
+
```
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
## SMS
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
const sms = payhos.sms;
|
|
24
|
-
const email = payhos.email;
|
|
25
|
-
```
|
|
19
|
+
Use the `sms` helper to send messages.
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
message:
|
|
33
|
-
recipients: [
|
|
34
|
-
senderId:
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// to send SMS
|
|
38
|
-
sms.send(data).then(response => {
|
|
39
|
-
// message(s) sent successfully
|
|
40
|
-
console.log(response);
|
|
41
|
-
}).catch(err => {
|
|
42
|
-
console.log(err);
|
|
21
|
+
```ts
|
|
22
|
+
import { PayHos } from "@payhos/api";
|
|
23
|
+
const payhos = new PayHos("<YOUR_API_TOKEN>");
|
|
24
|
+
|
|
25
|
+
await payhos.sms.send({
|
|
26
|
+
message: "Hello from PayHos",
|
|
27
|
+
recipients: ["+1234567890"],
|
|
28
|
+
senderId: "PayHos",
|
|
43
29
|
});
|
|
44
30
|
```
|
|
45
31
|
|
|
46
32
|
## Email
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
],
|
|
58
|
-
from: {
|
|
59
|
-
name: 'PayHos',
|
|
60
|
-
email: 'test@yourdomain.com'
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// to send email
|
|
65
|
-
email.send(data).then(response => {
|
|
66
|
-
// message(s) sent successfully
|
|
67
|
-
console.log(response);
|
|
68
|
-
}).catch(err => {
|
|
69
|
-
console.log(err);
|
|
33
|
+
|
|
34
|
+
Use the `email` helper to send emails.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { PayHos } from "@payhos/api";
|
|
38
|
+
const payhos = new PayHos("<YOUR_API_TOKEN>");
|
|
39
|
+
|
|
40
|
+
await payhos.email.send({
|
|
41
|
+
subject: "Hi",
|
|
42
|
+
content: "<p>Hello</p>",
|
|
43
|
+
recipients: [{ email: "user@example.com" }],
|
|
44
|
+
from: { name: "PayHos", email: "noreply@payhos.com" },
|
|
70
45
|
});
|
|
71
46
|
```
|
|
47
|
+
|
|
48
|
+
## Prerender
|
|
49
|
+
|
|
50
|
+
Use the `prerender` helper to request a pre-rendered HTML snapshot of a URL.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { PayHos } from "@payhos/api";
|
|
54
|
+
const payhos = new PayHos("<YOUR_API_TOKEN>");
|
|
55
|
+
|
|
56
|
+
const resp = await payhos.prerender.page({
|
|
57
|
+
url: "https://example.com",
|
|
58
|
+
cacheMs: 86400000,
|
|
59
|
+
});
|
|
60
|
+
console.log(resp.result);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
For full API details, see https://docs.payhos.com.
|
package/config.js
CHANGED
package/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAW,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAW,MAAM,CAAC;AAErB,QAAA,OAAO,GAAG,GAAG,CAAC;AAEzB,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;IACvB,eAAO,GAAG,uBAAuB,CAAC;AACpC,CAAC;KAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;IAC/B,eAAO,GAAG,kCAAkC,CAAC;AAC/C,CAAC"}
|