@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 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
- ## Installation
8
- Install @payhos/api via npm by running the following command:
9
- > `npm install @payhos/api --save`
7
+ # PayHos API SDK
10
8
 
11
- ## Usage
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
- ```typescript
15
- import { PayHos } from '@payhos/api';
11
+ ## Install
16
12
 
17
- // or
18
- const { PayHos } = require('@payhos/api');
13
+ ```bash
14
+ npm install @payhos/api --save
15
+ ```
19
16
 
20
- const payhos = new PayHos('<YOUR API TOKEN>');
17
+ ## SMS
21
18
 
22
- // You can access each of PayHos' API features as follows:
23
- const sms = payhos.sms;
24
- const email = payhos.email;
25
- ```
19
+ Use the `sms` helper to send messages.
26
20
 
27
- ## SMS
28
- Visit [Send SMS with PayHos](https://docs.payhos.com/components/sms) for more information on SMS dodumentations.
29
- ```javascript
30
- const sms = payhos.sms;
31
- const data = {
32
- message: 'Hello there, this is a test message from PayHos SDK',
33
- recipients: ['+2348166666666', '+2348055555555'],
34
- senderId: 'PayHos',
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
- For detailed documentations on sending emails with PayHos API and other supported SDKs, visit [Sending Emails](https://docs.payhos.com/components/email) with PayHos
48
- ```javascript
49
- const email = payhos.email;
50
- const data = {
51
- subject: 'Test Email',
52
- content: `Hey <strong>Alice</strong>, this is a test email message from <a href="https://payhos.com">PayHos API Hub</a>`,
53
- customData: {},
54
- recipients: [
55
- {email: 'example@example.com'},
56
- { name: 'Alice', email: 'alice@example.com' }
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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.baseUrl = void 0;
4
- const platform = 'dev';
4
+ const platform = 'prod';
5
5
  exports.baseUrl = 'a';
6
6
  if (platform === 'dev') {
7
7
  exports.baseUrl = 'http://localhost:8850';
package/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAW,KAAK,CAAC;AAEpB,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"}
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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@payhos/api",
3
3
  "description": "An API package for payhos's API built for JavaScript and Typescript developers",
4
- "version": "2.3.0",
4
+ "version": "2.3.1",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {