|
4 | 4 |
|
5 | 5 | `@thexdev/biteship-nodejs` is unofficial NodeJS client for interacting with |
6 | 6 | [Biteship API](https://biteship.com/en). Since Biteship does not provide package |
7 | | -to interact with their API, I created this simple wrapper for our convenient. |
8 | | -So, instead of calling the API and handle the request manually, we can do |
9 | | -something like this: |
| 7 | +to interact with their API so, I created this simple wrapper for our convenient. |
| 8 | +Enjoy! 🚀 🚚 |
10 | 9 |
|
11 | | -```ts |
12 | | -const response = await client.send(new RetrieveArea({ input: "Magelang" }))`; |
| 10 | +## Getting Started |
| 11 | + |
| 12 | +Before we go, let's ensure you are ready. First, you |
| 13 | +must ensure your node version is `^18.x` because this package is internally use |
| 14 | +[Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers?retiredLocale=id) |
| 15 | +object. After that, please [setup your Biteship API Key](https://biteship.com/en/docs/intro). |
| 16 | +Finish? Then, we are ready to go. |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +The installation is simple! Just run this command. |
| 21 | + |
| 22 | +```bash |
| 23 | +npm i @thexdev/biteship-node |
| 24 | +``` |
| 25 | + |
| 26 | +## How to Use |
| 27 | + |
| 28 | +> 💡 You can also find useful example [here](https://github.com/thexdev/biteship-nodejs/tree/main/examples). |
| 29 | +
|
| 30 | +We need to use the `Biteship` and command class to perform a specific task. For |
| 31 | +example if we want to search some areas we can use the `RetreiveArea` command. |
| 32 | + |
| 33 | +```js |
| 34 | +// Using TypeScript |
| 35 | +import { Biteship, RetreiveArea } from '@thexdev/biteship-nodejs'; |
| 36 | + |
| 37 | +// or using CommonJS |
| 38 | +const { Biteship, RetrieveArea } = require('@thexdev/biteship-nodejs'); |
| 39 | + |
| 40 | +const biteship = new Biteship(process.env.BITESHIP_API_KEY); |
| 41 | + |
| 42 | +biteship.send(new RetriveArea({ input: 'Jakarta' })).then(console.log); |
| 43 | +// See the example result: https://biteship.com/en/docs/api/maps/retrieve_area_single |
13 | 44 | ``` |
| 45 | + |
| 46 | +I though this way looks better instead of calling the raw API using `fetch` or |
| 47 | +`axios` and handle each request manually 😅. For the command arguments, you can |
| 48 | +find it all on Biteship official documentation. |
| 49 | + |
| 50 | +## List of Commands |
| 51 | + |
| 52 | +- `CreateOrder` |
| 53 | +- `RetrieveArea` |
| 54 | +- `RetrieveCourierRates` |
| 55 | +- `RetrieveOrder` |
| 56 | +- `SearchRates` |
| 57 | +- More commands (soon) |
| 58 | + |
| 59 | +## Want to Support Me? |
| 60 | + |
| 61 | +All your support is much appreciated 🙏 |
| 62 | + |
| 63 | +- [Buy Me Coffee](https://www.buymeacoffee.com/thexdev) |
0 commit comments