pathao-merchant-sdk 1.2.0 → 2.0.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/CHANGELOG.md +83 -0
- package/CONTRIBUTING.md +187 -0
- package/README.md +88 -51
- package/dist/index.d.mts +50 -25
- package/dist/index.d.ts +50 -25
- package/dist/index.js +47 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
## [1.3.0] - 2025-12-04
|
|
2
|
+
|
|
3
|
+
### ✨ New Features
|
|
4
|
+
- b4fa591 feat: enhance Pathao API SDK with environment variable support and improved error handling
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Changelog
|
|
8
|
+
|
|
9
|
+
All notable changes to this project will be documented in this file.
|
|
10
|
+
|
|
11
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
12
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
13
|
+
|
|
14
|
+
## [Unreleased]
|
|
15
|
+
|
|
16
|
+
## [2.0.1] - 2025-12-05
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Added `PathaoApiError` with structured fields (`status`, `code`, `type`, `errors`, `validation`, `responseData`) and updated all SDK methods to throw it.
|
|
20
|
+
|
|
21
|
+
### Verified
|
|
22
|
+
- `npm test` (jest) passes.
|
|
23
|
+
|
|
24
|
+
## [1.2.0] - 2024-12-05
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- Fixed `PathaoPriceRequest` type - removed incorrect `recipient_area` field
|
|
28
|
+
- Split store response types into `PathaoStoreCreateResponse` and `PathaoStoreListResponse`
|
|
29
|
+
- Updated README examples to match official API response structures
|
|
30
|
+
- Removed deprecated `StoreType` enum references
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
- Enhanced package.json with ESM exports field and sideEffects flag
|
|
34
|
+
- Improved npm package structure with .npmignore
|
|
35
|
+
- Added CONTRIBUTING.md for contributors
|
|
36
|
+
- Reorganized documentation files into docs/ folder
|
|
37
|
+
|
|
38
|
+
### Verified
|
|
39
|
+
- All endpoints tested against official Pathao sandbox API
|
|
40
|
+
- Type definitions verified against actual API responses
|
|
41
|
+
|
|
42
|
+
## [1.1.0] - 2024-10-01
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
- Comprehensive CI/CD pipeline and automatic release management
|
|
46
|
+
|
|
47
|
+
## [1.0.0] - 2024-10-01
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
- Initial release of Pathao Merchant API SDK
|
|
51
|
+
- Full TypeScript support with complete type definitions
|
|
52
|
+
- Automatic OAuth2 authentication and token refresh
|
|
53
|
+
- Order management (create, track, status)
|
|
54
|
+
- Store management (create, list stores)
|
|
55
|
+
- Price calculation for delivery charges
|
|
56
|
+
- Location services (cities, zones, areas)
|
|
57
|
+
- Comprehensive error handling
|
|
58
|
+
- Built-in validation helpers
|
|
59
|
+
- Support for both CommonJS and ESM
|
|
60
|
+
- Extensive documentation and examples
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
- 🚀 Full TypeScript Support
|
|
64
|
+
- 🔐 Automatic Authentication
|
|
65
|
+
- 📦 Order Management
|
|
66
|
+
- 🏪 Store Management
|
|
67
|
+
- 💰 Price Calculation
|
|
68
|
+
- 🌍 Location Services
|
|
69
|
+
- ⚡ Built with Axios
|
|
70
|
+
- 🛡️ Error Handling
|
|
71
|
+
- 📚 Well Documented
|
|
72
|
+
|
|
73
|
+
## [1.0.0] - 2025-01-01
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
- Initial release
|
|
77
|
+
- Complete Pathao API integration
|
|
78
|
+
- TypeScript support
|
|
79
|
+
- Automatic authentication
|
|
80
|
+
- Order management
|
|
81
|
+
- Store management
|
|
82
|
+
- Price calculation
|
|
83
|
+
- Location services
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Contributing to Pathao Merchant SDK
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to the Pathao Merchant SDK! This document provides guidelines for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. **Fork the repository** on GitHub
|
|
8
|
+
2. **Clone your fork** locally:
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/YOUR_USERNAME/pathao-merchant-sdk.git
|
|
11
|
+
cd pathao-merchant-sdk
|
|
12
|
+
```
|
|
13
|
+
3. **Install dependencies**:
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
# or
|
|
17
|
+
pnpm install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Development Workflow
|
|
21
|
+
|
|
22
|
+
### 1. Create a Branch
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git checkout -b feature/your-feature-name
|
|
26
|
+
# or
|
|
27
|
+
git checkout -b fix/your-bug-fix
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Make Your Changes
|
|
31
|
+
|
|
32
|
+
- Write clean, readable code
|
|
33
|
+
- Follow the existing code style
|
|
34
|
+
- Add tests for new features
|
|
35
|
+
- Update documentation as needed
|
|
36
|
+
|
|
37
|
+
### 3. Run Tests
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm test
|
|
41
|
+
npm run build
|
|
42
|
+
npm run type-check
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 4. Commit Your Changes
|
|
46
|
+
|
|
47
|
+
Use conventional commit messages:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# For new features
|
|
51
|
+
git commit -m "feat: add support for webhook notifications"
|
|
52
|
+
|
|
53
|
+
# For bug fixes
|
|
54
|
+
git commit -m "fix: resolve token refresh issue"
|
|
55
|
+
|
|
56
|
+
# For documentation
|
|
57
|
+
git commit -m "docs: update API examples"
|
|
58
|
+
|
|
59
|
+
# For refactoring
|
|
60
|
+
git commit -m "refactor: improve error handling"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 5. Push and Create Pull Request
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git push origin feature/your-feature-name
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then create a Pull Request on GitHub.
|
|
70
|
+
|
|
71
|
+
## Code Style
|
|
72
|
+
|
|
73
|
+
- Use TypeScript for all new code
|
|
74
|
+
- Follow existing code formatting (we use ESLint)
|
|
75
|
+
- Write meaningful variable and function names
|
|
76
|
+
- Add JSDoc comments for public APIs
|
|
77
|
+
- Keep functions small and focused
|
|
78
|
+
|
|
79
|
+
## Testing
|
|
80
|
+
|
|
81
|
+
- Write unit tests for all new features
|
|
82
|
+
- Ensure all tests pass before submitting PR
|
|
83
|
+
- Aim for high test coverage
|
|
84
|
+
- Test against the sandbox API when possible
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
- Update README.md if you change functionality
|
|
89
|
+
- Add JSDoc comments to new functions/methods
|
|
90
|
+
- Update CHANGELOG.md following [Keep a Changelog](https://keepachangelog.com/) format
|
|
91
|
+
- Include examples for new features
|
|
92
|
+
|
|
93
|
+
## Pull Request Guidelines
|
|
94
|
+
|
|
95
|
+
### Before Submitting
|
|
96
|
+
|
|
97
|
+
- [ ] All tests pass
|
|
98
|
+
- [ ] Code builds without errors
|
|
99
|
+
- [ ] Documentation is updated
|
|
100
|
+
- [ ] Commit messages follow convention
|
|
101
|
+
- [ ] No console.log or debugging code
|
|
102
|
+
- [ ] Code is formatted properly
|
|
103
|
+
|
|
104
|
+
### PR Description Should Include
|
|
105
|
+
|
|
106
|
+
1. **What** - What does this PR do?
|
|
107
|
+
2. **Why** - Why is this change needed?
|
|
108
|
+
3. **How** - How does it work?
|
|
109
|
+
4. **Testing** - How was it tested?
|
|
110
|
+
|
|
111
|
+
### Example PR Template
|
|
112
|
+
|
|
113
|
+
```markdown
|
|
114
|
+
## Description
|
|
115
|
+
Brief description of changes
|
|
116
|
+
|
|
117
|
+
## Type of Change
|
|
118
|
+
- [ ] Bug fix
|
|
119
|
+
- [ ] New feature
|
|
120
|
+
- [ ] Breaking change
|
|
121
|
+
- [ ] Documentation update
|
|
122
|
+
|
|
123
|
+
## Testing
|
|
124
|
+
- [ ] Unit tests added/updated
|
|
125
|
+
- [ ] Tested against sandbox API
|
|
126
|
+
- [ ] Manual testing performed
|
|
127
|
+
|
|
128
|
+
## Checklist
|
|
129
|
+
- [ ] Code follows project style
|
|
130
|
+
- [ ] Documentation updated
|
|
131
|
+
- [ ] Tests pass
|
|
132
|
+
- [ ] CHANGELOG.md updated
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Reporting Bugs
|
|
136
|
+
|
|
137
|
+
### Before Creating an Issue
|
|
138
|
+
|
|
139
|
+
1. **Check existing issues** - Maybe it's already reported
|
|
140
|
+
2. **Test with latest version** - Update to the latest release
|
|
141
|
+
3. **Check documentation** - Ensure you're using the API correctly
|
|
142
|
+
|
|
143
|
+
### Bug Report Template
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
**Description**
|
|
147
|
+
Clear description of the bug
|
|
148
|
+
|
|
149
|
+
**To Reproduce**
|
|
150
|
+
Steps to reproduce:
|
|
151
|
+
1. Initialize SDK with...
|
|
152
|
+
2. Call method...
|
|
153
|
+
3. See error
|
|
154
|
+
|
|
155
|
+
**Expected Behavior**
|
|
156
|
+
What should happen
|
|
157
|
+
|
|
158
|
+
**Actual Behavior**
|
|
159
|
+
What actually happens
|
|
160
|
+
|
|
161
|
+
**Environment**
|
|
162
|
+
- SDK Version: 1.2.0
|
|
163
|
+
- Node Version: 18.0.0
|
|
164
|
+
- OS: macOS/Windows/Linux
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Feature Requests
|
|
168
|
+
|
|
169
|
+
We welcome feature requests! Please include:
|
|
170
|
+
|
|
171
|
+
1. **Use Case** - Why do you need this feature?
|
|
172
|
+
2. **Proposed Solution** - How do you envision it working?
|
|
173
|
+
3. **Alternatives** - What alternatives have you considered?
|
|
174
|
+
|
|
175
|
+
## Questions?
|
|
176
|
+
|
|
177
|
+
- Open a [GitHub Discussion](https://github.com/sifat07/pathao-merchant-sdk/discussions)
|
|
178
|
+
- Check existing [Issues](https://github.com/sifat07/pathao-merchant-sdk/issues)
|
|
179
|
+
- Email: sifatjasim@gmail.com
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
184
|
+
|
|
185
|
+
## Code of Conduct
|
|
186
|
+
|
|
187
|
+
Be respectful and constructive in all interactions. We're here to build something useful together! 🚀
|
package/README.md
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
# Pathao Merchant API SDK
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/pathao-merchant-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/pathao-merchant-sdk)
|
|
4
5
|
[](https://www.typescriptlang.org/)
|
|
5
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/sifat07/pathao-merchant-sdk/actions)
|
|
6
8
|
|
|
7
9
|
An **unofficial** TypeScript SDK for integrating with the Pathao Merchant API. This community package provides a clean, type-safe interface for all Pathao Merchant API operations including order management, store management, price calculation, and more.
|
|
8
10
|
|
|
9
|
-
[](https://www.npmjs.com/package/pathao-merchant-sdk)
|
|
10
|
-
[](https://www.npmjs.com/package/pathao-merchant-sdk)
|
|
11
|
-
|
|
12
11
|
> **Disclaimer**: This is not an official package from Pathao. It's a community-maintained SDK based on the public Pathao Merchant API documentation.
|
|
13
12
|
|
|
13
|
+
## Table of Contents
|
|
14
|
+
- [Features](#features)
|
|
15
|
+
- [Requirements](#requirements)
|
|
16
|
+
- [Installation](#installation)
|
|
17
|
+
- [Quick Start](#quick-start)
|
|
18
|
+
- [Configuration](#configuration)
|
|
19
|
+
- [Environment Variables](#environment-variables)
|
|
20
|
+
- [What You Can Do](#what-you-can-do)
|
|
21
|
+
- [API Reference](#api-reference)
|
|
22
|
+
- [Examples](#examples)
|
|
23
|
+
- [Error Handling](#error-handling)
|
|
24
|
+
- [Authentication](#authentication)
|
|
25
|
+
- [Official Documentation](#official-documentation)
|
|
26
|
+
- [Contributing](#contributing)
|
|
27
|
+
- [Development](#development)
|
|
28
|
+
- [License](#license)
|
|
29
|
+
- [Support](#support)
|
|
30
|
+
- [Changelog](#changelog)
|
|
31
|
+
|
|
14
32
|
## Features
|
|
15
33
|
|
|
16
34
|
- 🚀 **Full TypeScript Support** - Complete type definitions for all API responses
|
|
@@ -23,6 +41,11 @@ An **unofficial** TypeScript SDK for integrating with the Pathao Merchant API. T
|
|
|
23
41
|
- 🛡️ **Error Handling** - Comprehensive error handling with detailed error messages
|
|
24
42
|
- 📚 **Well Documented** - Extensive documentation and examples
|
|
25
43
|
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- Node.js >= 18 (see `engines` in `package.json`)
|
|
47
|
+
- TypeScript >= 4.9 (peer dependency; repository uses 5.x)
|
|
48
|
+
|
|
26
49
|
## Installation
|
|
27
50
|
|
|
28
51
|
```bash
|
|
@@ -63,6 +86,44 @@ const order = await pathao.createOrder({
|
|
|
63
86
|
console.log('Order created:', order.data.consignment_id);
|
|
64
87
|
```
|
|
65
88
|
|
|
89
|
+
## Environment Variables
|
|
90
|
+
|
|
91
|
+
Copy `env.example` to `.env` and fill in your credentials. If your runtime does not auto-load environment files, install and load `dotenv`:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cp env.example .env
|
|
95
|
+
npm install dotenv --save-dev # or yarn add -D dotenv / pnpm add -D dotenv
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import 'dotenv/config';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Required and optional variables:
|
|
103
|
+
|
|
104
|
+
```env
|
|
105
|
+
# Base URL (choose one)
|
|
106
|
+
PATHAO_BASE_URL=https://courier-api-sandbox.pathao.com # sandbox
|
|
107
|
+
# PATHAO_BASE_URL=https://api-hermes.pathao.com # production
|
|
108
|
+
|
|
109
|
+
# Authentication (required)
|
|
110
|
+
PATHAO_CLIENT_ID=your-client-id
|
|
111
|
+
PATHAO_CLIENT_SECRET=your-client-secret
|
|
112
|
+
PATHAO_USERNAME=your-username
|
|
113
|
+
PATHAO_PASSWORD=your-password
|
|
114
|
+
|
|
115
|
+
# Optional
|
|
116
|
+
PATHAO_TIMEOUT=30000
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## What You Can Do
|
|
120
|
+
|
|
121
|
+
- Create, price, and track delivery orders
|
|
122
|
+
- Manage stores (pickup/service points)
|
|
123
|
+
- Look up cities, zones, and areas
|
|
124
|
+
- Validate phone, address, weight, and recipient inputs
|
|
125
|
+
- Automatically handle OAuth2 authentication and token refresh
|
|
126
|
+
|
|
66
127
|
## API Reference
|
|
67
128
|
|
|
68
129
|
### Configuration
|
|
@@ -80,24 +141,7 @@ interface PathaoConfig {
|
|
|
80
141
|
|
|
81
142
|
#### Environment Variables
|
|
82
143
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# Base URL (required)
|
|
87
|
-
PATHAO_BASE_URL=https://courier-api-sandbox.pathao.com # For sandbox
|
|
88
|
-
# PATHAO_BASE_URL=https://api-hermes.pathao.com # For live
|
|
89
|
-
|
|
90
|
-
# Authentication credentials (all required)
|
|
91
|
-
PATHAO_CLIENT_ID=your-client-id
|
|
92
|
-
PATHAO_CLIENT_SECRET=your-client-secret
|
|
93
|
-
PATHAO_USERNAME=your-username
|
|
94
|
-
PATHAO_PASSWORD=your-password
|
|
95
|
-
|
|
96
|
-
# Optional
|
|
97
|
-
PATHAO_TIMEOUT=30000 # Request timeout in milliseconds
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
The SDK will automatically use these environment variables if they are set, falling back to the provided config values or defaults.
|
|
144
|
+
The SDK automatically reads the variables listed in the [Environment Variables](#environment-variables) section when present, and falls back to the values you pass in the config.
|
|
101
145
|
|
|
102
146
|
```typescript
|
|
103
147
|
// Option 1: All from environment variables
|
|
@@ -149,7 +193,7 @@ const order = await pathao.createOrder({
|
|
|
149
193
|
|
|
150
194
|
```typescript
|
|
151
195
|
const status = await pathao.getOrderStatus('consignment-id');
|
|
152
|
-
console.log('Order status:', status.data.
|
|
196
|
+
console.log('Order status:', status.data.order_status);
|
|
153
197
|
```
|
|
154
198
|
|
|
155
199
|
### Store Management
|
|
@@ -164,8 +208,7 @@ const store = await pathao.createStore({
|
|
|
164
208
|
address: '123 Store Street, Dhanmondi',
|
|
165
209
|
city_id: 1,
|
|
166
210
|
zone_id: 1,
|
|
167
|
-
area_id: 1
|
|
168
|
-
store_type: StoreType.PICKUP_POINT // 1 for Pickup Point, 2 for Service Point
|
|
211
|
+
area_id: 1
|
|
169
212
|
});
|
|
170
213
|
```
|
|
171
214
|
|
|
@@ -173,7 +216,7 @@ const store = await pathao.createStore({
|
|
|
173
216
|
|
|
174
217
|
```typescript
|
|
175
218
|
const stores = await pathao.getStores();
|
|
176
|
-
console.log('Available stores:', stores);
|
|
219
|
+
console.log('Available stores:', stores.data.data);
|
|
177
220
|
```
|
|
178
221
|
|
|
179
222
|
### Price Calculation
|
|
@@ -185,13 +228,12 @@ const price = await pathao.calculatePrice({
|
|
|
185
228
|
item_weight: 1.0,
|
|
186
229
|
delivery_type: DeliveryType.NORMAL,
|
|
187
230
|
recipient_city: 1,
|
|
188
|
-
recipient_zone: 1
|
|
189
|
-
recipient_area: 1
|
|
231
|
+
recipient_zone: 1
|
|
190
232
|
});
|
|
191
233
|
|
|
192
|
-
console.log('
|
|
193
|
-
console.log('
|
|
194
|
-
console.log('
|
|
234
|
+
console.log('Price:', price.data.price);
|
|
235
|
+
console.log('Final price:', price.data.final_price);
|
|
236
|
+
console.log('COD percentage:', price.data.cod_percentage);
|
|
195
237
|
```
|
|
196
238
|
|
|
197
239
|
### Location Services
|
|
@@ -253,15 +295,6 @@ enum ItemType {
|
|
|
253
295
|
}
|
|
254
296
|
```
|
|
255
297
|
|
|
256
|
-
### StoreType
|
|
257
|
-
|
|
258
|
-
```typescript
|
|
259
|
-
enum StoreType {
|
|
260
|
-
PICKUP_POINT = 1, // Pickup Point
|
|
261
|
-
SERVICE_POINT = 2 // Service Point
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
298
|
## Error Handling
|
|
266
299
|
|
|
267
300
|
The SDK provides comprehensive error handling with detailed error messages:
|
|
@@ -292,17 +325,6 @@ const pathao = new PathaoApiService({
|
|
|
292
325
|
});
|
|
293
326
|
```
|
|
294
327
|
|
|
295
|
-
## Environment Variables
|
|
296
|
-
|
|
297
|
-
Create a `.env` file with your Pathao API credentials:
|
|
298
|
-
|
|
299
|
-
```env
|
|
300
|
-
PATHAO_CLIENT_ID=your-client-id
|
|
301
|
-
PATHAO_CLIENT_SECRET=your-client-secret
|
|
302
|
-
PATHAO_USERNAME=your-username
|
|
303
|
-
PATHAO_PASSWORD=your-password
|
|
304
|
-
```
|
|
305
|
-
|
|
306
328
|
## Examples
|
|
307
329
|
|
|
308
330
|
### Complete Order Flow
|
|
@@ -362,10 +384,25 @@ async function createDeliveryOrder() {
|
|
|
362
384
|
}
|
|
363
385
|
```
|
|
364
386
|
|
|
387
|
+
## Official Documentation
|
|
388
|
+
|
|
389
|
+
This SDK is based on the official Pathao Courier Merchant API documentation. For complete API reference and details:
|
|
390
|
+
|
|
391
|
+
- **[Official API Documentation](./docs/official-pathao-api-documentation.md)** - Complete Pathao API guide
|
|
392
|
+
- **[API Reference](./docs/pathao-api-reference.txt)** - Original API reference document
|
|
393
|
+
- **[Pathao Merchant Portal](https://merchant.pathao.com)** - Official merchant dashboard
|
|
394
|
+
|
|
365
395
|
## Contributing
|
|
366
396
|
|
|
367
397
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
368
398
|
|
|
399
|
+
## Development
|
|
400
|
+
|
|
401
|
+
- Build: `npm run build`
|
|
402
|
+
- Tests: `npm test`
|
|
403
|
+
- Lint: `npm run lint`
|
|
404
|
+
- Type check: `npm run type-check`
|
|
405
|
+
|
|
369
406
|
## License
|
|
370
407
|
|
|
371
408
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
package/dist/index.d.mts
CHANGED
|
@@ -53,20 +53,41 @@ interface PathaoOrderResponse {
|
|
|
53
53
|
delivery_fee: number;
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
interface
|
|
56
|
+
interface PathaoStoreCreateResponse {
|
|
57
57
|
type: string;
|
|
58
58
|
code: number;
|
|
59
59
|
message: string;
|
|
60
60
|
data: {
|
|
61
|
-
store_id: number;
|
|
62
61
|
store_name: string;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface PathaoStore {
|
|
65
|
+
store_id: number;
|
|
66
|
+
store_name: string;
|
|
67
|
+
store_address: string;
|
|
68
|
+
is_active: number;
|
|
69
|
+
city_id: number;
|
|
70
|
+
zone_id: number;
|
|
71
|
+
hub_id: number;
|
|
72
|
+
is_default_store: boolean;
|
|
73
|
+
is_default_return_store: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface PathaoStoreListResponse {
|
|
76
|
+
type: string;
|
|
77
|
+
code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
data: {
|
|
80
|
+
data: PathaoStore[];
|
|
81
|
+
total: number;
|
|
82
|
+
current_page: number;
|
|
83
|
+
per_page: number;
|
|
84
|
+
total_in_page: number;
|
|
85
|
+
last_page: number;
|
|
86
|
+
path: string;
|
|
87
|
+
to: number;
|
|
88
|
+
from: number;
|
|
89
|
+
last_page_url: string;
|
|
90
|
+
first_page_url: string;
|
|
70
91
|
};
|
|
71
92
|
}
|
|
72
93
|
interface PathaoPriceRequest {
|
|
@@ -76,7 +97,6 @@ interface PathaoPriceRequest {
|
|
|
76
97
|
delivery_type: number;
|
|
77
98
|
recipient_city: number;
|
|
78
99
|
recipient_zone: number;
|
|
79
|
-
recipient_area: number;
|
|
80
100
|
}
|
|
81
101
|
interface PathaoPriceResponse {
|
|
82
102
|
type: string;
|
|
@@ -185,6 +205,22 @@ declare enum ItemType {
|
|
|
185
205
|
* - City, zone, and area management
|
|
186
206
|
*/
|
|
187
207
|
|
|
208
|
+
declare class PathaoApiError extends Error {
|
|
209
|
+
status: number | undefined;
|
|
210
|
+
code: number | undefined;
|
|
211
|
+
type: string | undefined;
|
|
212
|
+
errors: Record<string, string[]> | undefined;
|
|
213
|
+
validation: Record<string, string[]> | undefined;
|
|
214
|
+
responseData: unknown;
|
|
215
|
+
constructor(message: string, options?: {
|
|
216
|
+
status?: number | undefined;
|
|
217
|
+
code?: number | undefined;
|
|
218
|
+
type?: string | undefined;
|
|
219
|
+
errors?: Record<string, string[]> | undefined;
|
|
220
|
+
validation?: Record<string, string[]> | undefined;
|
|
221
|
+
responseData?: unknown;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
188
224
|
declare class PathaoApiService {
|
|
189
225
|
private pathaoClient;
|
|
190
226
|
private accessToken;
|
|
@@ -202,22 +238,11 @@ declare class PathaoApiService {
|
|
|
202
238
|
private authenticate;
|
|
203
239
|
private refreshAccessToken;
|
|
204
240
|
private getErrorMessage;
|
|
241
|
+
private toPathaoApiError;
|
|
205
242
|
private handleCircuitBreaker;
|
|
206
243
|
createOrder(orderData: PathaoOrderRequest): Promise<PathaoOrderResponse>;
|
|
207
|
-
createStore(storeData: PathaoStoreRequest): Promise<
|
|
208
|
-
getStores(): Promise<
|
|
209
|
-
data: PathaoStoreResponse[];
|
|
210
|
-
total: number;
|
|
211
|
-
current_page: number;
|
|
212
|
-
per_page: number;
|
|
213
|
-
total_in_page: number;
|
|
214
|
-
last_page: number;
|
|
215
|
-
path: string;
|
|
216
|
-
to: number;
|
|
217
|
-
from: number;
|
|
218
|
-
last_page_url: string;
|
|
219
|
-
first_page_url: string;
|
|
220
|
-
}>;
|
|
244
|
+
createStore(storeData: PathaoStoreRequest): Promise<PathaoStoreCreateResponse>;
|
|
245
|
+
getStores(): Promise<PathaoStoreListResponse>;
|
|
221
246
|
calculatePrice(priceData: PathaoPriceRequest): Promise<PathaoPriceResponse>;
|
|
222
247
|
getCities(): Promise<PathaoCityResponse>;
|
|
223
248
|
getZones(cityId: number): Promise<PathaoZoneResponse>;
|
|
@@ -241,4 +266,4 @@ declare class PathaoApiService {
|
|
|
241
266
|
clearAuth(): void;
|
|
242
267
|
}
|
|
243
268
|
|
|
244
|
-
export { DeliveryType, ItemType, PathaoApiService, type PathaoAreaResponse, type PathaoAuthResponse, type PathaoCityResponse, type PathaoConfig, type PathaoError, type PathaoOrderRequest, type PathaoOrderResponse, type PathaoOrderStatusResponse, type PathaoPriceRequest, type PathaoPriceResponse, type
|
|
269
|
+
export { DeliveryType, ItemType, PathaoApiError, PathaoApiService, type PathaoAreaResponse, type PathaoAuthResponse, type PathaoCityResponse, type PathaoConfig, type PathaoError, type PathaoOrderRequest, type PathaoOrderResponse, type PathaoOrderStatusResponse, type PathaoPriceRequest, type PathaoPriceResponse, type PathaoStore, type PathaoStoreCreateResponse, type PathaoStoreListResponse, type PathaoStoreRequest, type PathaoZoneResponse };
|