glitch-javascript-sdk 0.4.7 → 0.4.9
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/dist/cjs/index.js +209 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/TipEmojis.d.ts +53 -0
- package/dist/esm/api/TipPackagePurchases.d.ts +13 -0
- package/dist/esm/api/TipPackages.d.ts +53 -0
- package/dist/esm/api/Tips.d.ts +13 -0
- package/dist/esm/api/index.d.ts +8 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +209 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/TipEmojiRoute.d.ts +7 -0
- package/dist/esm/routes/TipPackagePurchaseRoute.d.ts +7 -0
- package/dist/esm/routes/TipPackagesRoute.d.ts +7 -0
- package/dist/esm/routes/TipRoute.d.ts +7 -0
- package/dist/esm/util/Requests.d.ts +0 -1
- package/dist/index.d.ts +128 -1
- package/package.json +1 -1
- package/src/api/TipEmojis.ts +78 -0
- package/src/api/TipPackagePurchases.ts +22 -0
- package/src/api/TipPackages.ts +78 -0
- package/src/api/Tips.ts +22 -0
- package/src/api/index.ts +9 -2
- package/src/index.ts +9 -0
- package/src/routes/TipEmojiRoute.ts +16 -0
- package/src/routes/TipPackagePurchaseRoute.ts +13 -0
- package/src/routes/TipPackagesRoute.ts +16 -0
- package/src/routes/TipRoute.ts +13 -0
- package/src/util/Requests.ts +2 -11
package/dist/index.d.ts
CHANGED
|
@@ -1668,13 +1668,136 @@ declare class Utility {
|
|
|
1668
1668
|
static listSocialInteractions<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1669
1669
|
}
|
|
1670
1670
|
|
|
1671
|
+
declare class Tips {
|
|
1672
|
+
/**
|
|
1673
|
+
* Give a tip to another user
|
|
1674
|
+
*
|
|
1675
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
1676
|
+
*
|
|
1677
|
+
* @returns A promise
|
|
1678
|
+
*/
|
|
1679
|
+
static give<T>(data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
declare class TipEmojis {
|
|
1683
|
+
/**
|
|
1684
|
+
* Retrieve a list of emojis for tupping.
|
|
1685
|
+
*
|
|
1686
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
1687
|
+
*
|
|
1688
|
+
* @returns promise
|
|
1689
|
+
*/
|
|
1690
|
+
static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1691
|
+
/**
|
|
1692
|
+
* Create a new emoji to use when tipping.
|
|
1693
|
+
*
|
|
1694
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
1695
|
+
*
|
|
1696
|
+
* @param data The data to be passed when creating a post.
|
|
1697
|
+
*
|
|
1698
|
+
* @returns Promise
|
|
1699
|
+
*/
|
|
1700
|
+
static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Update an emoji for tipping.
|
|
1703
|
+
*
|
|
1704
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
1705
|
+
*
|
|
1706
|
+
* @param type_id The id of the post to update.
|
|
1707
|
+
* @param data The data to update.
|
|
1708
|
+
*
|
|
1709
|
+
* @returns promise
|
|
1710
|
+
*/
|
|
1711
|
+
static update<T>(type_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1712
|
+
/**
|
|
1713
|
+
* Retrieve a single emoji resource to be used when tipping.
|
|
1714
|
+
*
|
|
1715
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
1716
|
+
*
|
|
1717
|
+
* @param type_id The id fo the post to retrieve.
|
|
1718
|
+
*
|
|
1719
|
+
* @returns promise
|
|
1720
|
+
*/
|
|
1721
|
+
static view<T>(type_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1722
|
+
/**
|
|
1723
|
+
* Delete an emoji resource.
|
|
1724
|
+
*
|
|
1725
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
1726
|
+
*
|
|
1727
|
+
* @param type_id The id of the post to delete.
|
|
1728
|
+
* @returns promise
|
|
1729
|
+
*/
|
|
1730
|
+
static delete<T>(type_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
declare class TipPackages {
|
|
1734
|
+
/**
|
|
1735
|
+
* Retrieve a list of tip packages.
|
|
1736
|
+
*
|
|
1737
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
1738
|
+
*
|
|
1739
|
+
* @returns promise
|
|
1740
|
+
*/
|
|
1741
|
+
static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1742
|
+
/**
|
|
1743
|
+
* Create a new tip package.
|
|
1744
|
+
*
|
|
1745
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
1746
|
+
*
|
|
1747
|
+
* @param data The data to be passed when creating a post.
|
|
1748
|
+
*
|
|
1749
|
+
* @returns Promise
|
|
1750
|
+
*/
|
|
1751
|
+
static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1752
|
+
/**
|
|
1753
|
+
* Update a tip package.
|
|
1754
|
+
*
|
|
1755
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
1756
|
+
*
|
|
1757
|
+
* @param package_id The id of the post to update.
|
|
1758
|
+
* @param data The data to update.
|
|
1759
|
+
*
|
|
1760
|
+
* @returns promise
|
|
1761
|
+
*/
|
|
1762
|
+
static update<T>(package_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1763
|
+
/**
|
|
1764
|
+
* Retrieve a single tip package resource.
|
|
1765
|
+
*
|
|
1766
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
1767
|
+
*
|
|
1768
|
+
* @param package_id The id fo the post to retrieve.
|
|
1769
|
+
*
|
|
1770
|
+
* @returns promise
|
|
1771
|
+
*/
|
|
1772
|
+
static view<T>(package_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1773
|
+
/**
|
|
1774
|
+
* Delete a tip package.
|
|
1775
|
+
*
|
|
1776
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
1777
|
+
*
|
|
1778
|
+
* @param package_id The id of the post to delete.
|
|
1779
|
+
* @returns promise
|
|
1780
|
+
*/
|
|
1781
|
+
static delete<T>(package_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
declare class TipPackagePurchases {
|
|
1785
|
+
/**
|
|
1786
|
+
* Purchase a package with Stripe as the processor.
|
|
1787
|
+
*
|
|
1788
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
1789
|
+
*
|
|
1790
|
+
* @returns A promise
|
|
1791
|
+
*/
|
|
1792
|
+
static stripe<T>(data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1671
1795
|
interface Route {
|
|
1672
1796
|
url: string;
|
|
1673
1797
|
method: string;
|
|
1674
1798
|
}
|
|
1675
1799
|
|
|
1676
1800
|
declare class Requests {
|
|
1677
|
-
private static axiosInstance;
|
|
1678
1801
|
private static config;
|
|
1679
1802
|
private static baseUrl;
|
|
1680
1803
|
private static authToken;
|
|
@@ -1977,6 +2100,10 @@ declare class Glitch {
|
|
|
1977
2100
|
Templates: typeof Templates;
|
|
1978
2101
|
Waitlists: typeof Waitlists;
|
|
1979
2102
|
Utility: typeof Utility;
|
|
2103
|
+
Tips: typeof Tips;
|
|
2104
|
+
TipPackages: typeof TipPackages;
|
|
2105
|
+
TipEmojis: typeof TipEmojis;
|
|
2106
|
+
TipPackagePurchases: typeof TipPackagePurchases;
|
|
1980
2107
|
};
|
|
1981
2108
|
static util: {
|
|
1982
2109
|
Requests: typeof Requests;
|
package/package.json
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import AuthRoutes from "../routes/AuthRoute";
|
|
2
|
+
import TipEmojiRoute from "../routes/TipEmojiRoute";
|
|
3
|
+
import TipRoute from "../routes/TipRoute";
|
|
4
|
+
import Requests from "../util/Requests";
|
|
5
|
+
import Response from "../util/Response";
|
|
6
|
+
import { AxiosPromise } from "axios";
|
|
7
|
+
|
|
8
|
+
class TipEmojis {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Retrieve a list of emojis for tupping.
|
|
12
|
+
*
|
|
13
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
14
|
+
*
|
|
15
|
+
* @returns promise
|
|
16
|
+
*/
|
|
17
|
+
public static list<T>(params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
18
|
+
return Requests.processRoute(TipEmojiRoute.routes.list, undefined, undefined, params);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create a new emoji to use when tipping.
|
|
23
|
+
*
|
|
24
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
25
|
+
*
|
|
26
|
+
* @param data The data to be passed when creating a post.
|
|
27
|
+
*
|
|
28
|
+
* @returns Promise
|
|
29
|
+
*/
|
|
30
|
+
public static create<T>(data : object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
31
|
+
|
|
32
|
+
return Requests.processRoute(TipEmojiRoute.routes.create, data, undefined, params);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update an emoji for tipping.
|
|
36
|
+
*
|
|
37
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
38
|
+
*
|
|
39
|
+
* @param type_id The id of the post to update.
|
|
40
|
+
* @param data The data to update.
|
|
41
|
+
*
|
|
42
|
+
* @returns promise
|
|
43
|
+
*/
|
|
44
|
+
public static update<T>(type_id : string, data : object, params?: Record<string, any>) : AxiosPromise<Response<T>>{
|
|
45
|
+
|
|
46
|
+
return Requests.processRoute(TipEmojiRoute.routes.update, data, {type_id : type_id}, params);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Retrieve a single emoji resource to be used when tipping.
|
|
51
|
+
*
|
|
52
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
53
|
+
*
|
|
54
|
+
* @param type_id The id fo the post to retrieve.
|
|
55
|
+
*
|
|
56
|
+
* @returns promise
|
|
57
|
+
*/
|
|
58
|
+
public static view<T>(type_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
59
|
+
|
|
60
|
+
return Requests.processRoute(TipEmojiRoute.routes.view, {}, {type_id : type_id}, params);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Delete an emoji resource.
|
|
65
|
+
*
|
|
66
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
67
|
+
*
|
|
68
|
+
* @param type_id The id of the post to delete.
|
|
69
|
+
* @returns promise
|
|
70
|
+
*/
|
|
71
|
+
public static delete<T>(type_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
72
|
+
|
|
73
|
+
return Requests.processRoute(TipEmojiRoute.routes.delete, {}, {type_id : type_id}, params);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default TipEmojis;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import AuthRoutes from "../routes/AuthRoute";
|
|
2
|
+
import TipPackagePurchaseRoute from "../routes/TipPackagePurchaseRoute";
|
|
3
|
+
import Requests from "../util/Requests";
|
|
4
|
+
import Response from "../util/Response";
|
|
5
|
+
import { AxiosPromise } from "axios";
|
|
6
|
+
|
|
7
|
+
class TipPackagePurchases {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Purchase a package with Stripe as the processor.
|
|
11
|
+
*
|
|
12
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
13
|
+
*
|
|
14
|
+
* @returns A promise
|
|
15
|
+
*/
|
|
16
|
+
public static stripe<T>(data? : object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
17
|
+
return Requests.processRoute(TipPackagePurchaseRoute.routes.stripe, data, {}, params);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default TipPackagePurchases;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import AuthRoutes from "../routes/AuthRoute";
|
|
2
|
+
import TipPackagesRoute from "../routes/TipPackagesRoute";
|
|
3
|
+
import TipRoute from "../routes/TipRoute";
|
|
4
|
+
import Requests from "../util/Requests";
|
|
5
|
+
import Response from "../util/Response";
|
|
6
|
+
import { AxiosPromise } from "axios";
|
|
7
|
+
|
|
8
|
+
class TipPackages {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Retrieve a list of tip packages.
|
|
12
|
+
*
|
|
13
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
14
|
+
*
|
|
15
|
+
* @returns promise
|
|
16
|
+
*/
|
|
17
|
+
public static list<T>(params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
18
|
+
return Requests.processRoute(TipPackagesRoute.routes.list, undefined, undefined, params);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create a new tip package.
|
|
23
|
+
*
|
|
24
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
25
|
+
*
|
|
26
|
+
* @param data The data to be passed when creating a post.
|
|
27
|
+
*
|
|
28
|
+
* @returns Promise
|
|
29
|
+
*/
|
|
30
|
+
public static create<T>(data : object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
31
|
+
|
|
32
|
+
return Requests.processRoute(TipPackagesRoute.routes.create, data, undefined, params);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update a tip package.
|
|
36
|
+
*
|
|
37
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
38
|
+
*
|
|
39
|
+
* @param package_id The id of the post to update.
|
|
40
|
+
* @param data The data to update.
|
|
41
|
+
*
|
|
42
|
+
* @returns promise
|
|
43
|
+
*/
|
|
44
|
+
public static update<T>(package_id : string, data : object, params?: Record<string, any>) : AxiosPromise<Response<T>>{
|
|
45
|
+
|
|
46
|
+
return Requests.processRoute(TipPackagesRoute.routes.update, data, {package_id : package_id}, params);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Retrieve a single tip package resource.
|
|
51
|
+
*
|
|
52
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
53
|
+
*
|
|
54
|
+
* @param package_id The id fo the post to retrieve.
|
|
55
|
+
*
|
|
56
|
+
* @returns promise
|
|
57
|
+
*/
|
|
58
|
+
public static view<T>(package_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
59
|
+
|
|
60
|
+
return Requests.processRoute(TipPackagesRoute.routes.view, {}, {package_id : package_id}, params);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Delete a tip package.
|
|
65
|
+
*
|
|
66
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
67
|
+
*
|
|
68
|
+
* @param package_id The id of the post to delete.
|
|
69
|
+
* @returns promise
|
|
70
|
+
*/
|
|
71
|
+
public static delete<T>(package_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
72
|
+
|
|
73
|
+
return Requests.processRoute(TipPackagesRoute.routes.delete, {}, {package_id : package_id}, params);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default TipPackages;
|
package/src/api/Tips.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import AuthRoutes from "../routes/AuthRoute";
|
|
2
|
+
import TipRoute from "../routes/TipRoute";
|
|
3
|
+
import Requests from "../util/Requests";
|
|
4
|
+
import Response from "../util/Response";
|
|
5
|
+
import { AxiosPromise } from "axios";
|
|
6
|
+
|
|
7
|
+
class Tips {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Give a tip to another user
|
|
11
|
+
*
|
|
12
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
13
|
+
*
|
|
14
|
+
* @returns A promise
|
|
15
|
+
*/
|
|
16
|
+
public static give<T>(data? : object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
17
|
+
return Requests.processRoute(TipRoute.routes.give, data, {}, params);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default Tips;
|
package/src/api/index.ts
CHANGED
|
@@ -8,7 +8,10 @@ import Waitlists from "./Waitlist";
|
|
|
8
8
|
import Posts from "./Posts";
|
|
9
9
|
import Templates from "./Templates";
|
|
10
10
|
import Utility from "./Utility";
|
|
11
|
-
|
|
11
|
+
import Tips from "./Tips";
|
|
12
|
+
import TipEmojis from "./TipEmojis";
|
|
13
|
+
import TipPackages from "./TipPackages";
|
|
14
|
+
import TipPackagePurchases from "./TipPackagePurchases";
|
|
12
15
|
|
|
13
16
|
export {Auth};
|
|
14
17
|
export {Competitions};
|
|
@@ -19,4 +22,8 @@ export {Teams};
|
|
|
19
22
|
export {Waitlists};
|
|
20
23
|
export {Posts};
|
|
21
24
|
export {Templates};
|
|
22
|
-
export {Utility};
|
|
25
|
+
export {Utility};
|
|
26
|
+
export {Tips};
|
|
27
|
+
export {TipEmojis};
|
|
28
|
+
export {TipPackages};
|
|
29
|
+
export {TipPackagePurchases}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,11 @@ import { Posts } from "./api";
|
|
|
13
13
|
import {Templates} from "./api";
|
|
14
14
|
import { Waitlists } from "./api";
|
|
15
15
|
import { Utility } from "./api";
|
|
16
|
+
import { Tips } from "./api";
|
|
17
|
+
import { TipPackages } from "./api";
|
|
18
|
+
import { TipEmojis } from "./api";
|
|
19
|
+
import { TipPackagePurchases } from "./api";
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
import Requests from "./util/Requests";
|
|
18
23
|
import Parser from "./util/Parser";
|
|
@@ -52,6 +57,10 @@ class Glitch {
|
|
|
52
57
|
Templates : Templates,
|
|
53
58
|
Waitlists: Waitlists,
|
|
54
59
|
Utility : Utility,
|
|
60
|
+
Tips: Tips,
|
|
61
|
+
TipPackages : TipPackages,
|
|
62
|
+
TipEmojis : TipEmojis ,
|
|
63
|
+
TipPackagePurchases: TipPackagePurchases
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
public static util = {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class TipEmojiRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/tipstypes', method: HTTP_METHODS.GET },
|
|
8
|
+
create: { url: '/tipstypes', method: HTTP_METHODS.POST },
|
|
9
|
+
view: { url: '/tipstypes/{type_id}', method: HTTP_METHODS.GET },
|
|
10
|
+
update: { url: '/tipstypes/{type_id}', method: HTTP_METHODS.PUT },
|
|
11
|
+
DELETE: { url: '/tipstypes/{type_id}', method: HTTP_METHODS.DELETE },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TipEmojiRoute;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class TipPackagePurchaseRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
stripe: { url: '/tipspackagepurchases/stripe', method: HTTP_METHODS.POST },
|
|
8
|
+
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default TipPackagePurchaseRoute;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class TipPackagesRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/tipspackages', method: HTTP_METHODS.GET },
|
|
8
|
+
create: { url: '/tipspackages', method: HTTP_METHODS.POST },
|
|
9
|
+
view: { url: '/tipspackages/{package_id}', method: HTTP_METHODS.GET },
|
|
10
|
+
update: { url: '/tipspackages/{package_id}', method: HTTP_METHODS.PUT },
|
|
11
|
+
DELETE: { url: '/tipspackages/{package_id}', method: HTTP_METHODS.DELETE },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TipPackagesRoute;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class TipRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
give: { url: '/tips/give', method: HTTP_METHODS.POST },
|
|
8
|
+
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default TipRoute;
|
package/src/util/Requests.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import axios, {
|
|
1
|
+
import axios, { AxiosPromise } from 'axios';
|
|
2
2
|
import Config from '../config/Config';
|
|
3
3
|
import HTTP_METHODS from '../constants/HttpMethods';
|
|
4
4
|
import Route from '../routes/interface';
|
|
5
5
|
import Response from './Response';
|
|
6
6
|
|
|
7
7
|
class Requests {
|
|
8
|
-
private static axiosInstance: AxiosInstance;
|
|
9
8
|
private static config: Config;
|
|
10
9
|
private static baseUrl = "";
|
|
11
10
|
private static authToken = "";
|
|
@@ -13,18 +12,10 @@ class Requests {
|
|
|
13
12
|
|
|
14
13
|
constructor(config: Config) {
|
|
15
14
|
Requests.config = config;
|
|
16
|
-
Requests.axiosInstance = axios.create({
|
|
17
|
-
baseURL: Requests.baseUrl,
|
|
18
|
-
headers: { 'Content-Type': 'application/json' },
|
|
19
|
-
});
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
public static setBaseUrl(url: string) {
|
|
23
18
|
Requests.baseUrl = url;
|
|
24
|
-
|
|
25
|
-
if(Requests.axiosInstance && Requests.axiosInstance.defaults) {
|
|
26
|
-
Requests.axiosInstance.defaults.baseURL = url;
|
|
27
|
-
}
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
public static setAuthToken(token: string) {
|
|
@@ -59,7 +50,7 @@ class Requests {
|
|
|
59
50
|
|
|
60
51
|
const validUri = uri.replace(/\/\//g, '/');
|
|
61
52
|
|
|
62
|
-
const axiosPromise =
|
|
53
|
+
const axiosPromise = axios({
|
|
63
54
|
method,
|
|
64
55
|
url: uri,
|
|
65
56
|
data: fileData || data,
|