@selfcommunity/api-services 0.7.0-alpha.0 → 0.7.0-alpha.2
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/lib/cjs/client/index.d.ts +3 -3
- package/lib/cjs/client/index.js +3 -3
- package/lib/cjs/constants/Endpoints.js +92 -1
- package/lib/cjs/index.d.ts +4 -2
- package/lib/cjs/index.js +7 -1
- package/lib/cjs/services/community/index.d.ts +65 -0
- package/lib/cjs/services/community/index.js +70 -0
- package/lib/cjs/services/feed_object/index.d.ts +28 -1
- package/lib/cjs/services/feed_object/index.js +44 -0
- package/lib/cjs/services/payment/index.d.ts +219 -0
- package/lib/cjs/services/payment/index.js +218 -0
- package/lib/cjs/services/user/index.d.ts +21 -1
- package/lib/cjs/services/user/index.js +30 -0
- package/lib/cjs/types/feedObject.d.ts +17 -0
- package/lib/cjs/types/index.d.ts +3 -2
- package/lib/cjs/types/payment.d.ts +137 -0
- package/lib/cjs/types/payment.js +2 -0
- package/lib/esm/client/index.d.ts +3 -3
- package/lib/esm/client/index.js +3 -3
- package/lib/esm/constants/Endpoints.js +92 -1
- package/lib/esm/index.d.ts +4 -2
- package/lib/esm/index.js +3 -1
- package/lib/esm/services/community/index.d.ts +65 -0
- package/lib/esm/services/community/index.js +65 -0
- package/lib/esm/services/feed_object/index.d.ts +28 -1
- package/lib/esm/services/feed_object/index.js +44 -0
- package/lib/esm/services/payment/index.d.ts +219 -0
- package/lib/esm/services/payment/index.js +213 -0
- package/lib/esm/services/user/index.d.ts +21 -1
- package/lib/esm/services/user/index.js +30 -0
- package/lib/esm/types/feedObject.d.ts +17 -0
- package/lib/esm/types/index.d.ts +3 -2
- package/lib/esm/types/payment.d.ts +137 -0
- package/lib/esm/types/payment.js +1 -0
- package/lib/umd/740.js +2 -0
- package/lib/umd/api-services.js +1 -1
- package/package.json +4 -4
- package/lib/umd/956.js +0 -2
- /package/lib/umd/{956.js.LICENSE.txt → 740.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { BaseGetParams, PaymentContentStatus, SCPaginatedResponse } from '../../types';
|
|
3
|
+
import { CheckoutCreateSessionParams, CheckoutSessionParams, PaymentProductsParams, CustomerPortalCreateSessionParams, PaymentContentStatusParams, PaymentOrderParams, CreatePaymentProductParams } from '../../types/payment';
|
|
4
|
+
import { SCCheckoutSession, SCPaymentOrder, SCCheckoutSessionDetail, SCCheckoutSessionComplete, SCPaymentProduct, SCPaymentPrice, SCPaymentsCustomerPortalSession, SCPaywall } from '@selfcommunity/types';
|
|
5
|
+
export interface PaymentApiClientInterface {
|
|
6
|
+
/**
|
|
7
|
+
* Get payment products related to an object (aka paywalls) of type <content_type> and id <content_id> and the current payment_order
|
|
8
|
+
* @param params
|
|
9
|
+
* @param config
|
|
10
|
+
*/
|
|
11
|
+
getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<PaymentContentStatus>;
|
|
12
|
+
/**
|
|
13
|
+
* Get payment products related to an object (aka paywalls) of type <content_type> and id <content_id>
|
|
14
|
+
* @param params
|
|
15
|
+
* @param config
|
|
16
|
+
*/
|
|
17
|
+
getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaywall>>;
|
|
18
|
+
/**
|
|
19
|
+
* Get payment products
|
|
20
|
+
* @param params
|
|
21
|
+
* @param config
|
|
22
|
+
*/
|
|
23
|
+
getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
|
|
24
|
+
/**
|
|
25
|
+
* Get product
|
|
26
|
+
* @param id
|
|
27
|
+
* @param config
|
|
28
|
+
*/
|
|
29
|
+
getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
30
|
+
/**
|
|
31
|
+
* Get prices related to a product
|
|
32
|
+
* @param id
|
|
33
|
+
* @param params
|
|
34
|
+
* @param config
|
|
35
|
+
*/
|
|
36
|
+
getPaymentProductPrices(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
|
|
37
|
+
/**
|
|
38
|
+
* Create session checkout with price_id for an object of type <content_type> and id <content_id>
|
|
39
|
+
* @param data
|
|
40
|
+
* @param config
|
|
41
|
+
*/
|
|
42
|
+
checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* This endpoint retrieve checkout session
|
|
45
|
+
* @param params
|
|
46
|
+
* @param config
|
|
47
|
+
*/
|
|
48
|
+
getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
|
|
49
|
+
/**
|
|
50
|
+
* Complete session checkout
|
|
51
|
+
* @param data
|
|
52
|
+
* @param config
|
|
53
|
+
*/
|
|
54
|
+
checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
|
|
55
|
+
/**
|
|
56
|
+
* This endpoint retrieve order history of authenticated user
|
|
57
|
+
* @param params
|
|
58
|
+
* @param config
|
|
59
|
+
*/
|
|
60
|
+
getPaymentsOrder(params?: PaymentOrderParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
61
|
+
/**
|
|
62
|
+
* This endpoint retrieves the single payment order
|
|
63
|
+
* @param id
|
|
64
|
+
* @param config
|
|
65
|
+
*/
|
|
66
|
+
getPaymentOrder(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentOrder>;
|
|
67
|
+
/**
|
|
68
|
+
* This endpoint retrieves the single payment order in pdf format
|
|
69
|
+
* @param id
|
|
70
|
+
* @param config
|
|
71
|
+
*/
|
|
72
|
+
getPaymentOrderPdf(id: number | string, config?: AxiosRequestConfig): Promise<Blob>;
|
|
73
|
+
/**
|
|
74
|
+
* This endpoint retrieve customer portal
|
|
75
|
+
* @param data
|
|
76
|
+
* @param config
|
|
77
|
+
*/
|
|
78
|
+
getPaymentsCustomerPortal(data: CustomerPortalCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentsCustomerPortalSession>;
|
|
79
|
+
/**
|
|
80
|
+
* Create payment product
|
|
81
|
+
* @param data
|
|
82
|
+
* @param config
|
|
83
|
+
*/
|
|
84
|
+
createPaymentProduct(data: CreatePaymentProductParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Contains all the endpoints needed to manage payments.
|
|
88
|
+
*/
|
|
89
|
+
export declare class PaymentApiClient {
|
|
90
|
+
/**
|
|
91
|
+
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id> and the current payment_order
|
|
92
|
+
* @param params
|
|
93
|
+
* @param config
|
|
94
|
+
*/
|
|
95
|
+
static getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<PaymentContentStatus>;
|
|
96
|
+
/**
|
|
97
|
+
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
|
|
98
|
+
* @param params
|
|
99
|
+
* @param config
|
|
100
|
+
*/
|
|
101
|
+
static getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaywall>>;
|
|
102
|
+
/**
|
|
103
|
+
* This endpoint retrieves all the payment products
|
|
104
|
+
* @param params
|
|
105
|
+
* @param config
|
|
106
|
+
*/
|
|
107
|
+
static getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
|
|
108
|
+
/**
|
|
109
|
+
* This endpoint retrieves a specific payment product.
|
|
110
|
+
* @param id
|
|
111
|
+
* @param config
|
|
112
|
+
*/
|
|
113
|
+
static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
114
|
+
/**
|
|
115
|
+
* This endpoint retrieves all the prices related to a product
|
|
116
|
+
* @param id
|
|
117
|
+
* @param params
|
|
118
|
+
* @param config
|
|
119
|
+
*/
|
|
120
|
+
static getPaymentProductPrices(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
|
|
121
|
+
/**
|
|
122
|
+
* This endpoint creates a checkout session.
|
|
123
|
+
* @param data
|
|
124
|
+
* @param config
|
|
125
|
+
*/
|
|
126
|
+
static checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSession>;
|
|
127
|
+
/**
|
|
128
|
+
* Create payment product
|
|
129
|
+
* @param data
|
|
130
|
+
* @param config
|
|
131
|
+
*/
|
|
132
|
+
static createPaymentProduct(data: CreatePaymentProductParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
133
|
+
/**
|
|
134
|
+
* This endpoint retrieve checkout session
|
|
135
|
+
* @param params
|
|
136
|
+
* @param config
|
|
137
|
+
*/
|
|
138
|
+
static getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
|
|
139
|
+
/**
|
|
140
|
+
* This endpoint complete checkout session
|
|
141
|
+
* @param data
|
|
142
|
+
* @param config
|
|
143
|
+
*/
|
|
144
|
+
static checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
|
|
145
|
+
/**
|
|
146
|
+
* This endpoint retrive order history of authenticated user
|
|
147
|
+
* @param params
|
|
148
|
+
* @param config
|
|
149
|
+
*/
|
|
150
|
+
static getPaymentsOrder(params?: PaymentOrderParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
151
|
+
/**
|
|
152
|
+
* This endpoint retrieves the single payment order
|
|
153
|
+
* @param id
|
|
154
|
+
* @param config
|
|
155
|
+
*/
|
|
156
|
+
static getPaymentOrder(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentOrder>;
|
|
157
|
+
/**
|
|
158
|
+
* This endpoint retrieves the single payment order in pdf format
|
|
159
|
+
* @param id
|
|
160
|
+
* @param config
|
|
161
|
+
*/
|
|
162
|
+
static getPaymentOrderPdf(id: number | string, config?: AxiosRequestConfig): Promise<Blob>;
|
|
163
|
+
/**
|
|
164
|
+
* This endpoint retrive customer portal
|
|
165
|
+
* @param data
|
|
166
|
+
* @param config
|
|
167
|
+
*/
|
|
168
|
+
static getPaymentsCustomerPortal(data: CustomerPortalCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentsCustomerPortalSession>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
:::tip Payment service can be used in the following way:
|
|
173
|
+
|
|
174
|
+
```jsx
|
|
175
|
+
1. Import the service from our library:
|
|
176
|
+
|
|
177
|
+
import {PaymentService} from "@selfcommunity/api-services";
|
|
178
|
+
```
|
|
179
|
+
```jsx
|
|
180
|
+
2. Create a function and put the service inside it!
|
|
181
|
+
The async function `getPaymentProducts` will return the events matching the search query.
|
|
182
|
+
|
|
183
|
+
async getPaymentProducts() {
|
|
184
|
+
return await PaymentService.getPaymentProducts({...});
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
```jsx
|
|
188
|
+
In case of required `params`, just add them inside the brackets.
|
|
189
|
+
|
|
190
|
+
async getPaymentPrices(eventId) {
|
|
191
|
+
return await PaymentService.getProductPrices(id);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
```jsx
|
|
195
|
+
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
196
|
+
|
|
197
|
+
1. Declare it(or declare them, it is possible to add multiple params)
|
|
198
|
+
|
|
199
|
+
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
200
|
+
|
|
201
|
+
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
202
|
+
```
|
|
203
|
+
:::
|
|
204
|
+
*/
|
|
205
|
+
export default class PaymentService {
|
|
206
|
+
static getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<PaymentContentStatus>;
|
|
207
|
+
static getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaywall>>;
|
|
208
|
+
static getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
|
|
209
|
+
static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
210
|
+
static getPaymentProductPrices(id: number | string, params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
|
|
211
|
+
static checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSession>;
|
|
212
|
+
static getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
|
|
213
|
+
static checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
|
|
214
|
+
static getPaymentsOrder(params?: PaymentOrderParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
215
|
+
static getPaymentOrder(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentOrder>;
|
|
216
|
+
static getPaymentOrderPdf(id: number | string, config?: AxiosRequestConfig): Promise<Blob>;
|
|
217
|
+
static getPaymentsCustomerPortal(data: CustomerPortalCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentsCustomerPortalSession>;
|
|
218
|
+
static createPaymentProduct(data: CreatePaymentProductParams | FormData, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
|
|
219
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import Endpoints from '../../constants/Endpoints';
|
|
3
|
+
import { apiRequest } from '../../utils/apiRequest';
|
|
4
|
+
import { urlParams } from '../../utils/url';
|
|
5
|
+
/**
|
|
6
|
+
* Contains all the endpoints needed to manage payments.
|
|
7
|
+
*/
|
|
8
|
+
export class PaymentApiClient {
|
|
9
|
+
/**
|
|
10
|
+
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id> and the current payment_order
|
|
11
|
+
* @param params
|
|
12
|
+
* @param config
|
|
13
|
+
*/
|
|
14
|
+
static getPaymentContentStatus(params, config) {
|
|
15
|
+
return apiRequest(Object.assign(Object.assign({}, config), { params, url: `${Endpoints.GetPaymentContentStatus.url({})}`, method: Endpoints.GetPaymentContentStatus.method }));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
|
|
19
|
+
* @param params
|
|
20
|
+
* @param config
|
|
21
|
+
*/
|
|
22
|
+
static getPaywalls(params, config) {
|
|
23
|
+
const p = urlParams(params);
|
|
24
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaywalls.url({})}?${p.toString()}`, method: Endpoints.GetPaywalls.method }));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* This endpoint retrieves all the payment products
|
|
28
|
+
* @param params
|
|
29
|
+
* @param config
|
|
30
|
+
*/
|
|
31
|
+
static getPaymentProducts(params, config) {
|
|
32
|
+
const p = urlParams(params);
|
|
33
|
+
return apiRequest(Object.assign({ url: `${Endpoints.GetPaymentProducts.url({})}?${p.toString()}`, method: Endpoints.GetPaymentProducts.method }, config));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* This endpoint retrieves a specific payment product.
|
|
37
|
+
* @param id
|
|
38
|
+
* @param config
|
|
39
|
+
*/
|
|
40
|
+
static getPaymentProduct(id, config) {
|
|
41
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetPaymentProduct.url({ id }), method: Endpoints.GetPaymentProduct.method }));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This endpoint retrieves all the prices related to a product
|
|
45
|
+
* @param id
|
|
46
|
+
* @param params
|
|
47
|
+
* @param config
|
|
48
|
+
*/
|
|
49
|
+
static getPaymentProductPrices(id, params, config) {
|
|
50
|
+
const p = urlParams(params);
|
|
51
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentProductPrices.url({ id })}?${p.toString()}`, method: Endpoints.GetPaymentProductPrices.method }));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* This endpoint creates a checkout session.
|
|
55
|
+
* @param data
|
|
56
|
+
* @param config
|
|
57
|
+
*/
|
|
58
|
+
static checkoutCreateSession(data, config) {
|
|
59
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CheckoutCreateSession.url({}), method: Endpoints.CheckoutCreateSession.method, data }));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create payment product
|
|
63
|
+
* @param data
|
|
64
|
+
* @param config
|
|
65
|
+
*/
|
|
66
|
+
static createPaymentProduct(data, config) {
|
|
67
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CreatePaymentProduct.url({}), method: Endpoints.CreatePaymentProduct.method, data }));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* This endpoint retrieve checkout session
|
|
71
|
+
* @param params
|
|
72
|
+
* @param config
|
|
73
|
+
*/
|
|
74
|
+
static getCheckoutSession(params, config) {
|
|
75
|
+
const p = urlParams(params);
|
|
76
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetCheckoutSession.url({})}?${p.toString()}`, method: Endpoints.GetCheckoutSession.method }));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* This endpoint complete checkout session
|
|
80
|
+
* @param data
|
|
81
|
+
* @param config
|
|
82
|
+
*/
|
|
83
|
+
static checkoutCompleteSession(data, config) {
|
|
84
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CheckoutSessionComplete.url({}), method: Endpoints.CheckoutSessionComplete.method, data }));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* This endpoint retrive order history of authenticated user
|
|
88
|
+
* @param params
|
|
89
|
+
* @param config
|
|
90
|
+
*/
|
|
91
|
+
static getPaymentsOrder(params, config) {
|
|
92
|
+
const p = urlParams(params);
|
|
93
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentOrders.url({})}?${p.toString()}`, method: Endpoints.GetPaymentOrders.method }));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* This endpoint retrieves the single payment order
|
|
97
|
+
* @param id
|
|
98
|
+
* @param config
|
|
99
|
+
*/
|
|
100
|
+
static getPaymentOrder(id, config) {
|
|
101
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentOrder.url({ id })}`, method: Endpoints.GetPaymentOrder.method }));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* This endpoint retrieves the single payment order in pdf format
|
|
105
|
+
* @param id
|
|
106
|
+
* @param config
|
|
107
|
+
*/
|
|
108
|
+
static getPaymentOrderPdf(id, config) {
|
|
109
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentOrderPdf.url({ id })}`, method: Endpoints.GetPaymentOrderPdf.method }));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* This endpoint retrive customer portal
|
|
113
|
+
* @param data
|
|
114
|
+
* @param config
|
|
115
|
+
*/
|
|
116
|
+
static getPaymentsCustomerPortal(data, config) {
|
|
117
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CreateCustomerPortalSession.url({}), method: Endpoints.CreateCustomerPortalSession.method, data }));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
:::tip Payment service can be used in the following way:
|
|
123
|
+
|
|
124
|
+
```jsx
|
|
125
|
+
1. Import the service from our library:
|
|
126
|
+
|
|
127
|
+
import {PaymentService} from "@selfcommunity/api-services";
|
|
128
|
+
```
|
|
129
|
+
```jsx
|
|
130
|
+
2. Create a function and put the service inside it!
|
|
131
|
+
The async function `getPaymentProducts` will return the events matching the search query.
|
|
132
|
+
|
|
133
|
+
async getPaymentProducts() {
|
|
134
|
+
return await PaymentService.getPaymentProducts({...});
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
```jsx
|
|
138
|
+
In case of required `params`, just add them inside the brackets.
|
|
139
|
+
|
|
140
|
+
async getPaymentPrices(eventId) {
|
|
141
|
+
return await PaymentService.getProductPrices(id);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
```jsx
|
|
145
|
+
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
|
|
146
|
+
|
|
147
|
+
1. Declare it(or declare them, it is possible to add multiple params)
|
|
148
|
+
|
|
149
|
+
const headers = headers: {Authorization: `Bearer ${yourToken}`}
|
|
150
|
+
|
|
151
|
+
2. Add it inside the brackets and pass it to the function, as shown in the previous example!
|
|
152
|
+
```
|
|
153
|
+
:::
|
|
154
|
+
*/
|
|
155
|
+
export default class PaymentService {
|
|
156
|
+
static getPaymentContentStatus(params, config) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
return PaymentApiClient.getPaymentContentStatus(params, config);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
static getPaywalls(params, config) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
return PaymentApiClient.getPaywalls(params, config);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
static getPaymentProducts(params, config) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
return PaymentApiClient.getPaymentProducts(params, config);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
static getPaymentProduct(id, config) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
return PaymentApiClient.getPaymentProduct(id, config);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
static getPaymentProductPrices(id, params, config) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
return PaymentApiClient.getPaymentProductPrices(id, params, config);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
static checkoutCreateSession(data, config) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
return PaymentApiClient.checkoutCreateSession(data, config);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
static getCheckoutSession(params, config) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
return PaymentApiClient.getCheckoutSession(params, config);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
static checkoutCompleteSession(data, config) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
return PaymentApiClient.checkoutCompleteSession(data, config);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
static getPaymentsOrder(params, config) {
|
|
197
|
+
return PaymentApiClient.getPaymentsOrder(params, config);
|
|
198
|
+
}
|
|
199
|
+
static getPaymentOrder(id, config) {
|
|
200
|
+
return PaymentApiClient.getPaymentOrder(id, config);
|
|
201
|
+
}
|
|
202
|
+
static getPaymentOrderPdf(id, config) {
|
|
203
|
+
return PaymentApiClient.getPaymentOrderPdf(id, config);
|
|
204
|
+
}
|
|
205
|
+
static getPaymentsCustomerPortal(data, config) {
|
|
206
|
+
return PaymentApiClient.getPaymentsCustomerPortal(data, config);
|
|
207
|
+
}
|
|
208
|
+
static createPaymentProduct(data, config) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
return PaymentApiClient.createPaymentProduct(data, config);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SCAvatarType, SCCategoryType, SCFeedUnitType, SCLiveStreamType, SCPlatformType, SCTagType, SCUserAutocompleteType, SCUserAvatarType, SCUserChangeEmailType, SCUserConnectionRequestType, SCUserConnectionStatusType, SCUserCounterType, SCUserEmailTokenType, SCUserFollowedStatusType, SCUserFollowerStatusType, SCUserHiddenByStatusType, SCUserHiddenStatusType, SCUserLoyaltyPointsType, SCUserPermissionType, SCUserProviderAssociationType, SCUserSettingsType, SCUserType } from '@selfcommunity/types';
|
|
1
|
+
import { SCAvatarType, SCCategoryType, SCFeedUnitType, SCLiveStreamType, SCPaymentOrder, SCPlatformType, SCTagType, SCUserAutocompleteType, SCUserAvatarType, SCUserChangeEmailType, SCUserConnectionRequestType, SCUserConnectionStatusType, SCUserCounterType, SCUserEmailTokenType, SCUserFollowedStatusType, SCUserFollowerStatusType, SCUserHiddenByStatusType, SCUserHiddenStatusType, SCUserLoyaltyPointsType, SCUserPermissionType, SCUserProviderAssociationType, SCUserSettingsType, SCUserType } from '@selfcommunity/types';
|
|
2
2
|
import { BaseGetParams, SCPaginatedResponse, UserAutocompleteParams, UserGetParams, UserSearchParams } from '../../types';
|
|
3
3
|
import { AxiosRequestConfig } from 'axios';
|
|
4
4
|
import { DeleteProviderAssociation } from '../../types/user';
|
|
@@ -55,6 +55,8 @@ export interface UserApiClientInterface {
|
|
|
55
55
|
createProviderAssociation(data: SCUserProviderAssociationType, config?: AxiosRequestConfig): Promise<SCUserProviderAssociationType>;
|
|
56
56
|
deleteProviderAssociation(data: DeleteProviderAssociation, config?: AxiosRequestConfig): Promise<any>;
|
|
57
57
|
getUserLiveStream(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCLiveStreamType>>;
|
|
58
|
+
getOrderHistory(id: number, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaymentOrder[]>;
|
|
59
|
+
getOrderDetail(id: number, order: number, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaymentOrder>;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Contains all the endpoints needed to manage users.
|
|
@@ -392,6 +394,22 @@ export declare class UserApiClient {
|
|
|
392
394
|
* @param config
|
|
393
395
|
*/
|
|
394
396
|
static getUserLiveStream(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCLiveStreamType>>;
|
|
397
|
+
/**
|
|
398
|
+
* This endpoint retrieve all order history of authenticated user
|
|
399
|
+
*
|
|
400
|
+
* @param id
|
|
401
|
+
* @param params
|
|
402
|
+
* @param config
|
|
403
|
+
*/
|
|
404
|
+
static getOrderHistory(id: number, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
405
|
+
/**
|
|
406
|
+
* This endpoint retrieve detail of an order
|
|
407
|
+
* @param id
|
|
408
|
+
* @param order
|
|
409
|
+
* @param params
|
|
410
|
+
* @param config
|
|
411
|
+
*/
|
|
412
|
+
static getOrderDetail(id: number, order: number, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaymentOrder>;
|
|
395
413
|
}
|
|
396
414
|
/**
|
|
397
415
|
*
|
|
@@ -483,4 +501,6 @@ export default class UserService {
|
|
|
483
501
|
static createProviderAssociation(data: SCUserProviderAssociationType, config?: AxiosRequestConfig): Promise<SCUserProviderAssociationType>;
|
|
484
502
|
static deleteProviderAssociation(data: DeleteProviderAssociation, config?: AxiosRequestConfig): Promise<any>;
|
|
485
503
|
static getUserLiveStream(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCLiveStreamType>>;
|
|
504
|
+
static getOrderHistory(id: number, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentOrder>>;
|
|
505
|
+
static getOrderDetail(id: number, order: number, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaymentOrder>;
|
|
486
506
|
}
|
|
@@ -457,6 +457,26 @@ export class UserApiClient {
|
|
|
457
457
|
static getUserLiveStream(id, params, config) {
|
|
458
458
|
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetLiveStream.url({ id }), method: Endpoints.UserFeed.method, params }));
|
|
459
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* This endpoint retrieve all order history of authenticated user
|
|
462
|
+
*
|
|
463
|
+
* @param id
|
|
464
|
+
* @param params
|
|
465
|
+
* @param config
|
|
466
|
+
*/
|
|
467
|
+
static getOrderHistory(id, params, config) {
|
|
468
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetOrderHistory.url({ id }), method: Endpoints.GetOrderHistory.method, params }));
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* This endpoint retrieve detail of an order
|
|
472
|
+
* @param id
|
|
473
|
+
* @param order
|
|
474
|
+
* @param params
|
|
475
|
+
* @param config
|
|
476
|
+
*/
|
|
477
|
+
static getOrderDetail(id, order, params, config) {
|
|
478
|
+
return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetOrderDetail.url({ id, order }), method: Endpoints.GetOrderDetail.method, params }));
|
|
479
|
+
}
|
|
460
480
|
}
|
|
461
481
|
/**
|
|
462
482
|
*
|
|
@@ -756,4 +776,14 @@ export default class UserService {
|
|
|
756
776
|
return UserApiClient.getUserLiveStream(id, params, config);
|
|
757
777
|
});
|
|
758
778
|
}
|
|
779
|
+
static getOrderHistory(id, params, config) {
|
|
780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
781
|
+
return UserApiClient.getOrderHistory(id, params, config);
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
static getOrderDetail(id, order, params, config) {
|
|
785
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
786
|
+
return UserApiClient.getOrderDetail(id, order, params, config);
|
|
787
|
+
});
|
|
788
|
+
}
|
|
759
789
|
}
|
|
@@ -43,6 +43,10 @@ export interface FeedObjCreateParams {
|
|
|
43
43
|
* The list of tag ids.
|
|
44
44
|
*/
|
|
45
45
|
addressing?: number[];
|
|
46
|
+
/**
|
|
47
|
+
* If the feed obj is not published yet
|
|
48
|
+
*/
|
|
49
|
+
draft?: boolean;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* FeedObjectPollVotesSearch interface
|
|
@@ -53,3 +57,16 @@ export interface FeedObjectPollVotesSearch extends BaseGetParams {
|
|
|
53
57
|
*/
|
|
54
58
|
choice?: number;
|
|
55
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* ScheduledFeedObjParams interface
|
|
62
|
+
*/
|
|
63
|
+
export interface ScheduledFeedObjParams {
|
|
64
|
+
/**
|
|
65
|
+
* Includes posts that were scheduled and already published
|
|
66
|
+
*/
|
|
67
|
+
include_published?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Show only posts that were scheduled and already published
|
|
70
|
+
*/
|
|
71
|
+
only_published?: boolean;
|
|
72
|
+
}
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { CustomAdvParams } from './customAdv';
|
|
|
16
16
|
import { CustomPageParams, CustomPageSearchParams } from './customPage';
|
|
17
17
|
import { EmbedUpdateParams, EmbedSearchParams } from './embed';
|
|
18
18
|
import { BaseGetParams, BaseSearchParams } from './baseParams';
|
|
19
|
-
import { FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch } from './feedObject';
|
|
19
|
+
import { FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, ScheduledFeedObjParams } from './feedObject';
|
|
20
20
|
import { FeedParams } from './feed';
|
|
21
21
|
import { LegalPageFilterParams } from './legalPage';
|
|
22
22
|
import { FeatureParams } from './feature';
|
|
@@ -28,4 +28,5 @@ import { EventCreateParams, EventFeedParams, EventRelatedParams, EventSearchPara
|
|
|
28
28
|
import { LiveStreamCreateParams, LiveStreamSearchParams, LiveStreamRemoveParticipantParams } from './liveStream';
|
|
29
29
|
import { StartStepParams, OnBoardingStep } from './onBoarding';
|
|
30
30
|
import { CourseCreateParams, CourseSearchParams, CourseInfoViewType, CourseInfoParams, CourseLessonCommentsParams, CourseUserRoleParams, CourseUsersParams, CourseDashboardUsersParams } from './course';
|
|
31
|
-
|
|
31
|
+
import { PaymentContentStatusParams, PaymentContentStatus, PaymentProductsParams, CustomerPortalCreateSessionParams, CheckoutSessionParams, CheckoutCreateSessionParams, PaymentOrderParams } from './payment';
|
|
32
|
+
export { AccountCreateParams, AccountVerifyParams, AccountRecoverParams, AccountResetParams, AccountSearchParams, SCPaginatedResponse, WebhookParamType, WebhookEventsType, SSOSignUpParams, CommentListParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, ModerateContributionParams, FlaggedContributionParams, CustomNotificationParams, UserGetParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadCompleteParams, ChunkUploadParams, ThreadParams, ThreadDeleteParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, ScheduledFeedObjParams, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams, GroupCreateParams, GroupFeedParams, EventCreateParams, EventFeedParams, EventRelatedParams, EventSearchParams, LiveStreamCreateParams, LiveStreamSearchParams, LiveStreamRemoveParticipantParams, StartStepParams, OnBoardingStep, CourseCreateParams, CourseSearchParams, CourseInfoViewType, CourseInfoParams, CourseLessonCommentsParams, CourseUserRoleParams, CourseUsersParams, CourseDashboardUsersParams, PaymentContentStatusParams, PaymentContentStatus, PaymentProductsParams, CustomerPortalCreateSessionParams, CheckoutSessionParams, CheckoutCreateSessionParams, PaymentOrderParams };
|