vantuz 3.4.2 → 3.5.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/.env.example +21 -0
- package/.openclaw/completions/openclaw.bash +227 -0
- package/.openclaw/completions/openclaw.fish +1552 -0
- package/.openclaw/completions/openclaw.ps1 +1966 -0
- package/.openclaw/completions/openclaw.zsh +3571 -0
- package/.openclaw/gateway.cmd +10 -0
- package/.openclaw/identity/device.json +7 -0
- package/.openclaw/openclaw.json +40 -0
- package/.windsurf/workflows/vantuz-dev.md +31 -0
- package/DOCS_TR.md +80 -0
- package/LICENSE +45 -45
- package/README.md +52 -21
- package/cli.js +685 -585
- package/config.js +733 -733
- package/core/agent-loop.js +190 -190
- package/core/ai-provider.js +298 -261
- package/core/automation.js +523 -523
- package/core/brand-analyst.js +101 -0
- package/core/channels.js +167 -167
- package/core/dashboard.js +230 -230
- package/core/database.js +135 -37
- package/core/eia-monitor.js +3 -1
- package/core/engine.js +648 -636
- package/core/gateway.js +447 -447
- package/core/learning.js +214 -214
- package/core/license.js +113 -0
- package/core/marketplace-adapter.js +168 -168
- package/core/memory.js +190 -190
- package/core/migrations/001-initial-schema.sql +1 -1
- package/core/queue.js +120 -120
- package/core/self-healer.js +314 -314
- package/core/unified-product.js +214 -214
- package/core/vision-service.js +113 -113
- package/index.js +217 -174
- package/modules/crm/sentiment-crm.js +231 -231
- package/modules/healer/listing-healer.js +201 -201
- package/modules/oracle/predictor.js +214 -214
- package/modules/researcher/agent.js +169 -169
- package/modules/team/agents/base.js +92 -92
- package/modules/team/agents/dev.js +33 -33
- package/modules/team/agents/josh.js +40 -40
- package/modules/team/agents/marketing.js +33 -33
- package/modules/team/agents/milo.js +36 -36
- package/modules/team/index.js +78 -78
- package/modules/team/shared-memory.js +87 -87
- package/modules/war-room/competitor-tracker.js +250 -250
- package/modules/war-room/pricing-engine.js +308 -308
- package/n11docs.md +1680 -0
- package/nodes/warehouse.js +238 -238
- package/onboard.js +1 -1
- package/openclawdocs.md +3 -0
- package/package.json +7 -5
- package/platforms/pttavm.js +14 -14
- package/plugins/vantuz/index.js +528 -528
- package/plugins/vantuz/memory/hippocampus.js +465 -465
- package/plugins/vantuz/package.json +20 -20
- package/plugins/vantuz/platforms/_template.js +118 -118
- package/plugins/vantuz/platforms/amazon.js +236 -236
- package/plugins/vantuz/platforms/ciceksepeti.js +166 -166
- package/plugins/vantuz/platforms/hepsiburada.js +180 -180
- package/plugins/vantuz/platforms/index.js +165 -165
- package/plugins/vantuz/platforms/n11.js +229 -229
- package/plugins/vantuz/platforms/pazarama.js +154 -154
- package/plugins/vantuz/platforms/pttavm.js +127 -127
- package/plugins/vantuz/platforms/trendyol.js +326 -326
- package/plugins/vantuz/services/alerts.js +253 -253
- package/plugins/vantuz/services/license.js +34 -34
- package/plugins/vantuz/services/scheduler.js +232 -232
- package/plugins/vantuz/tools/analytics.js +152 -152
- package/plugins/vantuz/tools/crossborder.js +187 -187
- package/plugins/vantuz/tools/nl-parser.js +211 -211
- package/plugins/vantuz/tools/product.js +110 -110
- package/plugins/vantuz/tools/quick-report.js +175 -175
- package/plugins/vantuz/tools/repricer.js +314 -314
- package/plugins/vantuz/tools/sentiment.js +115 -115
- package/plugins/vantuz/tools/vision.js +257 -257
- package/public.pem +9 -0
- package/server/app.js +260 -260
- package/server/public/index.html +514 -514
- package/start.bat +33 -33
- package/vantuz.sqlite +0 -0
- package/workspace/AGENTS.md +73 -0
- package/workspace/BRAND.md +29 -0
- package/workspace/SOUL.md +72 -0
- package/workspace/team/DECISIONS.md +3 -0
- package/workspace/team/GOALS.md +3 -0
- package/workspace/team/PROJECT_STATUS.md +3 -0
- package/workspace/team/agents/dev/SOUL.md +12 -0
- package/workspace/team/agents/josh/SOUL.md +12 -0
- package/workspace/team/agents/marketing/SOUL.md +12 -0
- package/workspace/team/agents/milo/SOUL.md +12 -0
- package/vantuz-3.3.4.tgz +0 -0
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🛒 PAZARAMA API Entegrasyonu
|
|
3
|
-
* sellers.pazarama.com
|
|
4
|
-
*/
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 🛒 PAZARAMA API Entegrasyonu
|
|
3
|
+
* sellers.pazarama.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import { requestWithRetry } from './_request.js';
|
|
8
|
-
|
|
9
|
-
const BASE_URL = 'https://isortagimapi.pazarama.com/api';
|
|
10
|
-
const AUTH_URL = 'https://isortagimapi.pazarama.com/oauth/token';
|
|
11
|
-
|
|
12
|
-
export class PazaramaAPI {
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.clientId = config.clientId;
|
|
15
|
-
this.clientSecret = config.clientSecret;
|
|
16
|
-
this.accessToken = null;
|
|
17
|
-
this.tokenExpiry = null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async _getAccessToken() {
|
|
21
|
-
if (this.accessToken && this.tokenExpiry > Date.now()) {
|
|
22
|
-
return this.accessToken;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
8
|
+
|
|
9
|
+
const BASE_URL = 'https://isortagimapi.pazarama.com/api';
|
|
10
|
+
const AUTH_URL = 'https://isortagimapi.pazarama.com/oauth/token';
|
|
11
|
+
|
|
12
|
+
export class PazaramaAPI {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.clientId = config.clientId;
|
|
15
|
+
this.clientSecret = config.clientSecret;
|
|
16
|
+
this.accessToken = null;
|
|
17
|
+
this.tokenExpiry = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async _getAccessToken() {
|
|
21
|
+
if (this.accessToken && this.tokenExpiry > Date.now()) {
|
|
22
|
+
return this.accessToken;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
26
|
const response = await requestWithRetry(axios, {
|
|
27
27
|
method: 'POST',
|
|
28
28
|
url: AUTH_URL,
|
|
@@ -36,18 +36,18 @@ export class PazaramaAPI {
|
|
|
36
36
|
baseDelayMs: 500,
|
|
37
37
|
maxDelayMs: 4000
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
this.accessToken = response.data.access_token;
|
|
41
|
-
this.tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000;
|
|
42
|
-
return this.accessToken;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new Error('Pazarama token alınamadı: ' + error.message);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async _request(method, endpoint, data = null, params = null) {
|
|
49
|
-
try {
|
|
50
|
-
const token = await this._getAccessToken();
|
|
39
|
+
|
|
40
|
+
this.accessToken = response.data.access_token;
|
|
41
|
+
this.tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000;
|
|
42
|
+
return this.accessToken;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error('Pazarama token alınamadı: ' + error.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async _request(method, endpoint, data = null, params = null) {
|
|
49
|
+
try {
|
|
50
|
+
const token = await this._getAccessToken();
|
|
51
51
|
const response = await requestWithRetry(axios, {
|
|
52
52
|
method,
|
|
53
53
|
url: `${BASE_URL}${endpoint}`,
|
|
@@ -63,122 +63,122 @@ export class PazaramaAPI {
|
|
|
63
63
|
maxDelayMs: 4000
|
|
64
64
|
});
|
|
65
65
|
return { success: true, data: response.data };
|
|
66
|
-
} catch (error) {
|
|
67
|
-
return {
|
|
68
|
-
success: false,
|
|
69
|
-
error: error.response?.data || error.message
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
75
|
-
// ÜRÜN İŞLEMLERİ
|
|
76
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
77
|
-
|
|
78
|
-
async getProducts(params = {}) {
|
|
79
|
-
const { page = 0, size = 100, code } = params;
|
|
80
|
-
return await this._request('GET', '/products', null, {
|
|
81
|
-
page, size, code
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async createProduct(product) {
|
|
86
|
-
return await this._request('POST', '/products', product);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async updateProduct(productCode, updates) {
|
|
90
|
-
return await this._request('PUT', `/products/${productCode}`, updates);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async updatePrice(productCode, salePrice, listPrice = null) {
|
|
94
|
-
return await this._request('PUT', `/products/${productCode}/price`, {
|
|
95
|
-
salePrice,
|
|
96
|
-
listPrice: listPrice || salePrice
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async updateStock(productCode, quantity) {
|
|
101
|
-
return await this._request('PUT', `/products/${productCode}/stock`, {
|
|
102
|
-
quantity
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
107
|
-
// SİPARİŞ İŞLEMLERİ
|
|
108
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
109
|
-
|
|
110
|
-
async getOrders(params = {}) {
|
|
111
|
-
const { status, startDate, endDate, page = 0, size = 100 } = params;
|
|
112
|
-
return await this._request('GET', '/orders', null, {
|
|
113
|
-
status, startDate, endDate, page, size
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async getOrderDetail(orderId) {
|
|
118
|
-
return await this._request('GET', `/orders/${orderId}`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async approveOrder(orderId) {
|
|
122
|
-
return await this._request('PUT', `/orders/${orderId}/approve`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async shipOrder(orderId, trackingNumber, cargoCompany) {
|
|
126
|
-
return await this._request('PUT', `/orders/${orderId}/ship`, {
|
|
127
|
-
trackingNumber,
|
|
128
|
-
cargoCompany
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async cancelOrder(orderId, reason) {
|
|
133
|
-
return await this._request('PUT', `/orders/${orderId}/cancel`, { reason });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
137
|
-
// KATEGORİ & MARKA
|
|
138
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
139
|
-
|
|
140
|
-
async getCategories() {
|
|
141
|
-
return await this._request('GET', '/categories');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async getCategoryAttributes(categoryId) {
|
|
145
|
-
return await this._request('GET', `/categories/${categoryId}/attributes`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async getBrands() {
|
|
149
|
-
return await this._request('GET', '/brands');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
153
|
-
// HELPER
|
|
154
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
155
|
-
|
|
156
|
-
async testConnection() {
|
|
157
|
-
try {
|
|
158
|
-
await this._getAccessToken();
|
|
159
|
-
return true;
|
|
160
|
-
} catch {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
isConnected() {
|
|
166
|
-
return !!(this.clientId && this.clientSecret);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let instance = null;
|
|
171
|
-
|
|
172
|
-
export const pazaramaApi = {
|
|
173
|
-
init(config) {
|
|
174
|
-
instance = new PazaramaAPI(config);
|
|
175
|
-
return instance;
|
|
176
|
-
},
|
|
177
|
-
getInstance() { return instance; },
|
|
178
|
-
isConnected() { return instance?.isConnected() || false; },
|
|
179
|
-
|
|
180
|
-
async getProducts(params) { return instance?.getProducts(params); },
|
|
181
|
-
async updatePrice(code, price) { return instance?.updatePrice(code, price); },
|
|
182
|
-
async updateStock(code, qty) { return instance?.updateStock(code, qty); },
|
|
183
|
-
async getOrders(params) { return instance?.getOrders(params); }
|
|
184
|
-
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: error.response?.data || error.message
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
75
|
+
// ÜRÜN İŞLEMLERİ
|
|
76
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
77
|
+
|
|
78
|
+
async getProducts(params = {}) {
|
|
79
|
+
const { page = 0, size = 100, code } = params;
|
|
80
|
+
return await this._request('GET', '/products', null, {
|
|
81
|
+
page, size, code
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async createProduct(product) {
|
|
86
|
+
return await this._request('POST', '/products', product);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async updateProduct(productCode, updates) {
|
|
90
|
+
return await this._request('PUT', `/products/${productCode}`, updates);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async updatePrice(productCode, salePrice, listPrice = null) {
|
|
94
|
+
return await this._request('PUT', `/products/${productCode}/price`, {
|
|
95
|
+
salePrice,
|
|
96
|
+
listPrice: listPrice || salePrice
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async updateStock(productCode, quantity) {
|
|
101
|
+
return await this._request('PUT', `/products/${productCode}/stock`, {
|
|
102
|
+
quantity
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
107
|
+
// SİPARİŞ İŞLEMLERİ
|
|
108
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
109
|
+
|
|
110
|
+
async getOrders(params = {}) {
|
|
111
|
+
const { status, startDate, endDate, page = 0, size = 100 } = params;
|
|
112
|
+
return await this._request('GET', '/orders', null, {
|
|
113
|
+
status, startDate, endDate, page, size
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async getOrderDetail(orderId) {
|
|
118
|
+
return await this._request('GET', `/orders/${orderId}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async approveOrder(orderId) {
|
|
122
|
+
return await this._request('PUT', `/orders/${orderId}/approve`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async shipOrder(orderId, trackingNumber, cargoCompany) {
|
|
126
|
+
return await this._request('PUT', `/orders/${orderId}/ship`, {
|
|
127
|
+
trackingNumber,
|
|
128
|
+
cargoCompany
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async cancelOrder(orderId, reason) {
|
|
133
|
+
return await this._request('PUT', `/orders/${orderId}/cancel`, { reason });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
137
|
+
// KATEGORİ & MARKA
|
|
138
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
139
|
+
|
|
140
|
+
async getCategories() {
|
|
141
|
+
return await this._request('GET', '/categories');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async getCategoryAttributes(categoryId) {
|
|
145
|
+
return await this._request('GET', `/categories/${categoryId}/attributes`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async getBrands() {
|
|
149
|
+
return await this._request('GET', '/brands');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
153
|
+
// HELPER
|
|
154
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
155
|
+
|
|
156
|
+
async testConnection() {
|
|
157
|
+
try {
|
|
158
|
+
await this._getAccessToken();
|
|
159
|
+
return true;
|
|
160
|
+
} catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
isConnected() {
|
|
166
|
+
return !!(this.clientId && this.clientSecret);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let instance = null;
|
|
171
|
+
|
|
172
|
+
export const pazaramaApi = {
|
|
173
|
+
init(config) {
|
|
174
|
+
instance = new PazaramaAPI(config);
|
|
175
|
+
return instance;
|
|
176
|
+
},
|
|
177
|
+
getInstance() { return instance; },
|
|
178
|
+
isConnected() { return instance?.isConnected() || false; },
|
|
179
|
+
|
|
180
|
+
async getProducts(params) { return instance?.getProducts(params); },
|
|
181
|
+
async updatePrice(code, price) { return instance?.updatePrice(code, price); },
|
|
182
|
+
async updateStock(code, qty) { return instance?.updateStock(code, qty); },
|
|
183
|
+
async getOrders(params) { return instance?.getOrders(params); }
|
|
184
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 📮 PTTavm API Entegrasyonu
|
|
3
|
-
* pttavm.com/entegrasyon
|
|
4
|
-
*/
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 📮 PTTavm API Entegrasyonu
|
|
3
|
+
* pttavm.com/entegrasyon
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import { requestWithRetry } from './_request.js';
|
|
8
|
-
|
|
9
|
-
const BASE_URL = 'https://api.pttavm.com/v1';
|
|
10
|
-
|
|
11
|
-
export class PttavmAPI {
|
|
12
|
-
constructor(config) {
|
|
13
|
-
this.apiKey = config.apiKey;
|
|
14
|
-
this.token = config.token;
|
|
15
|
-
this.shopId = config.shopId;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_headers() {
|
|
19
|
-
return {
|
|
20
|
-
'Authorization': `Bearer ${this.token}`,
|
|
21
|
-
'X-API-Key': this.apiKey,
|
|
22
|
-
'Content-Type': 'application/json'
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async _request(method, endpoint, data = null, params = null) {
|
|
27
|
-
try {
|
|
8
|
+
|
|
9
|
+
const BASE_URL = 'https://api.pttavm.com/v1';
|
|
10
|
+
|
|
11
|
+
export class PttavmAPI {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.apiKey = config.apiKey;
|
|
14
|
+
this.token = config.token;
|
|
15
|
+
this.shopId = config.shopId;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_headers() {
|
|
19
|
+
return {
|
|
20
|
+
'Authorization': `Bearer ${this.token}`,
|
|
21
|
+
'X-API-Key': this.apiKey,
|
|
22
|
+
'Content-Type': 'application/json'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async _request(method, endpoint, data = null, params = null) {
|
|
27
|
+
try {
|
|
28
28
|
const response = await requestWithRetry(axios, {
|
|
29
29
|
method,
|
|
30
30
|
url: `${BASE_URL}${endpoint}`,
|
|
@@ -37,105 +37,105 @@ export class PttavmAPI {
|
|
|
37
37
|
maxDelayMs: 4000
|
|
38
38
|
});
|
|
39
39
|
return { success: true, data: response.data };
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return {
|
|
42
|
-
success: false,
|
|
43
|
-
error: error.response?.data || error.message
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
49
|
-
// ÜRÜN İŞLEMLERİ
|
|
50
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
51
|
-
|
|
52
|
-
async getProducts(params = {}) {
|
|
53
|
-
const { page = 1, limit = 100, barcode } = params;
|
|
54
|
-
return await this._request('GET', '/products', null, {
|
|
55
|
-
page, limit, barcode
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async createProduct(product) {
|
|
60
|
-
return await this._request('POST', '/products', product);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async updateProduct(productId, updates) {
|
|
64
|
-
return await this._request('PUT', `/products/${productId}`, updates);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async updatePrice(barcode, price) {
|
|
68
|
-
return await this._request('PUT', '/products/price', {
|
|
69
|
-
items: [{ barcode, salePrice: price }]
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async updateStock(barcode, quantity) {
|
|
74
|
-
return await this._request('PUT', '/products/stock', {
|
|
75
|
-
items: [{ barcode, quantity }]
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
80
|
-
// SİPARİŞ İŞLEMLERİ
|
|
81
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
82
|
-
|
|
83
|
-
async getOrders(params = {}) {
|
|
84
|
-
const { status, startDate, endDate, page = 1, limit = 100 } = params;
|
|
85
|
-
return await this._request('GET', '/orders', null, {
|
|
86
|
-
status, startDate, endDate, page, limit
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async getOrderDetail(orderId) {
|
|
91
|
-
return await this._request('GET', `/orders/${orderId}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async updateOrderStatus(orderId, status) {
|
|
95
|
-
return await this._request('PUT', `/orders/${orderId}/status`, { status });
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async shipOrder(orderId, trackingNumber) {
|
|
99
|
-
return await this._request('PUT', `/orders/${orderId}/ship`, {
|
|
100
|
-
trackingNumber,
|
|
101
|
-
cargoCompany: 'PTT'
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
106
|
-
// KATEGORİ
|
|
107
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
108
|
-
|
|
109
|
-
async getCategories() {
|
|
110
|
-
return await this._request('GET', '/categories');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
114
|
-
// HELPER
|
|
115
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
116
|
-
|
|
117
|
-
async testConnection() {
|
|
118
|
-
const result = await this.getProducts({ page: 1, limit: 1 });
|
|
119
|
-
return result.success;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
isConnected() {
|
|
123
|
-
return !!(this.apiKey && this.token);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
let instance = null;
|
|
128
|
-
|
|
129
|
-
export const pttavmApi = {
|
|
130
|
-
init(config) {
|
|
131
|
-
instance = new PttavmAPI(config);
|
|
132
|
-
return instance;
|
|
133
|
-
},
|
|
134
|
-
getInstance() { return instance; },
|
|
135
|
-
isConnected() { return instance?.isConnected() || false; },
|
|
136
|
-
|
|
137
|
-
async getProducts(params) { return instance?.getProducts(params); },
|
|
138
|
-
async updatePrice(code, price) { return instance?.updatePrice(code, price); },
|
|
139
|
-
async updateStock(code, qty) { return instance?.updateStock(code, qty); },
|
|
140
|
-
async getOrders(params) { return instance?.getOrders(params); }
|
|
141
|
-
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
error: error.response?.data || error.message
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
49
|
+
// ÜRÜN İŞLEMLERİ
|
|
50
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
51
|
+
|
|
52
|
+
async getProducts(params = {}) {
|
|
53
|
+
const { page = 1, limit = 100, barcode } = params;
|
|
54
|
+
return await this._request('GET', '/products', null, {
|
|
55
|
+
page, limit, barcode
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async createProduct(product) {
|
|
60
|
+
return await this._request('POST', '/products', product);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async updateProduct(productId, updates) {
|
|
64
|
+
return await this._request('PUT', `/products/${productId}`, updates);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async updatePrice(barcode, price) {
|
|
68
|
+
return await this._request('PUT', '/products/price', {
|
|
69
|
+
items: [{ barcode, salePrice: price }]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async updateStock(barcode, quantity) {
|
|
74
|
+
return await this._request('PUT', '/products/stock', {
|
|
75
|
+
items: [{ barcode, quantity }]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
80
|
+
// SİPARİŞ İŞLEMLERİ
|
|
81
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
82
|
+
|
|
83
|
+
async getOrders(params = {}) {
|
|
84
|
+
const { status, startDate, endDate, page = 1, limit = 100 } = params;
|
|
85
|
+
return await this._request('GET', '/orders', null, {
|
|
86
|
+
status, startDate, endDate, page, limit
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async getOrderDetail(orderId) {
|
|
91
|
+
return await this._request('GET', `/orders/${orderId}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async updateOrderStatus(orderId, status) {
|
|
95
|
+
return await this._request('PUT', `/orders/${orderId}/status`, { status });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async shipOrder(orderId, trackingNumber) {
|
|
99
|
+
return await this._request('PUT', `/orders/${orderId}/ship`, {
|
|
100
|
+
trackingNumber,
|
|
101
|
+
cargoCompany: 'PTT'
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
106
|
+
// KATEGORİ
|
|
107
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
108
|
+
|
|
109
|
+
async getCategories() {
|
|
110
|
+
return await this._request('GET', '/categories');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
114
|
+
// HELPER
|
|
115
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
116
|
+
|
|
117
|
+
async testConnection() {
|
|
118
|
+
const result = await this.getProducts({ page: 1, limit: 1 });
|
|
119
|
+
return result.success;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
isConnected() {
|
|
123
|
+
return !!(this.apiKey && this.token);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let instance = null;
|
|
128
|
+
|
|
129
|
+
export const pttavmApi = {
|
|
130
|
+
init(config) {
|
|
131
|
+
instance = new PttavmAPI(config);
|
|
132
|
+
return instance;
|
|
133
|
+
},
|
|
134
|
+
getInstance() { return instance; },
|
|
135
|
+
isConnected() { return instance?.isConnected() || false; },
|
|
136
|
+
|
|
137
|
+
async getProducts(params) { return instance?.getProducts(params); },
|
|
138
|
+
async updatePrice(code, price) { return instance?.updatePrice(code, price); },
|
|
139
|
+
async updateStock(code, qty) { return instance?.updateStock(code, qty); },
|
|
140
|
+
async getOrders(params) { return instance?.getOrders(params); }
|
|
141
|
+
};
|