@selfcommunity/api-services 0.6.7-payments.152 → 0.6.7-payments.155

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.
@@ -0,0 +1,65 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { BaseGetParams, SCPaginatedResponse } from '../../types';
3
+ import { SCCommunity } from '@selfcommunity/types';
4
+ export interface CommunityApiClientInterface {
5
+ /**
6
+ * Get list of communities. Used to get the payment products related to the community (aka paywalls)
7
+ * @param params
8
+ * @param config
9
+ */
10
+ getCommunities(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCCommunity>>;
11
+ /**
12
+ * Get Community
13
+ * @param id
14
+ * @param config
15
+ */
16
+ getCommunity(id: number | string, config?: AxiosRequestConfig): Promise<SCCommunity>;
17
+ }
18
+ /**
19
+ * Contains all the endpoints needed to manage payments.
20
+ */
21
+ export declare class CommunityApiClient {
22
+ /**
23
+ * Get list of communities. Used to get the payment products related to the community (aka paywalls)
24
+ * @param params
25
+ * @param config
26
+ */
27
+ static getCommunities(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCCommunity>>;
28
+ /**
29
+ * Get Community
30
+ * @param id
31
+ * @param config
32
+ */
33
+ static getCommunity(id: number | string, config?: AxiosRequestConfig): Promise<SCCommunity>;
34
+ }
35
+ /**
36
+ *
37
+ :::tip Community service can be used in the following way:
38
+
39
+ ```jsx
40
+ 1. Import the service from our library:
41
+
42
+ import {CommunityService} from "@selfcommunity/api-services";
43
+ ```
44
+ ```jsx
45
+ 2. Create a function and put the service inside it!
46
+ The async function `getCommunities` will return the events matching the search query.
47
+
48
+ async getCommunities() {
49
+ return await CommunityService.getCommunities({...});
50
+ }
51
+ ```
52
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
53
+
54
+ 1. Declare it(or declare them, it is possible to add multiple params)
55
+
56
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
57
+
58
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
59
+ ```
60
+ :::
61
+ */
62
+ export default class CommunityService {
63
+ static getCommunities(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCCommunity>>;
64
+ static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCCommunity>;
65
+ }
@@ -0,0 +1,65 @@
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 CommunityApiClient {
9
+ /**
10
+ * Get list of communities. Used to get the payment products related to the community (aka paywalls)
11
+ * @param params
12
+ * @param config
13
+ */
14
+ static getCommunities(params, config) {
15
+ const p = urlParams(params);
16
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetCommunities.url({})}?${p.toString()}`, method: Endpoints.GetCommunities.method }));
17
+ }
18
+ /**
19
+ * Get Community
20
+ * @param id
21
+ * @param config
22
+ */
23
+ static getCommunity(id, config) {
24
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetCommunity.url({ id }), method: Endpoints.GetCommunity.method }));
25
+ }
26
+ }
27
+ /**
28
+ *
29
+ :::tip Community service can be used in the following way:
30
+
31
+ ```jsx
32
+ 1. Import the service from our library:
33
+
34
+ import {CommunityService} from "@selfcommunity/api-services";
35
+ ```
36
+ ```jsx
37
+ 2. Create a function and put the service inside it!
38
+ The async function `getCommunities` will return the events matching the search query.
39
+
40
+ async getCommunities() {
41
+ return await CommunityService.getCommunities({...});
42
+ }
43
+ ```
44
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
45
+
46
+ 1. Declare it(or declare them, it is possible to add multiple params)
47
+
48
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
49
+
50
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
51
+ ```
52
+ :::
53
+ */
54
+ export default class CommunityService {
55
+ static getCommunities(params, config) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ return CommunityApiClient.getCommunities(params, config);
58
+ });
59
+ }
60
+ static getPaymentProduct(id, config) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ return CommunityApiClient.getCommunity(id, config);
63
+ });
64
+ }
65
+ }
@@ -1,14 +1,26 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { BaseGetParams, SCPaginatedResponse } from '../../types';
3
- import { CheckoutCreateSessionParams, CheckoutSessionParams, ContentProductsParams, CustomerPortalCreateSessionParams } from '../../types/payment';
4
- import { SCCheckoutSession, SCPaymentOrder, SCCheckoutSessionDetail, SCCheckoutSessionComplete, SCPaymentProduct, SCPaymentPrice, SCPaymentsCustomerPortalSession, SCCommunityPaymentProducts } from '@selfcommunity/types';
2
+ import { BaseGetParams, PaymentContentStatusParams, SCPaginatedResponse } from '../../types';
3
+ import { CheckoutCreateSessionParams, CheckoutSessionParams, PaymentProductsParams, CustomerPortalCreateSessionParams } from '../../types/payment';
4
+ import { SCCheckoutSession, SCPaymentOrder, SCCheckoutSessionDetail, SCCheckoutSessionComplete, SCPaymentProduct, SCPaymentPrice, SCPaymentsCustomerPortalSession, SCPurchasableContent } from '@selfcommunity/types';
5
5
  export interface PaymentApiClientInterface {
6
6
  /**
7
- * Get paywall products related to an object of type <content_type> and id <content_id>
7
+ * Get payment products related to an object (aka paywalls) of type <content_type> and id <content_id> and the current payment_order
8
8
  * @param params
9
9
  * @param config
10
10
  */
11
- getPaymentProducts(params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
11
+ getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<SCPurchasableContent>;
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<SCPaymentProduct>>;
18
+ /**
19
+ * Get payment products
20
+ * @param params
21
+ * @param config
22
+ */
23
+ getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
12
24
  /**
13
25
  * Get product
14
26
  * @param id
@@ -22,12 +34,6 @@ export interface PaymentApiClientInterface {
22
34
  * @param config
23
35
  */
24
36
  getPaymentProductPrices(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
25
- /**
26
- * Get paywall for the community
27
- * @param params
28
- * @param config
29
- */
30
- getCommunityPaymentProducts(params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCCommunityPaymentProducts>;
31
37
  /**
32
38
  * Create session checkout with price_id for an object of type <content_type> and id <content_id>
33
39
  * @param data
@@ -63,12 +69,24 @@ export interface PaymentApiClientInterface {
63
69
  * Contains all the endpoints needed to manage payments.
64
70
  */
65
71
  export declare class PaymentApiClient {
72
+ /**
73
+ * This endpoint retrieves all the products related to an object of type <content_type> and id <content_id> and the current payment_order
74
+ * @param params
75
+ * @param config
76
+ */
77
+ static getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<SCPurchasableContent>;
66
78
  /**
67
79
  * This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
68
80
  * @param params
69
81
  * @param config
70
82
  */
71
- static getPaymentProducts(params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
83
+ static getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
84
+ /**
85
+ * This endpoint retrieves all the payment products
86
+ * @param params
87
+ * @param config
88
+ */
89
+ static getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
72
90
  /**
73
91
  * This endpoint retrieves a specific payment product.
74
92
  * @param id
@@ -82,12 +100,6 @@ export declare class PaymentApiClient {
82
100
  * @param config
83
101
  */
84
102
  static getPaymentProductPrices(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
85
- /**
86
- * This endpoint retrieves all the products related the Community product
87
- * @param params
88
- * @param config
89
- */
90
- static getCommunityPaymentProducts(params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCCommunityPaymentProducts>;
91
103
  /**
92
104
  * This endpoint creates a checkout session.
93
105
  * @param data
@@ -155,10 +167,11 @@ export declare class PaymentApiClient {
155
167
  :::
156
168
  */
157
169
  export default class PaymentService {
158
- static getPaymentProducts(params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
170
+ static getPaymentContentStatus(params?: PaymentContentStatusParams, config?: AxiosRequestConfig): Promise<SCPurchasableContent>;
171
+ static getPaywalls(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
172
+ static getPaymentProducts(params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentProduct>>;
159
173
  static getPaymentProduct(id: number | string, config?: AxiosRequestConfig): Promise<SCPaymentProduct>;
160
- static getPaymentProductPrices(id: number | string, params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
161
- static getCommunityPaymentProducts(params?: ContentProductsParams, config?: AxiosRequestConfig): Promise<SCCommunityPaymentProducts>;
174
+ static getPaymentProductPrices(id: number | string, params?: PaymentProductsParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCPaymentPrice>>;
162
175
  static checkoutCreateSession(data: CheckoutCreateSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSession>;
163
176
  static getCheckoutSession(params?: CheckoutSessionParams, config?: AxiosRequestConfig): Promise<SCCheckoutSessionDetail>;
164
177
  static checkoutCompleteSession(data: CheckoutSessionParams | FormData, config?: AxiosRequestConfig): Promise<SCCheckoutSessionComplete>;
@@ -6,14 +6,32 @@ import { urlParams } from '../../utils/url';
6
6
  * Contains all the endpoints needed to manage payments.
7
7
  */
8
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
+ const p = urlParams(params);
16
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentContentStatus.url({})}?${p.toString()}`, method: Endpoints.GetPaymentContentStatus.method }));
17
+ }
9
18
  /**
10
19
  * This endpoint retrieves all the products related to an object of type <content_type> and id <content_id>
11
20
  * @param params
12
21
  * @param config
13
22
  */
23
+ static getPaywalls(params, config) {
24
+ const p = urlParams(params);
25
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaywalls.url({})}?${p.toString()}`, method: Endpoints.GetPaywalls.method }));
26
+ }
27
+ /**
28
+ * This endpoint retrieves all the payment products
29
+ * @param params
30
+ * @param config
31
+ */
14
32
  static getPaymentProducts(params, config) {
15
33
  const p = urlParams(params);
16
- return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetContentProducts.url({})}?${p.toString()}`, method: Endpoints.GetContentProducts.method }));
34
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentProducts.url({})}?${p.toString()}`, method: Endpoints.GetPaymentProducts.method }));
17
35
  }
18
36
  /**
19
37
  * This endpoint retrieves a specific payment product.
@@ -21,7 +39,7 @@ export class PaymentApiClient {
21
39
  * @param config
22
40
  */
23
41
  static getPaymentProduct(id, config) {
24
- return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetProduct.url({ id }), method: Endpoints.GetProduct.method }));
42
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetPaymentProduct.url({ id }), method: Endpoints.GetPaymentProduct.method }));
25
43
  }
26
44
  /**
27
45
  * This endpoint retrieves all the prices related to a product
@@ -31,16 +49,7 @@ export class PaymentApiClient {
31
49
  */
32
50
  static getPaymentProductPrices(id, params, config) {
33
51
  const p = urlParams(params);
34
- return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetProductPrices.url({ id })}?${p.toString()}`, method: Endpoints.GetProductPrices.method }));
35
- }
36
- /**
37
- * This endpoint retrieves all the products related the Community product
38
- * @param params
39
- * @param config
40
- */
41
- static getCommunityPaymentProducts(params, config) {
42
- const p = urlParams(params);
43
- return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetCommunityProduct.url({})}?${p.toString()}`, method: Endpoints.GetCommunityProduct.method }));
52
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetPaymentProductPrices.url({ id })}?${p.toString()}`, method: Endpoints.GetPaymentProductPrices.method }));
44
53
  }
45
54
  /**
46
55
  * This endpoint creates a checkout session.
@@ -120,6 +129,16 @@ export class PaymentApiClient {
120
129
  :::
121
130
  */
122
131
  export default class PaymentService {
132
+ static getPaymentContentStatus(params, config) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ return PaymentApiClient.getPaymentContentStatus(params, config);
135
+ });
136
+ }
137
+ static getPaywalls(params, config) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ return PaymentApiClient.getPaywalls(params, config);
140
+ });
141
+ }
123
142
  static getPaymentProducts(params, config) {
124
143
  return __awaiter(this, void 0, void 0, function* () {
125
144
  return PaymentApiClient.getPaymentProducts(params, config);
@@ -135,11 +154,6 @@ export default class PaymentService {
135
154
  return PaymentApiClient.getPaymentProductPrices(id, params, config);
136
155
  });
137
156
  }
138
- static getCommunityPaymentProducts(params, config) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- return PaymentApiClient.getCommunityPaymentProducts(params, config);
141
- });
142
- }
143
157
  static checkoutCreateSession(data, config) {
144
158
  return __awaiter(this, void 0, void 0, function* () {
145
159
  return PaymentApiClient.checkoutCreateSession(data, config);
@@ -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
- 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, 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 };
31
+ import { PaymentContentStatusParams, PaymentProductsParams, CustomerPortalCreateSessionParams, CheckoutSessionParams, CheckoutCreateSessionParams } 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, 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, PaymentProductsParams, CustomerPortalCreateSessionParams, CheckoutSessionParams, CheckoutCreateSessionParams };
@@ -3,7 +3,7 @@ import { SCCheckoutSessionUIMode, SCContentType } from '@selfcommunity/types';
3
3
  /**
4
4
  * PaymentParams interface.
5
5
  */
6
- export interface ContentProductsParams extends BaseGetParams {
6
+ export interface PaymentProductsParams extends BaseGetParams {
7
7
  /**
8
8
  * Content id
9
9
  */
@@ -55,3 +55,16 @@ export interface CustomerPortalCreateSessionParams {
55
55
  */
56
56
  return_url?: string;
57
57
  }
58
+ /**
59
+ * PaymentContentStatusParams interface.
60
+ */
61
+ export interface PaymentContentStatusParams extends BaseGetParams {
62
+ /**
63
+ * Content id
64
+ */
65
+ content_id?: number | string;
66
+ /**
67
+ * Content type
68
+ */
69
+ content_type?: SCContentType;
70
+ }