Skip to content

Commit

Permalink
♻️ refactor: run prettier format
Browse files Browse the repository at this point in the history
  • Loading branch information
fuadop committed May 28, 2022
1 parent 53de0dd commit d81fcd7
Show file tree
Hide file tree
Showing 16 changed files with 775 additions and 754 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- "npm"
- "dependencies"
schedule:
interval: daily
interval: daily
6 changes: 3 additions & 3 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
branches:
- main
pull_request:
jobs:

jobs:
lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -17,4 +17,4 @@ jobs:
cache: "npm"
- run: npm ci
- name: Verify files are prettier-ed
run: npx prettier --check "**/*" --ignore-unknown
run: npx prettier --check "**/*" --ignore-unknown
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"useTabs": true
}
"useTabs": true
}
75 changes: 42 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Run a sendchamp simulator locally, to test your apps using sendchamp API without
- [Timeline](#timeline)
- [Contributing](#contributing)


## Quick start

![summary](/assets/summary.gif)
Expand Down Expand Up @@ -67,39 +66,47 @@ Ideally you would have a constant holding the sendchamp api base url before maki
<br />

## Examples

Pardon me 🙏, I only know how to write nodejs and golang fluently.

**Nodejs with axios**

```javascript
// use simulator url if in dev mode and live url in production
const axios = require("axios");

const BASE_URL = process.env.NODE_ENV === "development" ? "http://localhost:2920" : "https://api.sendchamp.com";
const BASE_URL =
process.env.NODE_ENV === "development"
? "http://localhost:2920"
: "https://api.sendchamp.com";

// Now lets start attacking the endpoints.
// Lets send a text message to one of our simulators phone number.

let options = {
to: "2349153207998",
message: "Pinging my simulator",
sender_name: "Sendchamp",
route: "dnd"
to: "2349153207998",
message: "Pinging my simulator",
sender_name: "Sendchamp",
route: "dnd",
};

axios.post("/api/v1/sms/send", options, {
baseURL: BASE_URL,
headers: {
// this doesn't neccessarily need to be a valid key.. anything works 😜. but if you want to use other endpoints like /wallet/wallet_balance you need to put a valid sendchamp public key, since those endpoints aren't intercepted and they go directly to api.sendchamp.com.
"Authorization": "Bearer <sendchamp_key>",
"Accept": "application/json",
"Content-Type": "application/json"
}
}).then((response) => {
// exactly as sendchamp would respond you 😉
console.log(response);
}).catch((error) => {
console.error(error);
});
axios
.post("/api/v1/sms/send", options, {
baseURL: BASE_URL,
headers: {
// this doesn't neccessarily need to be a valid key.. anything works 😜. but if you want to use other endpoints like /wallet/wallet_balance you need to put a valid sendchamp public key, since those endpoints aren't intercepted and they go directly to api.sendchamp.com.
Authorization: "Bearer <sendchamp_key>",
Accept: "application/json",
"Content-Type": "application/json",
},
})
.then((response) => {
// exactly as sendchamp would respond you 😉
console.log(response);
})
.catch((error) => {
console.error(error);
});
```

Now, let's check the simulator !.
Expand All @@ -116,26 +123,27 @@ And also in the console, we get the regular sendchamp response.
const Sendchamp = require("sendchamp-sdk");

const sendchamp = new Sendchamp({
publicKey: "sk_test_$lkdl$lksd...",
mode: "local-simulator"
publicKey: "sk_test_$lkdl$lksd...",
mode: "local-simulator",
});

const sms = sendchamp.SMS;

const options = {
sender_name: "sendchamp.sdk",
to: "2349153207998",
message: "test from sendchamp-sdk",
route: "dnd"
sender_name: "sendchamp.sdk",
to: "2349153207998",
message: "test from sendchamp-sdk",
route: "dnd",
};

sms.send(options)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
sms
.send(options)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
```

![sendchamp-sdk](/assets/js-sdk.png)
Expand Down Expand Up @@ -259,6 +267,7 @@ Currently the simulator works for all sms based requests. I am looking into also
If you find any bugs or have a feature request, please file an issue on the [issue tracker](https://github.com/fuadop/sendchamp-simulator/issues), I'll be happy to help!.

## Contributing

PRs are greatly appreciated, help us build this hugely needed tool so anyone else can easily test their apps using sendchamp.

1. Create a fork
Expand Down
142 changes: 71 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
{
"name": "sendchamp-simulator",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"files": [
"bin",
"public"
],
"bin": {
"sendchamp-simulator": "./bin/index.js"
},
"scripts": {
"dev": "tsc-watch --onSuccess \"node bin --phone=2348153207998\"",
"build": "rimraf bin && tsc",
"format": "prettier --write \"**/*\" --ignore-unknown"
},
"repository": {
"type": "git",
"url": "git+https://github.com/fuadop/sendchamp-simulator.git"
},
"keywords": [
"otp",
"email",
"sms",
"sendchamp",
"send",
"verification",
"voice",
"call",
"sender"
],
"author": "Fuad Olatunji",
"bugs": {
"url": "https://github.com/fuadop/sendchamp-simulator/issues"
},
"homepage": "https://github.com/fuadop/sendchamp-simulator#readme",
"dependencies": {
"@fuadop/koa-proxy": "^1.0.0",
"@koa/cors": "^3.3.0",
"@koa/router": "^10.1.1",
"@types/uuid": "^8.3.4",
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-json": "^2.0.2",
"koa-logger": "^3.2.1",
"koa-static": "^5.0.0",
"minimist": "^1.2.6",
"minimist-options": "^4.1.0",
"node-cache": "^5.1.2",
"randomatic": "^3.1.1",
"uuid": "^8.3.2",
"ws": "^8.7.0"
},
"devDependencies": {
"@types/koa-bodyparser": "^4.3.7",
"@types/koa-json": "^2.0.20",
"@types/koa-logger": "^3.1.2",
"@types/koa-proxy": "^1.0.4",
"@types/koa-static": "^4.0.2",
"@types/koa__router": "^8.0.11",
"@types/minimist": "^1.2.2",
"@types/node": "^17.0.35",
"@types/randomatic": "^3.1.3",
"@types/ws": "^8.5.3",
"copyfiles": "^2.4.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-node": "^10.8.0",
"tsc-watch": "^5.0.3",
"typescript": "^4.7.2"
}
"name": "sendchamp-simulator",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"files": [
"bin",
"public"
],
"bin": {
"sendchamp-simulator": "./bin/index.js"
},
"scripts": {
"dev": "tsc-watch --onSuccess \"node bin --phone=2348153207998\"",
"build": "rimraf bin && tsc",
"format": "prettier --write \"**/*\" --ignore-unknown"
},
"repository": {
"type": "git",
"url": "git+https://github.com/fuadop/sendchamp-simulator.git"
},
"keywords": [
"otp",
"email",
"sms",
"sendchamp",
"send",
"verification",
"voice",
"call",
"sender"
],
"author": "Fuad Olatunji",
"bugs": {
"url": "https://github.com/fuadop/sendchamp-simulator/issues"
},
"homepage": "https://github.com/fuadop/sendchamp-simulator#readme",
"dependencies": {
"@fuadop/koa-proxy": "^1.0.0",
"@koa/cors": "^3.3.0",
"@koa/router": "^10.1.1",
"@types/uuid": "^8.3.4",
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-json": "^2.0.2",
"koa-logger": "^3.2.1",
"koa-static": "^5.0.0",
"minimist": "^1.2.6",
"minimist-options": "^4.1.0",
"node-cache": "^5.1.2",
"randomatic": "^3.1.1",
"uuid": "^8.3.2",
"ws": "^8.7.0"
},
"devDependencies": {
"@types/koa-bodyparser": "^4.3.7",
"@types/koa-json": "^2.0.20",
"@types/koa-logger": "^3.1.2",
"@types/koa-proxy": "^1.0.4",
"@types/koa-static": "^4.0.2",
"@types/koa__router": "^8.0.11",
"@types/minimist": "^1.2.2",
"@types/node": "^17.0.35",
"@types/randomatic": "^3.1.3",
"@types/ws": "^8.5.3",
"copyfiles": "^2.4.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-node": "^10.8.0",
"tsc-watch": "^5.0.3",
"typescript": "^4.7.2"
}
}
Loading

0 comments on commit d81fcd7

Please sign in to comment.