@serik_lav/api-fe 0.47.0
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 +906 -0
- package/README.md +1100 -0
- package/dist/entities/ad/api/adApi.d.ts +6 -0
- package/dist/entities/ad/api/adApi.d.ts.map +1 -0
- package/dist/entities/ad/api/adApi.js +29 -0
- package/dist/entities/ad/api/adApi.js.map +1 -0
- package/dist/entities/ad/index.d.ts +3 -0
- package/dist/entities/ad/index.d.ts.map +1 -0
- package/dist/entities/ad/index.js +3 -0
- package/dist/entities/ad/index.js.map +1 -0
- package/dist/entities/ad/model/types.d.ts +22 -0
- package/dist/entities/ad/model/types.d.ts.map +1 -0
- package/dist/entities/ad/model/types.js +1 -0
- package/dist/entities/ad/model/types.js.map +1 -0
- package/dist/entities/auth/api/authApi.d.ts +9 -0
- package/dist/entities/auth/api/authApi.d.ts.map +1 -0
- package/dist/entities/auth/api/authApi.js +46 -0
- package/dist/entities/auth/api/authApi.js.map +1 -0
- package/dist/entities/auth/index.d.ts +3 -0
- package/dist/entities/auth/index.d.ts.map +1 -0
- package/dist/entities/auth/index.js +3 -0
- package/dist/entities/auth/index.js.map +1 -0
- package/dist/entities/auth/model/types.d.ts +77 -0
- package/dist/entities/auth/model/types.d.ts.map +1 -0
- package/dist/entities/auth/model/types.js +1 -0
- package/dist/entities/auth/model/types.js.map +1 -0
- package/dist/entities/cart/api/cartApi.d.ts +12 -0
- package/dist/entities/cart/api/cartApi.d.ts.map +1 -0
- package/dist/entities/cart/api/cartApi.js +396 -0
- package/dist/entities/cart/api/cartApi.js.map +1 -0
- package/dist/entities/cart/index.d.ts +3 -0
- package/dist/entities/cart/index.d.ts.map +1 -0
- package/dist/entities/cart/index.js +4 -0
- package/dist/entities/cart/index.js.map +1 -0
- package/dist/entities/cart/model/types.d.ts +91 -0
- package/dist/entities/cart/model/types.d.ts.map +1 -0
- package/dist/entities/cart/model/types.js +1 -0
- package/dist/entities/cart/model/types.js.map +1 -0
- package/dist/entities/category/api/categoryApi.d.ts +8 -0
- package/dist/entities/category/api/categoryApi.d.ts.map +1 -0
- package/dist/entities/category/api/categoryApi.js +33 -0
- package/dist/entities/category/api/categoryApi.js.map +1 -0
- package/dist/entities/category/index.d.ts +4 -0
- package/dist/entities/category/index.d.ts.map +1 -0
- package/dist/entities/category/index.js +4 -0
- package/dist/entities/category/index.js.map +1 -0
- package/dist/entities/category/model/store-category.d.ts +88 -0
- package/dist/entities/category/model/store-category.d.ts.map +1 -0
- package/dist/entities/category/model/store-category.js +24 -0
- package/dist/entities/category/model/store-category.js.map +1 -0
- package/dist/entities/category/model/types.d.ts +155 -0
- package/dist/entities/category/model/types.d.ts.map +1 -0
- package/dist/entities/category/model/types.js +18 -0
- package/dist/entities/category/model/types.js.map +1 -0
- package/dist/entities/category/model/useCategoryBreadcrumbs.d.ts +30 -0
- package/dist/entities/category/model/useCategoryBreadcrumbs.d.ts.map +1 -0
- package/dist/entities/category/model/useCategoryBreadcrumbs.js +72 -0
- package/dist/entities/category/model/useCategoryBreadcrumbs.js.map +1 -0
- package/dist/entities/chat/api/chatApi.d.ts +15 -0
- package/dist/entities/chat/api/chatApi.d.ts.map +1 -0
- package/dist/entities/chat/api/chatApi.js +400 -0
- package/dist/entities/chat/api/chatApi.js.map +1 -0
- package/dist/entities/chat/index.d.ts +3 -0
- package/dist/entities/chat/index.d.ts.map +1 -0
- package/dist/entities/chat/index.js +3 -0
- package/dist/entities/chat/index.js.map +1 -0
- package/dist/entities/chat/model/types.d.ts +439 -0
- package/dist/entities/chat/model/types.d.ts.map +1 -0
- package/dist/entities/chat/model/types.js +1 -0
- package/dist/entities/chat/model/types.js.map +1 -0
- package/dist/entities/country/api/countryApi.d.ts +5 -0
- package/dist/entities/country/api/countryApi.d.ts.map +1 -0
- package/dist/entities/country/api/countryApi.js +21 -0
- package/dist/entities/country/api/countryApi.js.map +1 -0
- package/dist/entities/country/index.d.ts +3 -0
- package/dist/entities/country/index.d.ts.map +1 -0
- package/dist/entities/country/index.js +3 -0
- package/dist/entities/country/index.js.map +1 -0
- package/dist/entities/country/model/types.d.ts +19 -0
- package/dist/entities/country/model/types.d.ts.map +1 -0
- package/dist/entities/country/model/types.js +1 -0
- package/dist/entities/country/model/types.js.map +1 -0
- package/dist/entities/customer/api/customerApi.d.ts +6 -0
- package/dist/entities/customer/api/customerApi.d.ts.map +1 -0
- package/dist/entities/customer/api/customerApi.js +21 -0
- package/dist/entities/customer/api/customerApi.js.map +1 -0
- package/dist/entities/customer/index.d.ts +3 -0
- package/dist/entities/customer/index.d.ts.map +1 -0
- package/dist/entities/customer/index.js +3 -0
- package/dist/entities/customer/index.js.map +1 -0
- package/dist/entities/customer/model/types.d.ts +237 -0
- package/dist/entities/customer/model/types.d.ts.map +1 -0
- package/dist/entities/customer/model/types.js +1 -0
- package/dist/entities/customer/model/types.js.map +1 -0
- package/dist/entities/favorite/api/favoriteApi.d.ts +32 -0
- package/dist/entities/favorite/api/favoriteApi.d.ts.map +1 -0
- package/dist/entities/favorite/api/favoriteApi.js +344 -0
- package/dist/entities/favorite/api/favoriteApi.js.map +1 -0
- package/dist/entities/favorite/index.d.ts +3 -0
- package/dist/entities/favorite/index.d.ts.map +1 -0
- package/dist/entities/favorite/index.js +3 -0
- package/dist/entities/favorite/index.js.map +1 -0
- package/dist/entities/favorite/model/types.d.ts +39 -0
- package/dist/entities/favorite/model/types.d.ts.map +1 -0
- package/dist/entities/favorite/model/types.js +1 -0
- package/dist/entities/favorite/model/types.js.map +1 -0
- package/dist/entities/notification/api/notificationApi.d.ts +12 -0
- package/dist/entities/notification/api/notificationApi.d.ts.map +1 -0
- package/dist/entities/notification/api/notificationApi.js +109 -0
- package/dist/entities/notification/api/notificationApi.js.map +1 -0
- package/dist/entities/notification/index.d.ts +3 -0
- package/dist/entities/notification/index.d.ts.map +1 -0
- package/dist/entities/notification/index.js +3 -0
- package/dist/entities/notification/index.js.map +1 -0
- package/dist/entities/notification/model/types.d.ts +273 -0
- package/dist/entities/notification/model/types.d.ts.map +1 -0
- package/dist/entities/notification/model/types.js +1 -0
- package/dist/entities/notification/model/types.js.map +1 -0
- package/dist/entities/novaposhta/api/novaposhtaApi.d.ts +11 -0
- package/dist/entities/novaposhta/api/novaposhtaApi.d.ts.map +1 -0
- package/dist/entities/novaposhta/api/novaposhtaApi.js +69 -0
- package/dist/entities/novaposhta/api/novaposhtaApi.js.map +1 -0
- package/dist/entities/novaposhta/index.d.ts +6 -0
- package/dist/entities/novaposhta/index.d.ts.map +1 -0
- package/dist/entities/novaposhta/index.js +6 -0
- package/dist/entities/novaposhta/index.js.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaCity.d.ts +101 -0
- package/dist/entities/novaposhta/model/novaposhtaCity.d.ts.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaCity.js +16 -0
- package/dist/entities/novaposhta/model/novaposhtaCity.js.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaSettlement.d.ts +140 -0
- package/dist/entities/novaposhta/model/novaposhtaSettlement.d.ts.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaSettlement.js +23 -0
- package/dist/entities/novaposhta/model/novaposhtaSettlement.js.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaStreet.d.ts +123 -0
- package/dist/entities/novaposhta/model/novaposhtaStreet.d.ts.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaStreet.js +16 -0
- package/dist/entities/novaposhta/model/novaposhtaStreet.js.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaWarehouse.d.ts +131 -0
- package/dist/entities/novaposhta/model/novaposhtaWarehouse.d.ts.map +1 -0
- package/dist/entities/novaposhta/model/novaposhtaWarehouse.js +19 -0
- package/dist/entities/novaposhta/model/novaposhtaWarehouse.js.map +1 -0
- package/dist/entities/order/api/orderApi.d.ts +18 -0
- package/dist/entities/order/api/orderApi.d.ts.map +1 -0
- package/dist/entities/order/api/orderApi.js +105 -0
- package/dist/entities/order/api/orderApi.js.map +1 -0
- package/dist/entities/order/index.d.ts +3 -0
- package/dist/entities/order/index.d.ts.map +1 -0
- package/dist/entities/order/index.js +3 -0
- package/dist/entities/order/index.js.map +1 -0
- package/dist/entities/order/model/types.d.ts +630 -0
- package/dist/entities/order/model/types.d.ts.map +1 -0
- package/dist/entities/order/model/types.js +27 -0
- package/dist/entities/order/model/types.js.map +1 -0
- package/dist/entities/product/api/productApi.d.ts +27 -0
- package/dist/entities/product/api/productApi.d.ts.map +1 -0
- package/dist/entities/product/api/productApi.js +252 -0
- package/dist/entities/product/api/productApi.js.map +1 -0
- package/dist/entities/product/index.d.ts +3 -0
- package/dist/entities/product/index.d.ts.map +1 -0
- package/dist/entities/product/index.js +3 -0
- package/dist/entities/product/index.js.map +1 -0
- package/dist/entities/product/model/store-product.d.ts +138 -0
- package/dist/entities/product/model/store-product.d.ts.map +1 -0
- package/dist/entities/product/model/store-product.js +9 -0
- package/dist/entities/product/model/store-product.js.map +1 -0
- package/dist/entities/product/model/types.d.ts +898 -0
- package/dist/entities/product/model/types.d.ts.map +1 -0
- package/dist/entities/product/model/types.js +40 -0
- package/dist/entities/product/model/types.js.map +1 -0
- package/dist/entities/referral/api/referralApi.d.ts +7 -0
- package/dist/entities/referral/api/referralApi.d.ts.map +1 -0
- package/dist/entities/referral/api/referralApi.js +41 -0
- package/dist/entities/referral/api/referralApi.js.map +1 -0
- package/dist/entities/referral/index.d.ts +3 -0
- package/dist/entities/referral/index.d.ts.map +1 -0
- package/dist/entities/referral/index.js +3 -0
- package/dist/entities/referral/index.js.map +1 -0
- package/dist/entities/referral/model/types.d.ts +42 -0
- package/dist/entities/referral/model/types.d.ts.map +1 -0
- package/dist/entities/referral/model/types.js +1 -0
- package/dist/entities/referral/model/types.js.map +1 -0
- package/dist/entities/store/api/storeApi.d.ts +14 -0
- package/dist/entities/store/api/storeApi.d.ts.map +1 -0
- package/dist/entities/store/api/storeApi.js +134 -0
- package/dist/entities/store/api/storeApi.js.map +1 -0
- package/dist/entities/store/index.d.ts +3 -0
- package/dist/entities/store/index.d.ts.map +1 -0
- package/dist/entities/store/index.js +3 -0
- package/dist/entities/store/index.js.map +1 -0
- package/dist/entities/store/model/types.d.ts +853 -0
- package/dist/entities/store/model/types.d.ts.map +1 -0
- package/dist/entities/store/model/types.js +1 -0
- package/dist/entities/store/model/types.js.map +1 -0
- package/dist/entities/stories/api/storiesApi.d.ts +12 -0
- package/dist/entities/stories/api/storiesApi.d.ts.map +1 -0
- package/dist/entities/stories/api/storiesApi.js +225 -0
- package/dist/entities/stories/api/storiesApi.js.map +1 -0
- package/dist/entities/stories/index.d.ts +3 -0
- package/dist/entities/stories/index.d.ts.map +1 -0
- package/dist/entities/stories/index.js +3 -0
- package/dist/entities/stories/index.js.map +1 -0
- package/dist/entities/stories/model/types.d.ts +330 -0
- package/dist/entities/stories/model/types.d.ts.map +1 -0
- package/dist/entities/stories/model/types.js +1 -0
- package/dist/entities/stories/model/types.js.map +1 -0
- package/dist/entities/supplier/api/supplierApi.d.ts +20 -0
- package/dist/entities/supplier/api/supplierApi.d.ts.map +1 -0
- package/dist/entities/supplier/api/supplierApi.js +148 -0
- package/dist/entities/supplier/api/supplierApi.js.map +1 -0
- package/dist/entities/supplier/index.d.ts +3 -0
- package/dist/entities/supplier/index.d.ts.map +1 -0
- package/dist/entities/supplier/index.js +3 -0
- package/dist/entities/supplier/index.js.map +1 -0
- package/dist/entities/supplier/model/types.d.ts +295 -0
- package/dist/entities/supplier/model/types.d.ts.map +1 -0
- package/dist/entities/supplier/model/types.js +1 -0
- package/dist/entities/supplier/model/types.js.map +1 -0
- package/dist/entities/system/api/systemApi.d.ts +7 -0
- package/dist/entities/system/api/systemApi.d.ts.map +1 -0
- package/dist/entities/system/api/systemApi.js +60 -0
- package/dist/entities/system/api/systemApi.js.map +1 -0
- package/dist/entities/system/index.d.ts +3 -0
- package/dist/entities/system/index.d.ts.map +1 -0
- package/dist/entities/system/index.js +3 -0
- package/dist/entities/system/index.js.map +1 -0
- package/dist/entities/system/model/types.d.ts +55 -0
- package/dist/entities/system/model/types.d.ts.map +1 -0
- package/dist/entities/system/model/types.js +1 -0
- package/dist/entities/system/model/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/api/api.d.ts +18 -0
- package/dist/shared/api/api.d.ts.map +1 -0
- package/dist/shared/api/api.js +74 -0
- package/dist/shared/api/api.js.map +1 -0
- package/dist/shared/api/index.d.ts +3 -0
- package/dist/shared/api/index.d.ts.map +1 -0
- package/dist/shared/api/index.js +3 -0
- package/dist/shared/api/index.js.map +1 -0
- package/dist/shared/api/validation-error/ValidationError.d.ts +7 -0
- package/dist/shared/api/validation-error/ValidationError.d.ts.map +1 -0
- package/dist/shared/api/validation-error/ValidationError.js +1 -0
- package/dist/shared/api/validation-error/ValidationError.js.map +1 -0
- package/dist/shared/api/validation-error/handleValidationError.d.ts +2 -0
- package/dist/shared/api/validation-error/handleValidationError.d.ts.map +1 -0
- package/dist/shared/api/validation-error/handleValidationError.js +24 -0
- package/dist/shared/api/validation-error/handleValidationError.js.map +1 -0
- package/dist/shared/api/validation-error/index.d.ts +3 -0
- package/dist/shared/api/validation-error/index.d.ts.map +1 -0
- package/dist/shared/api/validation-error/index.js +3 -0
- package/dist/shared/api/validation-error/index.js.map +1 -0
- package/dist/shared/api/validation-error/isValidationError.d.ts +3 -0
- package/dist/shared/api/validation-error/isValidationError.d.ts.map +1 -0
- package/dist/shared/api/validation-error/isValidationError.js +11 -0
- package/dist/shared/api/validation-error/isValidationError.js.map +1 -0
- package/dist/shared/lib/getNextPageParam.d.ts +3 -0
- package/dist/shared/lib/getNextPageParam.d.ts.map +1 -0
- package/dist/shared/lib/getNextPageParam.js +4 -0
- package/dist/shared/lib/getNextPageParam.js.map +1 -0
- package/dist/shared/lib/index.d.ts +3 -0
- package/dist/shared/lib/index.d.ts.map +1 -0
- package/dist/shared/lib/index.js +3 -0
- package/dist/shared/lib/index.js.map +1 -0
- package/dist/shared/lib/objectToFormData.d.ts +2 -0
- package/dist/shared/lib/objectToFormData.d.ts.map +1 -0
- package/dist/shared/lib/objectToFormData.js +36 -0
- package/dist/shared/lib/objectToFormData.js.map +1 -0
- package/dist/shared/model/index.d.ts +2 -0
- package/dist/shared/model/index.d.ts.map +1 -0
- package/dist/shared/model/index.js +2 -0
- package/dist/shared/model/index.js.map +1 -0
- package/dist/shared/model/types.d.ts +75 -0
- package/dist/shared/model/types.d.ts.map +1 -0
- package/dist/shared/model/types.js +31 -0
- package/dist/shared/model/types.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,1100 @@
|
|
|
1
|
+
# Buymeua API Frontend
|
|
2
|
+
|
|
3
|
+
TypeScript/JavaScript client for BuyMeUA API with RTK Query integration.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/buymeua-api-fe)
|
|
6
|
+
[](https://opensource.org/licenses/ISC)
|
|
7
|
+
|
|
8
|
+
## 🚀 Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install buymeua-api-fe @reduxjs/toolkit react-redux
|
|
12
|
+
# or
|
|
13
|
+
yarn add buymeua-api-fe @reduxjs/toolkit react-redux
|
|
14
|
+
# or
|
|
15
|
+
pnpm add buymeua-api-fe @reduxjs/toolkit react-redux
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 📖 Quick Start
|
|
19
|
+
|
|
20
|
+
### Table of Contents
|
|
21
|
+
|
|
22
|
+
- [Configuration](#configuration)
|
|
23
|
+
- [Products](#products)
|
|
24
|
+
- [Cart](#cart)
|
|
25
|
+
- [Authentication](#authentication)
|
|
26
|
+
- [Customer Account](#customer-account)
|
|
27
|
+
- [Categories](#categories)
|
|
28
|
+
- [Favorites](#favorites)
|
|
29
|
+
- [Chat](#chat)
|
|
30
|
+
- [Notifications](#notifications)
|
|
31
|
+
- [Stories](#stories)
|
|
32
|
+
- [Suppliers](#suppliers)
|
|
33
|
+
- [Nova Poshta](#nova-poshta)
|
|
34
|
+
- [Orders](#orders)
|
|
35
|
+
- [Referrals](#referrals)
|
|
36
|
+
- [Ads](#ads)
|
|
37
|
+
- [Countries](#countries)
|
|
38
|
+
- [Store](#store)
|
|
39
|
+
- [System](#system)
|
|
40
|
+
|
|
41
|
+
### 1. Configure API and Setup Redux Store
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
45
|
+
import { configureBuymeuaApi, Session } from 'buymeua-api-fe';
|
|
46
|
+
|
|
47
|
+
// Configure API before store setup
|
|
48
|
+
const buymeuaApi = configureBuymeuaApi({
|
|
49
|
+
baseUrl: 'https://api.buymeua.com/',
|
|
50
|
+
pusher: {
|
|
51
|
+
appKey: 'your-pusher-app-key',
|
|
52
|
+
cluster: 'eu',
|
|
53
|
+
},
|
|
54
|
+
prepareHeaders: (headers) => {
|
|
55
|
+
headers.set('Accept', 'application/json');
|
|
56
|
+
headers.set('Content-Type', 'application/json');
|
|
57
|
+
|
|
58
|
+
headers.set('X-SESSION', Session.Dropshipper);
|
|
59
|
+
|
|
60
|
+
const token = localStorage.getItem('auth-token');
|
|
61
|
+
if (token) {
|
|
62
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
onUnauthorized: (args, api, extraOptions) => {
|
|
66
|
+
// Handle 401 errors with full request context
|
|
67
|
+
console.log('Unauthorized request:', args);
|
|
68
|
+
localStorage.removeItem('auth-token');
|
|
69
|
+
window.location.href = '/login';
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Setup Redux store
|
|
74
|
+
export const store = configureStore({
|
|
75
|
+
reducer: {
|
|
76
|
+
[buymeuaApi.reducerPath]: buymeuaApi.reducer,
|
|
77
|
+
},
|
|
78
|
+
middleware: (getDefaultMiddleware) =>
|
|
79
|
+
getDefaultMiddleware().concat(buymeuaApi.middleware),
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Usage in React Components
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import React from 'react';
|
|
87
|
+
import { productApi } from 'buymeua-api-fe';
|
|
88
|
+
|
|
89
|
+
function ProductList() {
|
|
90
|
+
const { data, isLoading, error, fetchNextPage, hasNextPage } = productApi.useGetProductsInfiniteQuery({
|
|
91
|
+
per_page: 20,
|
|
92
|
+
core_filter: 'phone'
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (isLoading) return <div>Loading...</div>;
|
|
96
|
+
if (error) return <div>Error loading products</div>;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div>
|
|
100
|
+
{data?.pages.map((page, pageIndex) => (
|
|
101
|
+
<div key={pageIndex}>
|
|
102
|
+
{page.data.map((product) => (
|
|
103
|
+
<div key={product.id}>{product.name}</div>
|
|
104
|
+
))}
|
|
105
|
+
</div>
|
|
106
|
+
))}
|
|
107
|
+
{hasNextPage && (
|
|
108
|
+
<button onClick={() => fetchNextPage()}>Load More</button>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 📚 API Reference
|
|
116
|
+
|
|
117
|
+
### Configuration
|
|
118
|
+
|
|
119
|
+
#### `configureBuymeuaApi(config: ApiConfig)`
|
|
120
|
+
|
|
121
|
+
Configures the global API client.
|
|
122
|
+
|
|
123
|
+
#### `getPusher(): Promise<Pusher>`
|
|
124
|
+
|
|
125
|
+
Returns a shared Pusher instance for real-time subscriptions. Uses lazy initialization and automatically handles authentication for private channels.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { getPusher } from 'buymeua-api-fe';
|
|
129
|
+
|
|
130
|
+
// Subscribe to a channel
|
|
131
|
+
const pusher = await getPusher();
|
|
132
|
+
const channel = pusher.subscribe('my-channel');
|
|
133
|
+
channel.bind('my-event', (data) => {
|
|
134
|
+
console.log('Received:', data);
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Parameters:**
|
|
139
|
+
|
|
140
|
+
- `config.baseUrl` - Base API URL
|
|
141
|
+
- `config.prepareHeaders` - Function to prepare headers (receives Headers object and API context)
|
|
142
|
+
- `config.onUnauthorized` - Optional callback for handling 401 errors (receives args, api, extraOptions for context)
|
|
143
|
+
|
|
144
|
+
**Returns:** Configured API instance ready for Redux store setup
|
|
145
|
+
|
|
146
|
+
### Products
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { productApi } from 'buymeua-api-fe';
|
|
150
|
+
|
|
151
|
+
// Get products list with infinite scroll
|
|
152
|
+
const { data, fetchNextPage, hasNextPage } = productApi.useGetProductsInfiniteQuery({
|
|
153
|
+
per_page?: number;
|
|
154
|
+
core_filter?: string;
|
|
155
|
+
filter_has_special?: boolean | null;
|
|
156
|
+
order_by?: string | string[];
|
|
157
|
+
category_filter?: number[];
|
|
158
|
+
option_value_filter?: {
|
|
159
|
+
option_value_ids: number[];
|
|
160
|
+
warehouse_ids: number[];
|
|
161
|
+
};
|
|
162
|
+
attribute_filter?: {
|
|
163
|
+
attribute_ids: number[];
|
|
164
|
+
attribute_values: `${number}:$${number}`[];
|
|
165
|
+
};
|
|
166
|
+
filter_customer_id?: number;
|
|
167
|
+
filter_has_customer_id?: boolean;
|
|
168
|
+
filter_advertised?: boolean;
|
|
169
|
+
filter_product_ids?: number[];
|
|
170
|
+
filter_exclude_product_ids?: number[];
|
|
171
|
+
filter_bestseller?: boolean;
|
|
172
|
+
price_from?: number;
|
|
173
|
+
price_to?: number;
|
|
174
|
+
retail_price_from?: number;
|
|
175
|
+
retail_price_to?: number;
|
|
176
|
+
margin_from?: number;
|
|
177
|
+
margin_to?: number;
|
|
178
|
+
only_in_root_category?: boolean;
|
|
179
|
+
price_type?: string;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Get products with standard pagination
|
|
183
|
+
const { data } = productApi.useGetPaginatedProductsQuery({
|
|
184
|
+
page?: number;
|
|
185
|
+
per_page?: number;
|
|
186
|
+
core_filter?: string;
|
|
187
|
+
filter_has_special?: boolean | null;
|
|
188
|
+
order_by?: string | string[];
|
|
189
|
+
category_filter?: number[];
|
|
190
|
+
option_value_filter?: {
|
|
191
|
+
option_value_ids?: number[];
|
|
192
|
+
warehouse_ids?: number[];
|
|
193
|
+
};
|
|
194
|
+
attribute_filter?: {
|
|
195
|
+
attribute_ids: number[];
|
|
196
|
+
attribute_values: `${number}:$${number}`[];
|
|
197
|
+
};
|
|
198
|
+
filter_customer_id?: number;
|
|
199
|
+
filter_has_customer_id?: boolean;
|
|
200
|
+
filter_advertised?: boolean;
|
|
201
|
+
filter_product_ids?: number[];
|
|
202
|
+
filter_exclude_product_ids?: number[];
|
|
203
|
+
filter_bestseller?: boolean;
|
|
204
|
+
price_from?: number;
|
|
205
|
+
price_to?: number;
|
|
206
|
+
retail_price_from?: number;
|
|
207
|
+
retail_price_to?: number;
|
|
208
|
+
margin_from?: number;
|
|
209
|
+
margin_to?: number;
|
|
210
|
+
only_in_root_category?: boolean;
|
|
211
|
+
price_type?: string;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Get products by QR code
|
|
215
|
+
const { data, fetchNextPage, hasNextPage } = productApi.useGetProductsByQrInfiniteQuery({
|
|
216
|
+
'filter[barcode]'?: string;
|
|
217
|
+
'filter[product_id]'?: number;
|
|
218
|
+
warehouse_id?: number;
|
|
219
|
+
show_sizes?: boolean;
|
|
220
|
+
per_page?: number;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Get single product by ID
|
|
224
|
+
const { data } = productApi.useGetProductQuery({ product: number });
|
|
225
|
+
|
|
226
|
+
// Get product statistics
|
|
227
|
+
const { data } = productApi.useGetProductStatisticsQuery({ product: number });
|
|
228
|
+
|
|
229
|
+
// Get product details
|
|
230
|
+
const { data } = productApi.useGetProductDetailsQuery({ product: number });
|
|
231
|
+
|
|
232
|
+
// Get product attributes for filtering
|
|
233
|
+
const { data } = productApi.useGetProductAttributesQuery({
|
|
234
|
+
search?: string;
|
|
235
|
+
product_id?: number;
|
|
236
|
+
category_id?: number;
|
|
237
|
+
attribute_ids?: number[];
|
|
238
|
+
option_value_filter?: {
|
|
239
|
+
option_value_ids?: number[];
|
|
240
|
+
warehouse_ids?: number[];
|
|
241
|
+
};
|
|
242
|
+
attribute_filter?: {
|
|
243
|
+
attribute_ids?: number[];
|
|
244
|
+
attribute_values?: `${number}:${string}`[];
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Get product options for filtering
|
|
249
|
+
const { data } = productApi.useGetProductOptionsQuery({
|
|
250
|
+
search?: string;
|
|
251
|
+
product_id?: number;
|
|
252
|
+
category_id?: number;
|
|
253
|
+
option_id?: number;
|
|
254
|
+
option_value_ids?: number[];
|
|
255
|
+
warehouse_ids?: number[];
|
|
256
|
+
attribute_filter?: {
|
|
257
|
+
attribute_ids?: number[];
|
|
258
|
+
attribute_values?: `${number}:${string}`[];
|
|
259
|
+
};
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Get supplier products with infinite scroll
|
|
263
|
+
const { data, fetchNextPage, hasNextPage } = productApi.useGetSupplierProductsInfiniteQuery({
|
|
264
|
+
core_filter?: string;
|
|
265
|
+
category_filter?: number[];
|
|
266
|
+
buyme_category_filter?: number[];
|
|
267
|
+
filter_buyme_category_set_main_category?: boolean;
|
|
268
|
+
filter_customer_id?: number;
|
|
269
|
+
filter_exclude_supplier_ids?: number[];
|
|
270
|
+
filter_advertised?: boolean;
|
|
271
|
+
only_in_root_category?: boolean;
|
|
272
|
+
option_value_filter?: {
|
|
273
|
+
option_value_ids?: number[];
|
|
274
|
+
warehouse_ids?: number[];
|
|
275
|
+
};
|
|
276
|
+
price_from?: number;
|
|
277
|
+
price_to?: number;
|
|
278
|
+
per_page?: number;
|
|
279
|
+
price_type?: 'price' | 'price_drop';
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Get supplier products with standard pagination
|
|
283
|
+
const { data } = productApi.useGetPaginatedSupplierProductsQuery({
|
|
284
|
+
page?: number;
|
|
285
|
+
core_filter?: string;
|
|
286
|
+
category_filter?: number[];
|
|
287
|
+
buyme_category_filter?: number[];
|
|
288
|
+
filter_buyme_category_set_main_category?: boolean;
|
|
289
|
+
filter_customer_id?: number;
|
|
290
|
+
filter_exclude_supplier_ids?: number[];
|
|
291
|
+
filter_advertised?: boolean;
|
|
292
|
+
only_in_root_category?: boolean;
|
|
293
|
+
option_value_filter?: {
|
|
294
|
+
option_value_ids?: number[];
|
|
295
|
+
warehouse_ids?: number[];
|
|
296
|
+
};
|
|
297
|
+
price_from?: number;
|
|
298
|
+
price_to?: number;
|
|
299
|
+
per_page?: number;
|
|
300
|
+
price_type?: 'price' | 'price_drop';
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Get supplier product details
|
|
304
|
+
const { data } = productApi.useGetSupplierProductDetailsQuery({ id: number });
|
|
305
|
+
|
|
306
|
+
// Generate product description using AI
|
|
307
|
+
const { data } = productApi.useGenerateProductDescriptionQuery({ product: number });
|
|
308
|
+
// data.description - AI-generated product description
|
|
309
|
+
|
|
310
|
+
// Get storefront products with infinite scroll (context: X-BSTORE-ID header)
|
|
311
|
+
const { data, fetchNextPage, hasNextPage } = productApi.useGetStoreProductsInfiniteQuery({
|
|
312
|
+
filter_category_ids?: number[];
|
|
313
|
+
filter_product_ids?: number[];
|
|
314
|
+
filter_search?: string;
|
|
315
|
+
filter_option_value_ids?: number[];
|
|
316
|
+
filter_attribute_values?: string[]; // format: "attr_id:value_id"
|
|
317
|
+
filter_price_from?: number;
|
|
318
|
+
filter_price_to?: number;
|
|
319
|
+
filter_has_special?: boolean;
|
|
320
|
+
order_by?: 'price_asc' | 'price_desc' | 'newest' | 'discount';
|
|
321
|
+
per_page?: number;
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Cart
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
import { cartApi } from 'buymeua-api-fe';
|
|
329
|
+
|
|
330
|
+
// Get cart count
|
|
331
|
+
const { data } = cartApi.useGetCartCountQuery();
|
|
332
|
+
|
|
333
|
+
// Get cart merchants
|
|
334
|
+
const { data, fetchNextPage, hasNextPage } = cartApi.useGetCartMerchantsInfiniteQuery({
|
|
335
|
+
per_page?: number;
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// Get cart merchant items
|
|
339
|
+
const { data, fetchNextPage, hasNextPage } = cartApi.useGetCartMerchantItemsInfiniteQuery({
|
|
340
|
+
merchant_id: number;
|
|
341
|
+
per_page?: number;
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Add item to cart
|
|
345
|
+
const [addToCart] = cartApi.useAddToCartMutation();
|
|
346
|
+
await addToCart({
|
|
347
|
+
product_type: 'buyme' | 'supplier';
|
|
348
|
+
product_id: number;
|
|
349
|
+
product_option_value_id: number;
|
|
350
|
+
quantity: number;
|
|
351
|
+
warehouse_id: number | null; // only for buyme products
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// Remove item from cart
|
|
355
|
+
const [removeFromCart] = cartApi.useRemoveItemFromCartMutation();
|
|
356
|
+
await removeFromCart({
|
|
357
|
+
cart_item_id: number;
|
|
358
|
+
merchantId: number;
|
|
359
|
+
quantity: number;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// Remove entire merchant from cart
|
|
363
|
+
const [removeMerchant] = cartApi.useRemoveMerchantFromCartMutation();
|
|
364
|
+
await removeMerchant({ merchant_id: number });
|
|
365
|
+
|
|
366
|
+
// Update cart item quantity
|
|
367
|
+
const [updateQuantity] = cartApi.useUpdateCartItemQuantityMutation();
|
|
368
|
+
await updateQuantity({
|
|
369
|
+
cart_item_option_value_id: number;
|
|
370
|
+
quantity: number;
|
|
371
|
+
type: 'increase' | 'decrease';
|
|
372
|
+
merchantId: number;
|
|
373
|
+
optionIndex: number;
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// Toggle gift package
|
|
377
|
+
const [toggleGift] = cartApi.useToggleGiftPackageMutation();
|
|
378
|
+
await toggleGift({
|
|
379
|
+
gift_package: boolean;
|
|
380
|
+
});
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Authentication
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { authApi } from 'buymeua-api-fe';
|
|
387
|
+
|
|
388
|
+
// Sign in with phone number
|
|
389
|
+
const [signIn] = authApi.useSignInMutation();
|
|
390
|
+
await signIn({
|
|
391
|
+
telephone: string;
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// Confirm verification code
|
|
395
|
+
const [confirmCode] = authApi.useConfirmCodeMutation();
|
|
396
|
+
await confirmCode({
|
|
397
|
+
telephone: string;
|
|
398
|
+
code: string;
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// Sign up
|
|
402
|
+
const [signUp] = authApi.useSignUpMutation();
|
|
403
|
+
await signUp({
|
|
404
|
+
telephone: string;
|
|
405
|
+
firstname: string;
|
|
406
|
+
lastname: string;
|
|
407
|
+
term: true;
|
|
408
|
+
platform: 'web' | 'ios' | 'android';
|
|
409
|
+
ad_platform: 'instagram' | 'tiktok' | 'facebook' | 'youtube' | 'web_organic' | 'google' | 'telegram' | 'referral_program' | 'other';
|
|
410
|
+
referral_id?: number;
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// Register as guest
|
|
414
|
+
const [registerGuest] = authApi.useRegisterGuestMutation();
|
|
415
|
+
const { data } = await registerGuest(); // Returns Customer with token
|
|
416
|
+
|
|
417
|
+
// Logout
|
|
418
|
+
const [logout] = authApi.useLogoutMutation();
|
|
419
|
+
await logout();
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Customer Account
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
import { customerApi } from 'buymeua-api-fe';
|
|
426
|
+
|
|
427
|
+
// Save customer settings
|
|
428
|
+
const [saveSettings] = customerApi.useSaveCustomerSettingsMutation();
|
|
429
|
+
await saveSettings({
|
|
430
|
+
customer_group_id?: number;
|
|
431
|
+
firstname?: string;
|
|
432
|
+
lastname?: string;
|
|
433
|
+
middlename?: string;
|
|
434
|
+
email?: string;
|
|
435
|
+
iban?: string;
|
|
436
|
+
card_fio?: string;
|
|
437
|
+
ederpou?: string;
|
|
438
|
+
avatar?: File; // jpeg, png, jpg, gif, max: 2048kb
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// Delete customer account
|
|
442
|
+
const [deleteAccount] = customerApi.useDeleteCustomerAccountMutation();
|
|
443
|
+
await deleteAccount();
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Categories
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { categoryApi, useCategoryBreadcrumbs } from 'buymeua-api-fe';
|
|
450
|
+
|
|
451
|
+
// Get categories tree (full hierarchy)
|
|
452
|
+
const { data } = categoryApi.useGetCategoriesQuery({
|
|
453
|
+
search?: string;
|
|
454
|
+
filter_parent_id?: number;
|
|
455
|
+
filter_with_products?: boolean;
|
|
456
|
+
filter_with_supplier_products?: boolean;
|
|
457
|
+
filter_prepared_for_site?: boolean;
|
|
458
|
+
filter_has_products_with_special?: boolean;
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Build category breadcrumbs
|
|
462
|
+
// For regular categories
|
|
463
|
+
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId);
|
|
464
|
+
|
|
465
|
+
// For regular categories with filter params
|
|
466
|
+
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId, undefined, {
|
|
467
|
+
filter_with_products: true
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// For supplier categories
|
|
471
|
+
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId, supplierId);
|
|
472
|
+
|
|
473
|
+
// For supplier categories with filter params
|
|
474
|
+
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId, supplierId, {
|
|
475
|
+
search: 'electronics'
|
|
476
|
+
});
|
|
477
|
+
// Returns array of categories from root to current
|
|
478
|
+
|
|
479
|
+
// Get storefront category tree
|
|
480
|
+
const { data } = categoryApi.useGetStoreCategoriesQuery();
|
|
481
|
+
|
|
482
|
+
// Get supplier categories
|
|
483
|
+
const { data } = categoryApi.useGetSupplierCategoriesQuery({
|
|
484
|
+
search?: string;
|
|
485
|
+
filter_parent_id?: number;
|
|
486
|
+
filter_customer_id?: number;
|
|
487
|
+
filter_has_products?: boolean;
|
|
488
|
+
filter_status?: boolean;
|
|
489
|
+
});
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Favorites
|
|
493
|
+
|
|
494
|
+
```typescript
|
|
495
|
+
import { favoriteApi } from 'buymeua-api-fe';
|
|
496
|
+
|
|
497
|
+
// Get favorite count
|
|
498
|
+
const { data } = favoriteApi.useGetFavoriteCountQuery();
|
|
499
|
+
|
|
500
|
+
// Get favorite merchants
|
|
501
|
+
const { data, fetchNextPage, hasNextPage } = favoriteApi.useGetFavoriteMerchantsInfiniteQuery({
|
|
502
|
+
per_page?: number;
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// Get favorite merchant items
|
|
506
|
+
const { data, fetchNextPage, hasNextPage } = favoriteApi.useGetFavoriteMerchantItemsInfiniteQuery({
|
|
507
|
+
merchant_id: number;
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
// Add to favorites
|
|
511
|
+
const [addToFavorite] = favoriteApi.useAddFavoriteMerchantItemMutation();
|
|
512
|
+
await addToFavorite({
|
|
513
|
+
product_type: 'buyme' | 'supplier';
|
|
514
|
+
product_id: number;
|
|
515
|
+
optimisticUpdate?: {
|
|
516
|
+
product: BaseProduct; // For optimistic UI updates
|
|
517
|
+
};
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// Remove from favorites
|
|
521
|
+
const [removeFromFavorite] = favoriteApi.useDeleteFavoriteMerchantItemMutation();
|
|
522
|
+
await removeFromFavorite({
|
|
523
|
+
product_type: 'buyme' | 'supplier';
|
|
524
|
+
product_id: number;
|
|
525
|
+
optimisticUpdate?: {
|
|
526
|
+
product: BaseProduct; // For optimistic UI updates
|
|
527
|
+
};
|
|
528
|
+
});
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Chat
|
|
532
|
+
|
|
533
|
+
```typescript
|
|
534
|
+
import { chatApi } from 'buymeua-api-fe';
|
|
535
|
+
|
|
536
|
+
// Get chat list
|
|
537
|
+
const { data, fetchNextPage, hasNextPage } = chatApi.useGetChatsInfiniteQuery({
|
|
538
|
+
per_page?: number;
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// Get chat messages
|
|
542
|
+
const { data, fetchNextPage, hasNextPage } = chatApi.useGetChatInfiniteQuery({
|
|
543
|
+
customerChatThreadId: number;
|
|
544
|
+
per_page?: number;
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
// Create chat
|
|
548
|
+
const [createChat] = chatApi.useCreateChatMutation();
|
|
549
|
+
await createChat({
|
|
550
|
+
customer_id: number;
|
|
551
|
+
supplier_id?: number; // Required if admin_id not provided
|
|
552
|
+
admin_id?: number; // Required if supplier_id not provided
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
// Send message
|
|
556
|
+
const [sendMessage] = chatApi.useSendChatMessageMutation();
|
|
557
|
+
await sendMessage({
|
|
558
|
+
customerChatThreadId: number;
|
|
559
|
+
message: string;
|
|
560
|
+
supplier_story_id?: number; // ID of supplier story being replied to
|
|
561
|
+
medias?: File[];
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// Update message
|
|
565
|
+
const [updateMessage] = chatApi.useUpdateChatMessageMutation();
|
|
566
|
+
await updateMessage({
|
|
567
|
+
customerChatThreadId: number;
|
|
568
|
+
customerChatId: number;
|
|
569
|
+
message: string;
|
|
570
|
+
medias?: File[];
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// Mark messages as read
|
|
574
|
+
const [markAsRead] = chatApi.useMarkChatMessagesAsReadMutation();
|
|
575
|
+
await markAsRead({
|
|
576
|
+
customerChatThreadId: number;
|
|
577
|
+
chats: number[]; // Message IDs
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
// Mark all messages as read
|
|
581
|
+
const [markAllAsRead] = chatApi.useMarkAllChatMessagesAsReadMutation();
|
|
582
|
+
await markAllAsRead({
|
|
583
|
+
customerChatThreadId: number;
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
// Resend message
|
|
587
|
+
const [resendMessage] = chatApi.useResendChatMessageMutation();
|
|
588
|
+
await resendMessage({
|
|
589
|
+
customerChatThreadId: number;
|
|
590
|
+
customerChatId: number;
|
|
591
|
+
message: string;
|
|
592
|
+
medias?: File[];
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
// Get chat warnings
|
|
596
|
+
const { data } = chatApi.useGetChatWarningsQuery({
|
|
597
|
+
customerChatThread: number;
|
|
598
|
+
});
|
|
599
|
+
// Real-time updates are automatically enabled via Pusher WebSocket
|
|
600
|
+
|
|
601
|
+
// Acknowledge chat warning
|
|
602
|
+
const [acknowledgeWarning] = chatApi.useAcknowledgeChatWarningMutation();
|
|
603
|
+
await acknowledgeWarning({
|
|
604
|
+
customerChatThread: number;
|
|
605
|
+
warning: number;
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// Get total unread messages count
|
|
609
|
+
const { data } = chatApi.useGetNewChatMessagesCountQuery();
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### Notifications
|
|
613
|
+
|
|
614
|
+
```typescript
|
|
615
|
+
import { notificationApi } from 'buymeua-api-fe';
|
|
616
|
+
|
|
617
|
+
// Get notifications
|
|
618
|
+
const { data, fetchNextPage, hasNextPage } = notificationApi.useGetNotificationsInfiniteQuery({
|
|
619
|
+
per_page?: number;
|
|
620
|
+
'filter[type]'?: string;
|
|
621
|
+
'filter[event]'?: string;
|
|
622
|
+
'filter[date_from]'?: string;
|
|
623
|
+
'filter[date_to]'?: string;
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
// Get single notification
|
|
627
|
+
const { data } = notificationApi.useGetNotificationQuery({
|
|
628
|
+
notification: number;
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// Get notifications count
|
|
632
|
+
const { data } = notificationApi.useGetNotificationsCountQuery();
|
|
633
|
+
|
|
634
|
+
// Get new suppliers count
|
|
635
|
+
const { data } = notificationApi.useGetNewSuppliersCountQuery();
|
|
636
|
+
|
|
637
|
+
// Mark all as read
|
|
638
|
+
const [markAllAsRead] = notificationApi.useMarkAllNotificationsAsReadMutation();
|
|
639
|
+
await markAllAsRead();
|
|
640
|
+
|
|
641
|
+
// Mark single notification as read
|
|
642
|
+
const [markAsRead] = notificationApi.useMarkNotificationAsReadMutation();
|
|
643
|
+
await markAsRead({ notification: number });
|
|
644
|
+
|
|
645
|
+
// Delete all notifications
|
|
646
|
+
const [deleteAll] = notificationApi.useDeleteAllNotificationsMutation();
|
|
647
|
+
await deleteAll();
|
|
648
|
+
|
|
649
|
+
// Delete single notification
|
|
650
|
+
const [deleteNotification] = notificationApi.useDeleteNotificationMutation();
|
|
651
|
+
await deleteNotification({ notification: number });
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
### Stories
|
|
655
|
+
|
|
656
|
+
```typescript
|
|
657
|
+
import { storiesApi } from 'buymeua-api-fe';
|
|
658
|
+
|
|
659
|
+
// Get stories
|
|
660
|
+
const { data, fetchNextPage, hasNextPage } = storiesApi.useGetStoriesInfiniteQuery({
|
|
661
|
+
sort_type?: 'created_at' | 'views_count' | 'sort_order' | 'viewed_order';
|
|
662
|
+
sort_direction?: 'asc' | 'desc';
|
|
663
|
+
per_page?: number;
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
// Increase story views
|
|
667
|
+
const [increaseViews] = storiesApi.useIncreaseStoryViewsMutation();
|
|
668
|
+
await increaseViews({ story: number });
|
|
669
|
+
|
|
670
|
+
// Get suppliers with stories (infinite scroll)
|
|
671
|
+
const { data, fetchNextPage, hasNextPage } = storiesApi.useGetSuppliersWithStoriesInfiniteQuery({
|
|
672
|
+
per_page?: number;
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
// Get suppliers with stories (pagination)
|
|
676
|
+
const { data } = storiesApi.useGetPaginatedSuppliersWithStoriesQuery({
|
|
677
|
+
page?: number;
|
|
678
|
+
per_page?: number;
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
// Get all active stories for a supplier (flat list across all groups)
|
|
682
|
+
const { data } = storiesApi.useGetSupplierStoriesQuery({
|
|
683
|
+
customer: number;
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
// Get supplier story groups
|
|
687
|
+
const { data } = storiesApi.useGetSupplierStoryGroupsQuery({
|
|
688
|
+
customer: number;
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// Get stories in a group
|
|
692
|
+
const { data } = storiesApi.useGetSupplierStoryGroupStoriesQuery({
|
|
693
|
+
customer: number;
|
|
694
|
+
supplierStoryGroup: number;
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
// Save story statistics
|
|
698
|
+
const [saveStats] = storiesApi.useSaveSupplierStoryStatisticsMutation();
|
|
699
|
+
await saveStats({
|
|
700
|
+
supplierStory: number;
|
|
701
|
+
type: 'view' | 'like' | 'unlike' | 'share' | 'reply';
|
|
702
|
+
// Optional: triggers optimistic cache update (only for view, like, unlike)
|
|
703
|
+
optimisticUpdate?: { customer: number; supplierStoryGroup: number };
|
|
704
|
+
});
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### Suppliers
|
|
708
|
+
|
|
709
|
+
```typescript
|
|
710
|
+
import { supplierApi } from 'buymeua-api-fe';
|
|
711
|
+
|
|
712
|
+
// Get suppliers list
|
|
713
|
+
const { data, fetchNextPage, hasNextPage } = supplierApi.useGetSuppliersInfiniteQuery({
|
|
714
|
+
per_page?: number;
|
|
715
|
+
search?: string;
|
|
716
|
+
filter_buyme_category_ids?: number[];
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
// Get supplier info
|
|
720
|
+
const { data } = supplierApi.useGetSupplierInfoQuery({
|
|
721
|
+
customer: number;
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
// Get supplier articles
|
|
725
|
+
const { data, fetchNextPage, hasNextPage } = supplierApi.useGetSupplierArticlesInfiniteQuery({
|
|
726
|
+
customer: number;
|
|
727
|
+
per_page?: number;
|
|
728
|
+
'filter[id]'?: number;
|
|
729
|
+
'filter[translations.title]'?: string;
|
|
730
|
+
'filter[translations.content]'?: string;
|
|
731
|
+
'filter[date_from]'?: string;
|
|
732
|
+
'filter[date_to]'?: string;
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
// Get supplier reviews
|
|
736
|
+
const { data, fetchNextPage, hasNextPage } = supplierApi.useGetSupplierReviewsInfiniteQuery({
|
|
737
|
+
supplier_id: number;
|
|
738
|
+
per_page?: number;
|
|
739
|
+
rating?: number;
|
|
740
|
+
has_reply?: boolean;
|
|
741
|
+
date_from?: string;
|
|
742
|
+
date_to?: string;
|
|
743
|
+
sort_by?: 'rating' | 'created_at';
|
|
744
|
+
sort_direction?: 'asc' | 'desc';
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
// Add supplier review
|
|
748
|
+
const [addReview] = supplierApi.useAddSupplierReviewMutation();
|
|
749
|
+
await addReview({
|
|
750
|
+
supplier_id: number;
|
|
751
|
+
rating: number;
|
|
752
|
+
text: string;
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
// Reply to supplier review
|
|
756
|
+
const [replyToReview] = supplierApi.useReplyToSupplierReviewMutation();
|
|
757
|
+
await replyToReview({
|
|
758
|
+
review_id: number;
|
|
759
|
+
reply_text: string;
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
// Mark supplier as old
|
|
763
|
+
const [markAsOld] = supplierApi.useMarkSupplierAsOldMutation();
|
|
764
|
+
await markAsOld({ supplier: number });
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
### Nova Poshta
|
|
768
|
+
|
|
769
|
+
```typescript
|
|
770
|
+
import { novaposhtaApi } from 'buymeua-api-fe';
|
|
771
|
+
|
|
772
|
+
// Get Nova Poshta cities
|
|
773
|
+
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaCitiesInfiniteQuery({
|
|
774
|
+
search?: string;
|
|
775
|
+
per_page?: number;
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
// Get Nova Poshta settlements (KATOTTG registry, for both warehouse and courier delivery)
|
|
779
|
+
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaSettlementsInfiniteQuery({
|
|
780
|
+
search: string; // required
|
|
781
|
+
per_page?: number;
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
// Get Nova Poshta streets
|
|
785
|
+
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaStreetsInfiniteQuery({
|
|
786
|
+
city_ref?: string; // from /novaposhta/cities
|
|
787
|
+
settlement_ref?: string; // from /novaposhta/settlements (requires search)
|
|
788
|
+
search?: string;
|
|
789
|
+
per_page?: number;
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
// Get Nova Poshta warehouses
|
|
793
|
+
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaWarehousesInfiniteQuery({
|
|
794
|
+
city_ref: string; // required — use delivery_city from NovaposhtaSettlement
|
|
795
|
+
search?: string;
|
|
796
|
+
type?: string;
|
|
797
|
+
per_page?: number;
|
|
798
|
+
});
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
### Orders
|
|
802
|
+
|
|
803
|
+
```typescript
|
|
804
|
+
import { orderApi } from 'buymeua-api-fe';
|
|
805
|
+
|
|
806
|
+
// Get orders list with infinite scroll
|
|
807
|
+
const { data, fetchNextPage, hasNextPage } = orderApi.useGetOrdersInfiniteQuery({
|
|
808
|
+
search?: string;
|
|
809
|
+
filter_order_id?: number;
|
|
810
|
+
filter_customer_id?: number;
|
|
811
|
+
filter_is_ttn_custom?: boolean;
|
|
812
|
+
filter_drop_name?: string;
|
|
813
|
+
filter_date_added?: string;
|
|
814
|
+
filter_drop_email?: string;
|
|
815
|
+
filter_customer_telephone?: string;
|
|
816
|
+
filter_customer_name?: string;
|
|
817
|
+
filter_drop_telephone?: string;
|
|
818
|
+
filter_email?: string;
|
|
819
|
+
filter_old_novaposhta_cn_number?: string;
|
|
820
|
+
filter_novaposhta_cn_number?: string;
|
|
821
|
+
filter_order_status_id?: number[];
|
|
822
|
+
filter_products_model?: string;
|
|
823
|
+
filter_products_name?: string;
|
|
824
|
+
filter_with_store?: boolean;
|
|
825
|
+
filter_without_store?: boolean;
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
// Check telephone number (blacklist, duplicates)
|
|
829
|
+
const { data } = orderApi.useCheckTelephoneQuery({
|
|
830
|
+
telephone: string;
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
// Get delivery methods for merchant
|
|
834
|
+
const { data } = orderApi.useGetDeliveryMethodsQuery({
|
|
835
|
+
merchant_id: number;
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// Get payment methods for merchant
|
|
839
|
+
const { data } = orderApi.useGetPaymentMethodsQuery({
|
|
840
|
+
merchant_id: number;
|
|
841
|
+
custom_ttn?: string;
|
|
842
|
+
delivery_method_code?: string;
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
// Create order
|
|
846
|
+
const [createOrder] = orderApi.useCreateOrderMutation();
|
|
847
|
+
await createOrder({
|
|
848
|
+
merchant_id: number;
|
|
849
|
+
payment_method_code: string;
|
|
850
|
+
delivery_method_code?: 'novaposhta.warehouse' | 'novaposhta.courier' | 'novaposhta.international';
|
|
851
|
+
custom_ttn?: string;
|
|
852
|
+
firstname?: string;
|
|
853
|
+
lastname?: string;
|
|
854
|
+
middlename?: string; // required for novaposhta.international
|
|
855
|
+
telephone?: string;
|
|
856
|
+
contact_method?: 'telegram' | 'viber' | 'phone';
|
|
857
|
+
email?: string; // required for novaposhta.international
|
|
858
|
+
comment?: string;
|
|
859
|
+
// novaposhta.warehouse
|
|
860
|
+
city_ref?: string;
|
|
861
|
+
warehouse_ref?: string;
|
|
862
|
+
// novaposhta.courier
|
|
863
|
+
settlement_ref?: string;
|
|
864
|
+
settlement_description?: string;
|
|
865
|
+
street_ref?: string;
|
|
866
|
+
street_description?: string;
|
|
867
|
+
shipping_house?: string;
|
|
868
|
+
shipping_flat?: string;
|
|
869
|
+
// novaposhta.international
|
|
870
|
+
country_id?: number;
|
|
871
|
+
city?: string;
|
|
872
|
+
address?: string;
|
|
873
|
+
total_pay?: number;
|
|
874
|
+
custom_customer_id?: number;
|
|
875
|
+
category_order_id?: number;
|
|
876
|
+
ad_platform_page_id?: number;
|
|
877
|
+
ad_new_client?: boolean;
|
|
878
|
+
utm_source?: string;
|
|
879
|
+
utm_medium?: string;
|
|
880
|
+
utm_campaign?: string;
|
|
881
|
+
utm_term?: string;
|
|
882
|
+
utm_content?: string;
|
|
883
|
+
});
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
### Referrals
|
|
887
|
+
|
|
888
|
+
```typescript
|
|
889
|
+
import { referralApi } from 'buymeua-api-fe';
|
|
890
|
+
|
|
891
|
+
// Get referral statistics
|
|
892
|
+
const { data, fetchNextPage, hasNextPage } = referralApi.useGetReferralStatisticsInfiniteQuery({
|
|
893
|
+
date_from?: string;
|
|
894
|
+
date_to?: string;
|
|
895
|
+
per_page?: number;
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
// Get referral transactions
|
|
899
|
+
const { data, fetchNextPage, hasNextPage } = referralApi.useGetReferralTransactionsInfiniteQuery({
|
|
900
|
+
referral_id: number;
|
|
901
|
+
date_from?: string;
|
|
902
|
+
date_to?: string;
|
|
903
|
+
per_page?: number;
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
// Track referral visit
|
|
907
|
+
const [trackVisit] = referralApi.useTrackReferralVisitMutation();
|
|
908
|
+
await trackVisit({
|
|
909
|
+
referral_id: number;
|
|
910
|
+
});
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
### Ads
|
|
914
|
+
|
|
915
|
+
```typescript
|
|
916
|
+
import { adApi } from 'buymeua-api-fe';
|
|
917
|
+
|
|
918
|
+
// Get ad pages
|
|
919
|
+
const { data } = adApi.useGetAdPagesQuery({
|
|
920
|
+
platform_id: number;
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
// Get ad platforms
|
|
924
|
+
const { data, fetchNextPage, hasNextPage } = adApi.useGetAdPlatformsInfiniteQuery({
|
|
925
|
+
per_page?: number;
|
|
926
|
+
});
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
### Countries
|
|
930
|
+
|
|
931
|
+
```typescript
|
|
932
|
+
import { countryApi } from 'buymeua-api-fe';
|
|
933
|
+
|
|
934
|
+
// Get countries list
|
|
935
|
+
const { data, fetchNextPage, hasNextPage } = countryApi.useGetCountriesInfiniteQuery({
|
|
936
|
+
search?: string;
|
|
937
|
+
per_page?: number;
|
|
938
|
+
});
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
### Store
|
|
942
|
+
|
|
943
|
+
```typescript
|
|
944
|
+
import { storeApi } from 'buymeua-api-fe';
|
|
945
|
+
|
|
946
|
+
// Get list of current user's stores
|
|
947
|
+
const { data, fetchNextPage, hasNextPage } = storeApi.useGetStoresInfiniteQuery({
|
|
948
|
+
per_page?: number;
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
// Get store information
|
|
952
|
+
const { data } = storeApi.useGetStoreQuery({
|
|
953
|
+
store: number;
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
// Get available store domains
|
|
957
|
+
const { data } = storeApi.useGetStoreDomainsQuery();
|
|
958
|
+
|
|
959
|
+
// Validate store domain availability
|
|
960
|
+
const [validateDomain] = storeApi.useValidateStoreDomainMutation();
|
|
961
|
+
await validateDomain({
|
|
962
|
+
link: string; // "my-store"
|
|
963
|
+
store_domain_id?: number;
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
// Get store platforms (web, mobile) with prices
|
|
967
|
+
const { data } = storeApi.useGetStorePlatformsQuery();
|
|
968
|
+
|
|
969
|
+
// Create new store (wizard step 1)
|
|
970
|
+
const [createStore] = storeApi.useCreateStoreMutation();
|
|
971
|
+
await createStore({
|
|
972
|
+
store_types: ('web' | 'mobile')[];
|
|
973
|
+
name: string;
|
|
974
|
+
link?: string;
|
|
975
|
+
store_domain_id?: number;
|
|
976
|
+
custom_domain_name?: string;
|
|
977
|
+
store_template_id?: number;
|
|
978
|
+
logo?: File;
|
|
979
|
+
icon_mobile?: File;
|
|
980
|
+
favicon?: File;
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// Update store wizard steps (1-6)
|
|
984
|
+
const [updateWizard] = storeApi.useUpdateStoreWizardMutation();
|
|
985
|
+
await updateWizard({
|
|
986
|
+
store: number;
|
|
987
|
+
current_step: 1 | 2 | 3 | 4 | 5 | 6;
|
|
988
|
+
// ... other step-specific fields
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
// Pay for store creation
|
|
992
|
+
const [payStore] = storeApi.usePayStoreCreationMutation();
|
|
993
|
+
await payStore({
|
|
994
|
+
store: number;
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
// Update store analytics settings
|
|
998
|
+
const [updateAnalytics] = storeApi.useUpdateStoreAnalyticsMutation();
|
|
999
|
+
await updateAnalytics({
|
|
1000
|
+
store: number;
|
|
1001
|
+
gtm_id?: string;
|
|
1002
|
+
fb_pixel_id?: string;
|
|
1003
|
+
tt_pixel_id?: string;
|
|
1004
|
+
ga_tracking_id?: string;
|
|
1005
|
+
facebook_domain_verification?: string;
|
|
1006
|
+
google_domain_verification?: string;
|
|
1007
|
+
google_merchant_id?: string;
|
|
1008
|
+
enable_cookie_consent?: boolean;
|
|
1009
|
+
gtm_custom_enabled: boolean;
|
|
1010
|
+
gtm_custom_script_url?: string;
|
|
1011
|
+
gtm_custom_noscript_url?: string;
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
// Cache behavior:
|
|
1015
|
+
// - getStore provides Store tags (specific store id + LIST)
|
|
1016
|
+
// - payStoreCreation and updateStoreWizard invalidate Store tag by store id
|
|
1017
|
+
// - active useGetStoreQuery({ store }) subscriptions refetch automatically
|
|
1018
|
+
|
|
1019
|
+
// Delete store
|
|
1020
|
+
const [deleteStore] = storeApi.useDeleteStoreMutation();
|
|
1021
|
+
await deleteStore({
|
|
1022
|
+
store: number;
|
|
1023
|
+
});
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
### System
|
|
1027
|
+
|
|
1028
|
+
```typescript
|
|
1029
|
+
import { systemApi } from 'buymeua-api-fe';
|
|
1030
|
+
|
|
1031
|
+
// Get maintenance status (with real-time Pusher updates)
|
|
1032
|
+
const { data } = systemApi.useGetMaintenanceStatusQuery();
|
|
1033
|
+
// data.enable: boolean - true if system is available
|
|
1034
|
+
|
|
1035
|
+
// Get version check for mobile apps (with real-time Pusher updates)
|
|
1036
|
+
const { data } = systemApi.useGetVersionCheckQuery();
|
|
1037
|
+
// data.ios.minimumVersion, data.ios.lastUpdatedVersion
|
|
1038
|
+
// data.android.minimumVersion, data.android.lastUpdatedVersion
|
|
1039
|
+
|
|
1040
|
+
// Check if Telegram user exists
|
|
1041
|
+
const { data } = systemApi.useCheckTelegramUserQuery({
|
|
1042
|
+
telegram_user_name: 'username', // without @
|
|
1043
|
+
});
|
|
1044
|
+
// data.success: boolean
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
## 📋 TypeScript Types
|
|
1048
|
+
|
|
1049
|
+
The library is fully typed with TypeScript. Main types:
|
|
1050
|
+
|
|
1051
|
+
```typescript
|
|
1052
|
+
interface ApiConfig {
|
|
1053
|
+
baseUrl: string;
|
|
1054
|
+
prepareHeaders?: (
|
|
1055
|
+
headers: Headers,
|
|
1056
|
+
api: {
|
|
1057
|
+
getState: () => unknown;
|
|
1058
|
+
extra: unknown;
|
|
1059
|
+
endpoint: string;
|
|
1060
|
+
type: 'query' | 'mutation';
|
|
1061
|
+
forced?: boolean;
|
|
1062
|
+
} & {
|
|
1063
|
+
arg: unknown;
|
|
1064
|
+
extraOptions: unknown;
|
|
1065
|
+
},
|
|
1066
|
+
) => Headers | void | Promise<void>;
|
|
1067
|
+
onUnauthorized?: (
|
|
1068
|
+
args: string | FetchArgs,
|
|
1069
|
+
api: BaseQueryApi,
|
|
1070
|
+
extraOptions: unknown,
|
|
1071
|
+
) => void;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
enum Session {
|
|
1075
|
+
Dropshipper = 'dropshipper',
|
|
1076
|
+
Supplier = 'supplier',
|
|
1077
|
+
Retail = 'retail',
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
interface PaginatedResponse {
|
|
1081
|
+
meta: {
|
|
1082
|
+
current_page: number;
|
|
1083
|
+
last_page: number;
|
|
1084
|
+
per_page: number;
|
|
1085
|
+
total: number;
|
|
1086
|
+
from: number;
|
|
1087
|
+
to: number;
|
|
1088
|
+
};
|
|
1089
|
+
links: {
|
|
1090
|
+
first: string;
|
|
1091
|
+
last: string;
|
|
1092
|
+
prev: string | null;
|
|
1093
|
+
next: string | null;
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
## 📄 License
|
|
1099
|
+
|
|
1100
|
+
ISC License - see the [LICENSE](LICENSE) file for details.
|