Skip to content

Commit 2b58696

Browse files
committed
add new metrics endpoints
1 parent 5fb5c63 commit 2b58696

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

src/endpoints/metrics.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@ class MetricsEndpoint extends BaseExtend {
2323
'GET'
2424
)
2525
}
26+
27+
// V2 Metrics Endpoints
28+
29+
GetOrderMetricsSummary(query) {
30+
const formattedString = formatQueryParams(query)
31+
return this.request.send(
32+
`${this.endpoint}/orders/summary?${formattedString}`,
33+
'GET'
34+
)
35+
}
36+
37+
GetOrderCountTimeSeries(query) {
38+
const formattedString = formatQueryParams(query)
39+
return this.request.send(
40+
`${this.endpoint}/orders/timeseries/count?${formattedString}`,
41+
'GET'
42+
)
43+
}
44+
45+
GetOrderDiscountTimeSeries(query) {
46+
const formattedString = formatQueryParams(query)
47+
return this.request.send(
48+
`${this.endpoint}/orders/timeseries/discount?${formattedString}`,
49+
'GET'
50+
)
51+
}
52+
53+
GetOrderValueTimeSeries(query) {
54+
const formattedString = formatQueryParams(query)
55+
return this.request.send(
56+
`${this.endpoint}/orders/timeseries/value?${formattedString}`,
57+
'GET'
58+
)
59+
}
2660
}
2761

2862
export default MetricsEndpoint

src/types/metrics.d.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,59 @@ export interface MetricsQuery {
1212
interval: string
1313
}
1414

15+
// V2 Metrics Types
16+
export interface MetricsFilter {
17+
contains?: Record<string, string>
18+
}
19+
20+
export interface MetricsV2Query {
21+
start_date: string
22+
end_date: string
23+
currency: string
24+
interval?: '1hr' | '1d'
25+
filter?: MetricsFilter
26+
}
27+
28+
export interface OrderMetricsSummary {
29+
count: number
30+
total_value: number
31+
total_discount: number
32+
}
33+
34+
export interface OrderCountTimeSeries {
35+
start_date: string
36+
count: number
37+
}
38+
39+
export interface OrderDiscountTimeSeries {
40+
start_date: string
41+
discount: number
42+
}
43+
44+
export interface OrderValueTimeSeries {
45+
start_date: string
46+
value: number
47+
}
48+
1549
export interface MetricsEndpoint {
1650
TotalOrders(query: MetricsQuery): Promise<ResourcePage<MetricsBase>>
1751

1852
TotalValue(query: MetricsQuery): Promise<ResourcePage<MetricsBase>>
53+
54+
// V2 Metrics Endpoints
55+
GetOrderMetricsSummary(
56+
query: MetricsV2Query
57+
): Promise<{ data: OrderMetricsSummary }>
58+
59+
GetOrderCountTimeSeries(
60+
query: MetricsV2Query
61+
): Promise<{ data: OrderCountTimeSeries[] }>
62+
63+
GetOrderDiscountTimeSeries(
64+
query: MetricsV2Query
65+
): Promise<{ data: OrderDiscountTimeSeries[] }>
66+
67+
GetOrderValueTimeSeries(
68+
query: MetricsV2Query
69+
): Promise<{ data: OrderValueTimeSeries[] }>
1970
}

0 commit comments

Comments
 (0)