@longvansoftware/storefront-js-client 2.9.4 → 2.9.6
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 +157 -64
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +2 -0
- package/dist/src/graphql/cashbook/queries.d.ts +2 -0
- package/dist/src/graphql/cashbook/queries.js +99 -0
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +5 -0
- package/dist/src/lib/cashbook/index.d.ts +6 -0
- package/dist/src/lib/cashbook/index.js +56 -0
- package/dist/src/lib/order/index.d.ts +10 -3
- package/dist/src/lib/order/index.js +25 -4
- package/dist/src/types/order.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,93 +1,186 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Longvan Storefront JavaScript Client SDK
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/js/%40longvansoftware%2Fstorefront-js-client)
|
|
4
|
+
[](http://www.typescriptlang.org/)
|
|
5
|
+
[](https://opensource.org/licenses/ISC)
|
|
3
6
|
|
|
7
|
+
A comprehensive TypeScript/JavaScript SDK for integrating with the Longvan e-commerce platform. This SDK provides easy-to-use interfaces for managing products, orders, users, payments, and other e-commerce functionalities.
|
|
4
8
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
-
|
|
9
|
-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
-
|
|
11
|
-
## Add your files
|
|
12
|
-
|
|
13
|
-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
9
|
+
## 🚀 Quick Start
|
|
15
10
|
|
|
11
|
+
```bash
|
|
12
|
+
npm install @longvansoftware/storefront-js-client
|
|
16
13
|
```
|
|
17
|
-
cd existing_repo
|
|
18
|
-
git remote add origin https://gitlab.longvan.vn/long-van-platform-2.0/website/storefront-js-client.git
|
|
19
|
-
git branch -M main
|
|
20
|
-
git push -uf origin main
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Integrate with your tools
|
|
24
|
-
|
|
25
|
-
- [ ] [Set up project integrations](https://gitlab.longvan.vn/long-van-platform-2.0/website/storefront-js-client/-/settings/integrations)
|
|
26
14
|
|
|
27
|
-
|
|
15
|
+
```typescript
|
|
16
|
+
import { SDK } from '@longvansoftware/storefront-js-client';
|
|
28
17
|
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
-
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
18
|
+
const sdk = new SDK('your-org-id', 'your-store-id', 'dev');
|
|
19
|
+
sdk.setToken('your-access-token');
|
|
34
20
|
|
|
35
|
-
|
|
21
|
+
// Ready to use!
|
|
22
|
+
const products = await sdk.product.getSimpleProducts({ currentPage: 1, maxResult: 10 });
|
|
23
|
+
```
|
|
36
24
|
|
|
37
|
-
|
|
25
|
+
## 📚 Documentation
|
|
26
|
+
|
|
27
|
+
### 🎯 Getting Started
|
|
28
|
+
- **[Installation & Setup](./docs/getting-started/installation.md)** - Complete installation guide
|
|
29
|
+
- **[Quick Start Guide](./docs/getting-started/quick-start.md)** - Get running in 5 minutes
|
|
30
|
+
- **[Configuration](./docs/getting-started/configuration.md)** - Environment and SDK configuration
|
|
31
|
+
- **[Authentication](./docs/getting-started/authentication.md)** - Authentication setup and patterns
|
|
32
|
+
|
|
33
|
+
### 🔧 Core Services
|
|
34
|
+
- **[Authentication Service](./docs/services/auth.md)** - User authentication and authorization
|
|
35
|
+
- **[Product Service](./docs/services/product.md)** - Product catalog management
|
|
36
|
+
- **[Order Service](./docs/services/order.md)** - Order lifecycle management
|
|
37
|
+
- **[User Service](./docs/services/user.md)** - Customer and user management
|
|
38
|
+
- **[Payment Service](./docs/services/payment.md)** - Payment processing and invoicing
|
|
39
|
+
- **[CRM Service](./docs/services/crm.md)** - Customer relationship management
|
|
40
|
+
|
|
41
|
+
### 🛠️ Extended Services
|
|
42
|
+
- **[Warehouse Service](./docs/services/warehouse.md)** - Inventory management
|
|
43
|
+
- **[Computing Service](./docs/services/computing.md)** - Cloud computing services
|
|
44
|
+
- **[Campaign Service](./docs/services/campaign.md)** - Marketing campaigns
|
|
45
|
+
- **[Image Service](./docs/services/image.md)** - Image and media management
|
|
46
|
+
- **[Upload Service](./docs/services/upload.md)** - File upload handling
|
|
47
|
+
|
|
48
|
+
### 📖 Advanced Topics
|
|
49
|
+
- **[Error Handling](./docs/advanced/error-handling.md)** - Robust error handling patterns
|
|
50
|
+
- **[TypeScript Support](./docs/advanced/typescript.md)** - Full TypeScript integration
|
|
51
|
+
- **[Testing](./docs/advanced/testing.md)** - Testing your integration
|
|
52
|
+
- **[Performance](./docs/advanced/performance.md)** - Optimization and best practices
|
|
53
|
+
|
|
54
|
+
### 💡 Examples & Patterns
|
|
55
|
+
- **[E-commerce Flow](./docs/examples/ecommerce-flow.md)** - Complete workflow examples
|
|
56
|
+
- **[Authentication Patterns](./docs/examples/auth-patterns.md)** - Auth implementation patterns
|
|
57
|
+
- **[Product Management](./docs/examples/product-management.md)** - Product handling examples
|
|
58
|
+
- **[Order Processing](./docs/examples/order-processing.md)** - Order workflow examples
|
|
59
|
+
|
|
60
|
+
### 🔍 API Reference
|
|
61
|
+
- **[Complete API Reference](./docs/api/README.md)** - Full API documentation
|
|
62
|
+
- **[Type Definitions](./docs/api/types.md)** - TypeScript type definitions
|
|
63
|
+
- **[Interfaces](./docs/api/interfaces.md)** - Interface specifications
|
|
64
|
+
|
|
65
|
+
## 🏗️ Architecture Overview
|
|
38
66
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
```
|
|
68
|
+
Longvan SDK
|
|
69
|
+
├── 🔐 Authentication Layer
|
|
70
|
+
├── 🛍️ Core E-commerce Services
|
|
71
|
+
│ ├── Product Management
|
|
72
|
+
│ ├── Order Processing
|
|
73
|
+
│ ├── User Management
|
|
74
|
+
│ └── Payment Processing
|
|
75
|
+
├── 🔧 Extended Services
|
|
76
|
+
│ ├── Warehouse & Inventory
|
|
77
|
+
│ ├── CRM & Customer Support
|
|
78
|
+
│ ├── Marketing & Campaigns
|
|
79
|
+
│ └── Media & File Management
|
|
80
|
+
└── 🚀 Infrastructure
|
|
81
|
+
├── GraphQL Client
|
|
82
|
+
├── REST API Client
|
|
83
|
+
├── Error Handling
|
|
84
|
+
└── TypeScript Support
|
|
85
|
+
```
|
|
44
86
|
|
|
45
|
-
|
|
87
|
+
## ✨ Key Features
|
|
46
88
|
|
|
47
|
-
|
|
89
|
+
- **🎯 Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
90
|
+
- **🔌 Multi-Protocol**: Supports both GraphQL and REST APIs
|
|
91
|
+
- **🔐 Secure**: Built-in authentication and token management
|
|
92
|
+
- **⚡ Performance**: Optimized for speed with caching and batching
|
|
93
|
+
- **🛠️ Developer-Friendly**: Intuitive API design with excellent IntelliSense
|
|
94
|
+
- **📱 Cross-Platform**: Works in Node.js, browsers, and React Native
|
|
95
|
+
- **🧪 Well-Tested**: Comprehensive test suite with high coverage
|
|
96
|
+
- **📖 Well-Documented**: Extensive documentation with real-world examples
|
|
48
97
|
|
|
49
|
-
|
|
98
|
+
## 🚀 Installation
|
|
50
99
|
|
|
51
|
-
|
|
100
|
+
### Using npm
|
|
101
|
+
```bash
|
|
102
|
+
npm install @longvansoftware/storefront-js-client
|
|
103
|
+
```
|
|
52
104
|
|
|
53
|
-
|
|
105
|
+
### Using yarn
|
|
106
|
+
```bash
|
|
107
|
+
yarn add @longvansoftware/storefront-js-client
|
|
108
|
+
```
|
|
54
109
|
|
|
55
|
-
|
|
56
|
-
|
|
110
|
+
### Using pnpm
|
|
111
|
+
```bash
|
|
112
|
+
pnpm add @longvansoftware/storefront-js-client
|
|
113
|
+
```
|
|
57
114
|
|
|
58
|
-
##
|
|
59
|
-
|
|
115
|
+
## ⚡ Quick Example
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { SDK } from '@longvansoftware/storefront-js-client';
|
|
119
|
+
|
|
120
|
+
// Initialize SDK
|
|
121
|
+
const sdk = new SDK('your-org-id', 'your-store-id', 'dev');
|
|
122
|
+
|
|
123
|
+
// Authenticate user
|
|
124
|
+
const loginResponse = await sdk.auth.login({
|
|
125
|
+
username: 'user@example.com',
|
|
126
|
+
password: 'password123'
|
|
127
|
+
});
|
|
128
|
+
sdk.setToken(loginResponse.accessToken);
|
|
129
|
+
|
|
130
|
+
// Browse products
|
|
131
|
+
const products = await sdk.product.getSimpleProducts({
|
|
132
|
+
keyword: 'laptop',
|
|
133
|
+
currentPage: 1,
|
|
134
|
+
maxResult: 20
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Create order
|
|
138
|
+
const order = await sdk.order.createOrder({
|
|
139
|
+
customer_id: loginResponse.partyId,
|
|
140
|
+
line_items: [{
|
|
141
|
+
product_id: products[0].id,
|
|
142
|
+
quantity: 1,
|
|
143
|
+
input_price: products[0].price
|
|
144
|
+
}]
|
|
145
|
+
}, 'web', false, loginResponse.partyId);
|
|
146
|
+
|
|
147
|
+
console.log('Order created:', order.id);
|
|
148
|
+
```
|
|
60
149
|
|
|
61
|
-
##
|
|
62
|
-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
150
|
+
## 🌟 What's New in v2.9.0
|
|
63
151
|
|
|
64
|
-
|
|
65
|
-
|
|
152
|
+
- ✨ Enhanced TypeScript support with stricter types
|
|
153
|
+
- 🚀 Improved error handling and debugging capabilities
|
|
154
|
+
- 🔧 New utility services for better platform integration
|
|
155
|
+
- ⚡ Performance optimizations and caching improvements
|
|
156
|
+
- 🔒 Updated dependencies and security enhancements
|
|
157
|
+
- 📖 Comprehensive documentation with real-world examples
|
|
66
158
|
|
|
67
|
-
##
|
|
68
|
-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
159
|
+
## 🤝 Community & Support
|
|
69
160
|
|
|
70
|
-
|
|
71
|
-
|
|
161
|
+
- **📖 Documentation**: [Complete Documentation](./docs/README.md)
|
|
162
|
+
- **🐛 Issues**: [GitLab Issues](https://gitlab.longvan.vn/long-van-platform-2.0/website/storefront-js-client/-/issues)
|
|
163
|
+
- **💬 Discussions**: [GitLab Discussions](https://gitlab.longvan.vn/long-van-platform-2.0/website/storefront-js-client/-/issues)
|
|
164
|
+
- **📧 Support**: Contact the Longvan development team
|
|
72
165
|
|
|
73
|
-
##
|
|
74
|
-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
166
|
+
## 🚀 Contributing
|
|
75
167
|
|
|
76
|
-
|
|
77
|
-
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
168
|
+
We welcome contributions! Please see our [Contributing Guide](./docs/contributing/README.md) for details on:
|
|
78
169
|
|
|
79
|
-
|
|
80
|
-
|
|
170
|
+
- 🔧 Setting up the development environment
|
|
171
|
+
- 📝 Code style and conventions
|
|
172
|
+
- 🧪 Running tests and quality checks
|
|
173
|
+
- 📤 Submitting pull requests
|
|
81
174
|
|
|
82
|
-
|
|
175
|
+
## 📄 License
|
|
83
176
|
|
|
84
|
-
|
|
177
|
+
This project is licensed under the ISC License - see the [LICENSE](./LICENSE) file for details.
|
|
85
178
|
|
|
86
|
-
|
|
87
|
-
Show your appreciation to those who have contributed to the project.
|
|
179
|
+
---
|
|
88
180
|
|
|
89
|
-
|
|
90
|
-
|
|
181
|
+
**Ready to get started?**
|
|
182
|
+
- 🚀 [Quick Start Guide](./docs/getting-started/quick-start.md)
|
|
183
|
+
- 📖 [Complete Documentation](./docs/README.md)
|
|
184
|
+
- 🔍 [API Reference](./docs/api/README.md)
|
|
91
185
|
|
|
92
|
-
|
|
93
|
-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
186
|
+
**Need help?** Open an issue on [GitLab](https://gitlab.longvan.vn/long-van-platform-2.0/website/storefront-js-client/-/issues) or check our [documentation](./docs/README.md).
|
package/dist/config/config.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const environmentEndpoints: {
|
|
|
22
22
|
omnigateway: string;
|
|
23
23
|
authorization: string;
|
|
24
24
|
zca: string;
|
|
25
|
+
cashbook: string;
|
|
25
26
|
};
|
|
26
27
|
live: {
|
|
27
28
|
product: string;
|
|
@@ -46,5 +47,6 @@ export declare const environmentEndpoints: {
|
|
|
46
47
|
omnigateway: string;
|
|
47
48
|
authorization: string;
|
|
48
49
|
zca: string;
|
|
50
|
+
cashbook: string;
|
|
49
51
|
};
|
|
50
52
|
};
|
package/dist/config/config.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.environmentEndpoints = {
|
|
|
25
25
|
omnigateway: "https://omni-gateway.dev.longvan.vn/omni-gateway/v1",
|
|
26
26
|
authorization: "https://id.dev.longvan.vn/authorization/public",
|
|
27
27
|
zca: "https://zca.dev.longvan.vn",
|
|
28
|
+
cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql'
|
|
28
29
|
},
|
|
29
30
|
live: {
|
|
30
31
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
|
@@ -49,5 +50,6 @@ exports.environmentEndpoints = {
|
|
|
49
50
|
omnigateway: "https://omni-gateway.longvan.vn/omni-gateway/v1",
|
|
50
51
|
authorization: "https://id.longvan.vn/authorization/public",
|
|
51
52
|
zca: "https://zca.longvan.vn",
|
|
53
|
+
cashbook: 'https://api-gateway.dev.longvan.vn/cashbook-service/graphql'
|
|
52
54
|
},
|
|
53
55
|
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET_CASHBOOK_TRANSACTION_DETAIL = exports.SEARCH_TRANSACTIONS = void 0;
|
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
+
exports.SEARCH_TRANSACTIONS = (0, graphql_tag_1.gql) `
|
|
6
|
+
query SearchTransactions(
|
|
7
|
+
$partnerId: String!
|
|
8
|
+
$keyword: String
|
|
9
|
+
$dateFrom: Long
|
|
10
|
+
$dateTo: Long
|
|
11
|
+
$currentPage: Int
|
|
12
|
+
$pageSize: Int
|
|
13
|
+
) {
|
|
14
|
+
searchTransactions(
|
|
15
|
+
partnerId: $partnerId
|
|
16
|
+
keyword: $keyword
|
|
17
|
+
dateFrom: $dateFrom
|
|
18
|
+
dateTo: $dateTo
|
|
19
|
+
currentPage: $currentPage
|
|
20
|
+
pageSize: $pageSize
|
|
21
|
+
) {
|
|
22
|
+
total
|
|
23
|
+
index
|
|
24
|
+
maxResult
|
|
25
|
+
resultList {
|
|
26
|
+
id
|
|
27
|
+
createdStamp
|
|
28
|
+
updatedStamp
|
|
29
|
+
createdBy
|
|
30
|
+
updatedBy
|
|
31
|
+
partnerId
|
|
32
|
+
extId
|
|
33
|
+
transactionId
|
|
34
|
+
paymentGatewayType
|
|
35
|
+
bankCode
|
|
36
|
+
bankAccountNumber
|
|
37
|
+
extBankAccountNumber
|
|
38
|
+
extBank
|
|
39
|
+
amount
|
|
40
|
+
currencyCode
|
|
41
|
+
description
|
|
42
|
+
timeTransaction
|
|
43
|
+
status
|
|
44
|
+
gateway
|
|
45
|
+
paymentId
|
|
46
|
+
paymentAmount
|
|
47
|
+
paymentConfirmStatus
|
|
48
|
+
paymentConfirmNote
|
|
49
|
+
accountTransactionId
|
|
50
|
+
orderId
|
|
51
|
+
invoiceId
|
|
52
|
+
cashAccountId
|
|
53
|
+
purpose
|
|
54
|
+
customAttributes
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
exports.GET_CASHBOOK_TRANSACTION_DETAIL = (0, graphql_tag_1.gql) `
|
|
60
|
+
query GetCashbookTransactionDetail(
|
|
61
|
+
$partnerId: String!
|
|
62
|
+
$cashTransactionId: String!
|
|
63
|
+
) {
|
|
64
|
+
getCashbookTransactionDetail(
|
|
65
|
+
partnerId: $partnerId
|
|
66
|
+
cashTransactionId: $cashTransactionId
|
|
67
|
+
) {
|
|
68
|
+
id
|
|
69
|
+
createdStamp
|
|
70
|
+
updatedStamp
|
|
71
|
+
createdBy
|
|
72
|
+
updatedBy
|
|
73
|
+
partnerId
|
|
74
|
+
extId
|
|
75
|
+
transactionId
|
|
76
|
+
paymentGatewayType
|
|
77
|
+
bankCode
|
|
78
|
+
bankAccountNumber
|
|
79
|
+
extBankAccountNumber
|
|
80
|
+
extBank
|
|
81
|
+
amount
|
|
82
|
+
currencyCode
|
|
83
|
+
description
|
|
84
|
+
timeTransaction
|
|
85
|
+
status
|
|
86
|
+
gateway
|
|
87
|
+
paymentId
|
|
88
|
+
paymentAmount
|
|
89
|
+
paymentConfirmStatus
|
|
90
|
+
paymentConfirmNote
|
|
91
|
+
accountTransactionId
|
|
92
|
+
orderId
|
|
93
|
+
invoiceId
|
|
94
|
+
cashAccountId
|
|
95
|
+
purpose
|
|
96
|
+
customAttributes
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
package/dist/src/lib/SDK.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { AccountingService } from "./accounting";
|
|
|
20
20
|
import { OmnigatewayService } from "./omnigateway";
|
|
21
21
|
import { AuthorizationService } from "./token";
|
|
22
22
|
import { ZcaService } from "./zca";
|
|
23
|
+
import { CashbookService } from "./cashbook";
|
|
23
24
|
export interface Endpoints {
|
|
24
25
|
product: string;
|
|
25
26
|
crm: string;
|
|
@@ -43,6 +44,7 @@ export interface Endpoints {
|
|
|
43
44
|
omnigateway: string;
|
|
44
45
|
authorization: string;
|
|
45
46
|
zca: string;
|
|
47
|
+
cashbook: string;
|
|
46
48
|
}
|
|
47
49
|
export declare class SDK {
|
|
48
50
|
orgId: string;
|
|
@@ -70,6 +72,7 @@ export declare class SDK {
|
|
|
70
72
|
omnigateway: OmnigatewayService;
|
|
71
73
|
authorization: AuthorizationService;
|
|
72
74
|
zca: ZcaService;
|
|
75
|
+
cashbook: CashbookService;
|
|
73
76
|
token: string | null;
|
|
74
77
|
constructor(orgId: string, storeId: string, environment: "dev" | "live");
|
|
75
78
|
setToken(token: string): void;
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -25,6 +25,7 @@ const accounting_1 = require("./accounting");
|
|
|
25
25
|
const omnigateway_1 = require("./omnigateway");
|
|
26
26
|
const token_1 = require("./token");
|
|
27
27
|
const zca_1 = require("./zca");
|
|
28
|
+
const cashbook_1 = require("./cashbook");
|
|
28
29
|
class SDK {
|
|
29
30
|
constructor(orgId, storeId, environment) {
|
|
30
31
|
this.orgId = orgId;
|
|
@@ -54,6 +55,7 @@ class SDK {
|
|
|
54
55
|
this.omnigateway = new omnigateway_1.OmnigatewayService(endpoints.omnigateway, orgId, storeId);
|
|
55
56
|
this.authorization = new token_1.AuthorizationService(endpoints.authorization, orgId, storeId);
|
|
56
57
|
this.zca = new zca_1.ZcaService(endpoints.zca, orgId, storeId);
|
|
58
|
+
this.cashbook = new cashbook_1.CashbookService(endpoints.cashbook, orgId, storeId);
|
|
57
59
|
// Initialize other services here
|
|
58
60
|
}
|
|
59
61
|
setToken(token) {
|
|
@@ -82,6 +84,7 @@ class SDK {
|
|
|
82
84
|
this.omnigateway.setToken(token);
|
|
83
85
|
this.authorization.setToken(token);
|
|
84
86
|
this.zca.setToken(token);
|
|
87
|
+
this.cashbook.setToken(token);
|
|
85
88
|
}
|
|
86
89
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
|
87
90
|
// src/service.ts
|
|
@@ -107,6 +110,7 @@ class SDK {
|
|
|
107
110
|
this.omnigateway.setStoreId(storeId);
|
|
108
111
|
this.auth.setStoreId(storeId);
|
|
109
112
|
this.zca.setStoreId(storeId);
|
|
113
|
+
this.cashbook.setStoreId(storeId);
|
|
110
114
|
// Set storeId for other services here
|
|
111
115
|
}
|
|
112
116
|
setOrgId(orgId) {
|
|
@@ -131,6 +135,7 @@ class SDK {
|
|
|
131
135
|
this.omnigateway.setOrgId(orgId);
|
|
132
136
|
this.auth.setOrgId(orgId);
|
|
133
137
|
this.zca.setOrgId(orgId);
|
|
138
|
+
this.cashbook.setOrgId(orgId);
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
exports.SDK = SDK;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Service } from "../serviceSDK";
|
|
2
|
+
export declare class CashbookService extends Service {
|
|
3
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
|
4
|
+
searchTransactions(keyword: string, dateFrom: number, dateTo: number, currentPage: number, pageSize: number): Promise<any>;
|
|
5
|
+
getCashbookTransactionDetail(cashTransactionId: string): Promise<any>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CashbookService = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
const queries_1 = require("../../graphql/cashbook/queries");
|
|
15
|
+
class CashbookService extends serviceSDK_1.Service {
|
|
16
|
+
constructor(endpoint, orgId, storeId) {
|
|
17
|
+
super(endpoint, orgId, storeId);
|
|
18
|
+
}
|
|
19
|
+
searchTransactions(keyword, dateFrom, dateTo, currentPage, pageSize) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const query = queries_1.SEARCH_TRANSACTIONS;
|
|
22
|
+
const variables = {
|
|
23
|
+
partnerId: this.orgId,
|
|
24
|
+
keyword,
|
|
25
|
+
dateFrom,
|
|
26
|
+
dateTo,
|
|
27
|
+
currentPage,
|
|
28
|
+
pageSize,
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
const response = yield this.graphqlQueryV3(query, variables);
|
|
32
|
+
return response.searchTransactions;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getCashbookTransactionDetail(cashTransactionId) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const query = queries_1.GET_CASHBOOK_TRANSACTION_DETAIL;
|
|
42
|
+
const variables = {
|
|
43
|
+
partnerId: this.orgId,
|
|
44
|
+
cashTransactionId,
|
|
45
|
+
};
|
|
46
|
+
try {
|
|
47
|
+
const response = yield this.graphqlQueryV3(query, variables);
|
|
48
|
+
return response.getCashbookTransactionDetail;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CashbookService = CashbookService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LineItem, DiscountCampaign, CancelOrder, MemberDiscount, CampaignPromotion, OrderQuery, ShippingAddress } from "../../types/order";
|
|
1
|
+
import { LineItem, DiscountCampaign, CancelOrder, MemberDiscount, CampaignPromotion, OrderQuery, ShippingAddress, CustomerInfo } from "../../types/order";
|
|
2
2
|
import { Service } from "../serviceSDK";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a service for managing orders.
|
|
@@ -512,11 +512,18 @@ export declare class OrderService extends Service {
|
|
|
512
512
|
updateVatInorder(orderId: string, orderItemId: string, vatRate: string): Promise<any>;
|
|
513
513
|
/**
|
|
514
514
|
* Updates the referral code for an order
|
|
515
|
-
* @param partnerId - The partner ID
|
|
516
515
|
* @param orderId - The ID of the order
|
|
517
516
|
* @param referralCode - The referral code to update
|
|
518
517
|
* @returns A promise that resolves when the referral code is updated
|
|
519
518
|
* @throws If an error occurs while updating the referral code
|
|
520
519
|
*/
|
|
521
|
-
updateReferralCode(
|
|
520
|
+
updateReferralCode(orderId: string, referralCode: string): Promise<any>;
|
|
521
|
+
/**
|
|
522
|
+
* Updates customer information for an order in front-end context
|
|
523
|
+
* @param orderId - The ID of the order
|
|
524
|
+
* @param customerInfo - The customer information to update
|
|
525
|
+
* @returns A promise that resolves when the customer information is updated
|
|
526
|
+
* @throws If an error occurs while updating the customer information
|
|
527
|
+
*/
|
|
528
|
+
updateCustomerInfoFront(orderId: string, customerInfo: CustomerInfo): Promise<any>;
|
|
522
529
|
}
|
|
@@ -1500,7 +1500,7 @@ class OrderService extends serviceSDK_1.Service {
|
|
|
1500
1500
|
updateVatInorder(orderId, orderItemId, vatRate) {
|
|
1501
1501
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1502
1502
|
const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/${orderItemId}/${vatRate}/vatProduct`;
|
|
1503
|
-
const method =
|
|
1503
|
+
const method = "PUT";
|
|
1504
1504
|
try {
|
|
1505
1505
|
const response = yield this.restApiCallWithToken(endpoint, method);
|
|
1506
1506
|
return response;
|
|
@@ -1512,16 +1512,16 @@ class OrderService extends serviceSDK_1.Service {
|
|
|
1512
1512
|
}
|
|
1513
1513
|
/**
|
|
1514
1514
|
* Updates the referral code for an order
|
|
1515
|
-
* @param partnerId - The partner ID
|
|
1516
1515
|
* @param orderId - The ID of the order
|
|
1517
1516
|
* @param referralCode - The referral code to update
|
|
1518
1517
|
* @returns A promise that resolves when the referral code is updated
|
|
1519
1518
|
* @throws If an error occurs while updating the referral code
|
|
1520
1519
|
*/
|
|
1521
|
-
updateReferralCode(
|
|
1520
|
+
updateReferralCode(orderId, referralCode) {
|
|
1522
1521
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1523
|
-
const endpoint = `/
|
|
1522
|
+
const endpoint = `/orders/${this.orgId}/${orderId}/${referralCode}/updateReferralCode`;
|
|
1524
1523
|
const method = "PUT";
|
|
1524
|
+
console.log("🚀 ~ OrderService ~ updateReferralCode ~ endpoint:", endpoint);
|
|
1525
1525
|
try {
|
|
1526
1526
|
const response = yield this.restApiCallWithToken(endpoint, method);
|
|
1527
1527
|
return response;
|
|
@@ -1532,5 +1532,26 @@ class OrderService extends serviceSDK_1.Service {
|
|
|
1532
1532
|
}
|
|
1533
1533
|
});
|
|
1534
1534
|
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Updates customer information for an order in front-end context
|
|
1537
|
+
* @param orderId - The ID of the order
|
|
1538
|
+
* @param customerInfo - The customer information to update
|
|
1539
|
+
* @returns A promise that resolves when the customer information is updated
|
|
1540
|
+
* @throws If an error occurs while updating the customer information
|
|
1541
|
+
*/
|
|
1542
|
+
updateCustomerInfoFront(orderId, customerInfo) {
|
|
1543
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1544
|
+
const endpoint = `/front/orders/${this.orgId}/${orderId}/customerInfo`;
|
|
1545
|
+
const method = "PUT";
|
|
1546
|
+
try {
|
|
1547
|
+
const response = yield this.restApiCallWithToken(endpoint, method, customerInfo);
|
|
1548
|
+
return response;
|
|
1549
|
+
}
|
|
1550
|
+
catch (error) {
|
|
1551
|
+
console.log(`Error in updateCustomerInfoFront: ${error}`);
|
|
1552
|
+
throw error;
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1535
1556
|
}
|
|
1536
1557
|
exports.OrderService = OrderService;
|