Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: junwen-k/onewaysms-sdk-deno
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.2
Choose a base ref
...
head repository: junwen-k/onewaysms-sdk-deno
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 6 commits
  • 4 files changed
  • 2 contributors

Commits on Jun 1, 2020

  1. Release v0.1.2

    junwen-k committed Jun 1, 2020
    Copy the full SHA
    798e717 View commit details

Commits on Jun 2, 2020

  1. Copy the full SHA
    2474775 View commit details
  2. Remove mod.json

    junwen-k committed Jun 2, 2020
    Copy the full SHA
    ed73f5c View commit details
  3. Copy the full SHA
    f9daf99 View commit details
  4. Log Changelog

    junwen-k committed Jun 2, 2020
    Copy the full SHA
    c77e6d5 View commit details
  5. Merge pull request #5 from junwen-k/remove-mod-json

    Remove mod.json
    junwen-k authored Jun 2, 2020
    Copy the full SHA
    b8d054a View commit details
Showing with 49 additions and 24 deletions.
  1. +10 −0 CHANGELOG.md
  2. +33 −19 README.md
  3. +0 −3 mod.json
  4. +6 −2 oneway.ts
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Improve README.md formatting.

### Removed

- `mod.json` and include constant in `oneway.ts` instead.

## [0.1.2] - 2020-06-01

### Added

- `buildRequestURL` function to generate request URL to access OneWaySMS API.
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
# OneWaySMS SDK for Deno

A non official OneWaySMS SDK written for Deno runtime. Based on the latest [v1.3](http://smsd2.onewaysms.sg/api.pdf) OneWaySMS API documentation.
A non-official OneWaySMS SDK written for Deno runtime. Based on the latest [v1.3](http://smsd2.onewaysms.sg/api.pdf) OneWaySMS API documentation.

[![license](https://img.shields.io/github/license/junwen-k/onewaysms-sdk-deno)](https://raw.githubusercontent.com/junwen-k/onewaysms-sdk-deno/master/LICENSE.txt)

## Installing

1. Import the SDK by using an URL.
Import the SDK by using a URL.

```ts
import {
OneWay,
OneWayError,
OneWayErrorType,
} from "https://deno.land/x/gh:junwen-k:onewaysms-sdk-deno/mod.ts";
```
```ts
import {
OneWay,
OneWayError,
OneWayErrorType,
} from "https://deno.land/x/gh:junwen-k:onewaysms-sdk-deno/mod.ts";
```

1. Initializing a new client.
Include the version tag in the URL to install a specific version of the SDK.

```ts
const svc = new OneWay({
baseURL: "API_BASE_URL",
apiUsername: "API_USERNAME",
apiPassword: "API_PASSWORD",
senderID: "SENDER_ID",
});
```
```ts
import {
OneWay,
OneWayError,
OneWayErrorType,
} from "https://deno.land/x/gh:junwen-k:onewaysms-sdk-deno@v0.1.0/mod.ts";
```

## Usage and Getting Started

### Initializing a new client

Initialize a new client with the exported `OneWay` class. For instance:

```ts
const svc = new OneWay({
baseURL: "API_BASE_URL",
apiUsername: "API_USERNAME",
apiPassword: "API_PASSWORD",
senderID: "SENDER_ID",
});
```

### Use case examples

1. **Send SMS** - Send SMS by calling OneWaySMS API gateway, returning mobile terminating ID(s) if request is successful.

```ts
@@ -70,7 +84,7 @@ A non official OneWaySMS SDK written for Deno runtime. Based on the latest [v1.3

```ts
try {
const data = await svc.checkTransactionStatus({ mtID: MT_ID });
const data = await svc.checkTransactionStatus({ mtID: 145712470 });
switch (data.status) {
case MTTransactionStatus.Success:
// Handle success status
3 changes: 0 additions & 3 deletions mod.json

This file was deleted.

8 changes: 6 additions & 2 deletions oneway.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,11 @@ import {
OneWayError,
OneWayErrorType,
} from "./error.ts";
import { version } from "./mod.json";

/**
* SDK Version constant.
*/
const VERSION = "0.1.2";

// Based on specifications found in http://smsd2.onewaysms.sg/api.pdf.
export class OneWay implements OneWayClient {
@@ -122,7 +126,7 @@ export class OneWay implements OneWayClient {
*/
private async getRequest(requestURL: string): Promise<Response> {
const headers = new Headers();
headers.append("User-Agent", `onewaysms-sdk-deno/${version}`);
headers.set("User-Agent", `onewaysms-sdk-deno/${VERSION}`);
return fetch(requestURL, {
headers,
});