mashroo3 0.2.0 → 0.3.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/index.d.ts +4 -0
- package/index.js +18 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -40,12 +40,14 @@ export declare class Mashroo3 {
|
|
|
40
40
|
timeoutMs: number;
|
|
41
41
|
catalog: {
|
|
42
42
|
list: (query?: QueryParams) => Promise<any[]>;
|
|
43
|
+
search: (query?: QueryParams) => Promise<{ data: any[]; meta: any }>;
|
|
43
44
|
};
|
|
44
45
|
categories: {
|
|
45
46
|
list: (query?: QueryParams) => Promise<any[]>;
|
|
46
47
|
};
|
|
47
48
|
customers: {
|
|
48
49
|
list: (query?: QueryParams) => Promise<any[]>;
|
|
50
|
+
search: (query?: QueryParams) => Promise<{ data: any[]; meta: any }>;
|
|
49
51
|
create: (payload: unknown) => Promise<any>;
|
|
50
52
|
};
|
|
51
53
|
orders: {
|
|
@@ -58,8 +60,10 @@ export declare class Mashroo3 {
|
|
|
58
60
|
request(method: string, path: string, options?: RequestOptions): Promise<any>;
|
|
59
61
|
|
|
60
62
|
listCatalog(query?: QueryParams): Promise<any[]>;
|
|
63
|
+
searchCatalog(query?: QueryParams): Promise<{ data: any[]; meta: any }>;
|
|
61
64
|
listCategories(query?: QueryParams): Promise<any[]>;
|
|
62
65
|
listCustomers(query?: QueryParams): Promise<any[]>;
|
|
66
|
+
searchCustomers(query?: QueryParams): Promise<{ data: any[]; meta: any }>;
|
|
63
67
|
createCustomer(payload: unknown): Promise<any>;
|
|
64
68
|
listOrders(query?: QueryParams): Promise<any[]>;
|
|
65
69
|
getOrder(orderId: number): Promise<any>;
|
package/index.js
CHANGED
|
@@ -36,6 +36,7 @@ class Mashroo3 {
|
|
|
36
36
|
|
|
37
37
|
this.catalog = {
|
|
38
38
|
list: (query) => this.listCatalog(query),
|
|
39
|
+
search: (query) => this.searchCatalog(query),
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
this.categories = {
|
|
@@ -44,6 +45,7 @@ class Mashroo3 {
|
|
|
44
45
|
|
|
45
46
|
this.customers = {
|
|
46
47
|
list: (query) => this.listCustomers(query),
|
|
48
|
+
search: (query) => this.searchCustomers(query),
|
|
47
49
|
create: (payload) => this.createCustomer(payload),
|
|
48
50
|
};
|
|
49
51
|
|
|
@@ -65,6 +67,14 @@ class Mashroo3 {
|
|
|
65
67
|
return this._extractList(payload, ["products", "catalog", "items"]);
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
async searchCatalog(query = {}) {
|
|
71
|
+
const payload = await this._request("GET", "/api/catalog/search", { query });
|
|
72
|
+
return {
|
|
73
|
+
data: Array.isArray(payload.data) ? payload.data : [],
|
|
74
|
+
meta: payload.meta || {},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
68
78
|
async listCategories(query = {}) {
|
|
69
79
|
const payload = await this._request("GET", "/api/categories", { query });
|
|
70
80
|
return this._extractList(payload, ["categories", "items"]);
|
|
@@ -75,6 +85,14 @@ class Mashroo3 {
|
|
|
75
85
|
return this._extractList(payload, ["customers", "items"]);
|
|
76
86
|
}
|
|
77
87
|
|
|
88
|
+
async searchCustomers(query = {}) {
|
|
89
|
+
const payload = await this._request("GET", "/api/customers/search", { query });
|
|
90
|
+
return {
|
|
91
|
+
data: Array.isArray(payload.data) ? payload.data : [],
|
|
92
|
+
meta: payload.meta || {},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
async createCustomer(payload) {
|
|
79
97
|
const response = await this._request("POST", "/api/customers", { body: payload });
|
|
80
98
|
const data = this._extractData(response);
|