@selfcommunity/api-services 0.3.6-alpha.7 → 0.3.6-alpha.8

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,54 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { SCPromoType } from '@selfcommunity/types';
3
+ export interface PromoApiClientInterface {
4
+ getSpecificPromo(code: string, config?: AxiosRequestConfig): Promise<SCPromoType>;
5
+ }
6
+ /**
7
+ * Contains all the endpoints needed to manage Promo codes.
8
+ */
9
+ export declare class PromoApiClient {
10
+ /**
11
+ * This endpoint retrieves a specific Promo identified by Promo code.
12
+ * @param code
13
+ * @param config
14
+ */
15
+ static getSpecificPromo(code: string, config?: AxiosRequestConfig): Promise<SCPromoType>;
16
+ }
17
+ /**
18
+ *
19
+ :::tip Promo service can be used in the following way:
20
+ ```jsx
21
+ 1. Import the service from our library:
22
+
23
+ import {PromoService} from "@selfcommunity/api-services";
24
+ ```
25
+ ```jsx
26
+ 2. Create a function and put the service inside it!
27
+ The async function `create` will return the paginated list of categories.
28
+
29
+ async getSpecificPromoCode() {
30
+ return await PromoService.getSpecificPromo();
31
+ }
32
+ ```
33
+ ```jsx
34
+ In case of required `params`, just add them inside the brackets.
35
+
36
+ async create(data) {
37
+ return await PromoService.getSpecificPromo(code);
38
+ }
39
+ ```
40
+ ```jsx
41
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
42
+
43
+ 1. Declare it(or declare them, it is possible to add multiple params)
44
+
45
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
46
+
47
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
48
+ ```
49
+ :::
50
+ */
51
+ export default class PromoService {
52
+ static getSpecificPromo(code: string, config?: AxiosRequestConfig): Promise<SCPromoType>;
53
+ }
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/promo/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,OAAO,CAAC;AACzC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACnF;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAGzF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;WAClB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAG/F"}
@@ -0,0 +1,66 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Endpoints from '../../constants/Endpoints';
11
+ import { apiRequest } from '../../utils/apiRequest';
12
+ /**
13
+ * Contains all the endpoints needed to manage Promo codes.
14
+ */
15
+ export class PromoApiClient {
16
+ /**
17
+ * This endpoint retrieves a specific Promo identified by Promo code.
18
+ * @param code
19
+ * @param config
20
+ */
21
+ static getSpecificPromo(code, config) {
22
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.PromoCode.url({ code }), method: Endpoints.User.method }));
23
+ }
24
+ }
25
+ /**
26
+ *
27
+ :::tip Promo service can be used in the following way:
28
+ ```jsx
29
+ 1. Import the service from our library:
30
+
31
+ import {PromoService} from "@selfcommunity/api-services";
32
+ ```
33
+ ```jsx
34
+ 2. Create a function and put the service inside it!
35
+ The async function `create` will return the paginated list of categories.
36
+
37
+ async getSpecificPromoCode() {
38
+ return await PromoService.getSpecificPromo();
39
+ }
40
+ ```
41
+ ```jsx
42
+ In case of required `params`, just add them inside the brackets.
43
+
44
+ async create(data) {
45
+ return await PromoService.getSpecificPromo(code);
46
+ }
47
+ ```
48
+ ```jsx
49
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
50
+
51
+ 1. Declare it(or declare them, it is possible to add multiple params)
52
+
53
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
54
+
55
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
56
+ ```
57
+ :::
58
+ */
59
+ export default class PromoService {
60
+ static getSpecificPromo(code, config) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ return PromoApiClient.getSpecificPromo(code, config);
63
+ });
64
+ }
65
+ }
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/promo/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAQlD;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAY,EAAE,MAA2B;QAC/D,OAAO,UAAU,iCAAK,MAAM,KAAE,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,EAAC,IAAI,EAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,IAAE,CAAC;IACtG,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,MAAM,CAAO,gBAAgB,CAAC,IAAY,EAAE,MAA2B;;YACrE,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC;KAAA;CACF"}