glitch-javascript-sdk 2.0.0 → 2.0.1

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,7 @@
1
+ import Route from "./interface";
2
+ declare class MarketingAgenciesRoute {
3
+ static routes: {
4
+ [key: string]: Route;
5
+ };
6
+ }
7
+ export default MarketingAgenciesRoute;
package/dist/index.d.ts CHANGED
@@ -5688,6 +5688,178 @@ declare class AIUsage {
5688
5688
  static summary<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5689
5689
  }
5690
5690
 
5691
+ declare class MarketingAgencies {
5692
+ /**
5693
+ * List all marketing agencies.
5694
+ *
5695
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies
5696
+ *
5697
+ * @param params Optional query parameters (e.g., is_admin, sort_by, sort_order, page, per_page).
5698
+ * @returns promise
5699
+ */
5700
+ static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5701
+ /**
5702
+ * Create a new marketing agency.
5703
+ *
5704
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies
5705
+ *
5706
+ * @param data The data for the new agency.
5707
+ * @returns Promise
5708
+ */
5709
+ static create<T>(data: object): AxiosPromise<Response<T>>;
5710
+ /**
5711
+ * Retrieve a single marketing agency by its ID.
5712
+ *
5713
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies-id
5714
+ *
5715
+ * @param id The UUID of the agency to retrieve.
5716
+ * @returns promise
5717
+ */
5718
+ static view<T>(id: string): AxiosPromise<Response<T>>;
5719
+ /**
5720
+ * Update a marketing agency.
5721
+ *
5722
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/putMarketing-agencies-id
5723
+ *
5724
+ * @param id The UUID of the agency to update.
5725
+ * @param data The data to update.
5726
+ * @returns promise
5727
+ */
5728
+ static update<T>(id: string, data: object): AxiosPromise<Response<T>>;
5729
+ /**
5730
+ * Deletes a marketing agency.
5731
+ *
5732
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id
5733
+ *
5734
+ * @param id The UUID of the agency to delete.
5735
+ * @returns promise
5736
+ */
5737
+ static delete<T>(id: string): AxiosPromise<Response<T>>;
5738
+ /**
5739
+ * Add a user as an administrator to an agency.
5740
+ *
5741
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-administrators
5742
+ *
5743
+ * @param id The UUID of the agency.
5744
+ * @param data The data containing the user_id to add.
5745
+ * @returns Promise
5746
+ */
5747
+ static addAdministrator<T>(id: string, data: {
5748
+ user_id: string;
5749
+ }): AxiosPromise<Response<T>>;
5750
+ /**
5751
+ * Remove a user as an administrator from an agency.
5752
+ *
5753
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id-administrators-user_id
5754
+ *
5755
+ * @param id The UUID of the agency.
5756
+ * @param user_id The UUID of the user to remove.
5757
+ * @returns Promise
5758
+ */
5759
+ static removeAdministrator<T>(id: string, user_id: string): AxiosPromise<Response<T>>;
5760
+ /**
5761
+ * Set the logo for an agency.
5762
+ *
5763
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-logo
5764
+ *
5765
+ * @param id The UUID of the agency.
5766
+ * @param data The data containing the media_id for the logo.
5767
+ * @returns Promise
5768
+ */
5769
+ static setLogo<T>(id: string, data: {
5770
+ media_id: string;
5771
+ }): AxiosPromise<Response<T>>;
5772
+ /**
5773
+ * Add a case study to an agency.
5774
+ *
5775
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-case-studies
5776
+ *
5777
+ * @param id The UUID of the agency.
5778
+ * @param data The data containing the media_id and optional order.
5779
+ * @returns Promise
5780
+ */
5781
+ static addCaseStudy<T>(id: string, data: {
5782
+ media_id: string;
5783
+ order?: number;
5784
+ }): AxiosPromise<Response<T>>;
5785
+ /**
5786
+ * Remove a case study from an agency.
5787
+ *
5788
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id-case-studies-media_id
5789
+ *
5790
+ * @param id The UUID of the agency.
5791
+ * @param media_id The UUID of the media to remove.
5792
+ * @returns Promise
5793
+ */
5794
+ static removeCaseStudy<T>(id: string, media_id: string): AxiosPromise<Response<T>>;
5795
+ /**
5796
+ * Update the order of case studies for an agency.
5797
+ *
5798
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-case-studies-order
5799
+ *
5800
+ * @param id The UUID of the agency.
5801
+ * @param order_data An array of objects with media_id and new order.
5802
+ * @returns Promise
5803
+ */
5804
+ static updateCaseStudyOrder<T>(id: string, order_data: {
5805
+ media_id: string;
5806
+ order: number;
5807
+ }[]): AxiosPromise<Response<T>>;
5808
+ /**
5809
+ * Invite a user to become an administrator of an agency.
5810
+ *
5811
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-invites
5812
+ *
5813
+ * @param id The UUID of the agency.
5814
+ * @param data The data containing the email of the user to invite.
5815
+ * @returns Promise
5816
+ */
5817
+ static invite<T>(id: string, data: {
5818
+ email: string;
5819
+ }): AxiosPromise<Response<T>>;
5820
+ /**
5821
+ * List all pending invitations for an agency.
5822
+ *
5823
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies-id-invites
5824
+ *
5825
+ * @param id The UUID of the agency.
5826
+ * @returns Promise
5827
+ */
5828
+ static listInvites<T>(id: string): AxiosPromise<Response<T>>;
5829
+ /**
5830
+ * Revoke a pending invitation.
5831
+ *
5832
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id-invites-invite_id
5833
+ *
5834
+ * @param id The UUID of the agency.
5835
+ * @param invite_id The UUID of the invitation to revoke.
5836
+ * @returns Promise
5837
+ */
5838
+ static revokeInvite<T>(id: string, invite_id: string): AxiosPromise<Response<T>>;
5839
+ /**
5840
+ * Get the details of a pending invitation using its token.
5841
+ *
5842
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies-invites-details
5843
+ *
5844
+ * @param params An object containing the token.
5845
+ * @returns Promise
5846
+ */
5847
+ static getInviteDetails<T>(params: {
5848
+ token: string;
5849
+ }): AxiosPromise<Response<T>>;
5850
+ /**
5851
+ * Accept an invitation to become an administrator.
5852
+ *
5853
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-invites-accept
5854
+ *
5855
+ * @param data The data containing the invitation token.
5856
+ * @returns Promise
5857
+ */
5858
+ static acceptInvite<T>(data: {
5859
+ token: string;
5860
+ }): AxiosPromise<Response<T>>;
5861
+ }
5862
+
5691
5863
  interface Route {
5692
5864
  url: string;
5693
5865
  method: string;
@@ -6032,6 +6204,7 @@ declare class Glitch {
6032
6204
  Fingerprinting: typeof Fingerprinting;
6033
6205
  ShortLinks: typeof ShortLinks;
6034
6206
  AIUsage: typeof AIUsage;
6207
+ MarketingAgencies: typeof MarketingAgencies;
6035
6208
  };
6036
6209
  static util: {
6037
6210
  Requests: typeof Requests;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,210 @@
1
+ import MarketingAgenciesRoute from "../routes/MarketingAgenciesRoute";
2
+ import Requests from "../util/Requests";
3
+ import Response from "../util/Response";
4
+ import { AxiosPromise } from "axios";
5
+
6
+ class MarketingAgencies {
7
+
8
+ /**
9
+ * List all marketing agencies.
10
+ *
11
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies
12
+ *
13
+ * @param params Optional query parameters (e.g., is_admin, sort_by, sort_order, page, per_page).
14
+ * @returns promise
15
+ */
16
+ public static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
17
+ return Requests.processRoute(MarketingAgenciesRoute.routes.list, undefined, undefined, params);
18
+ }
19
+
20
+ /**
21
+ * Create a new marketing agency.
22
+ *
23
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies
24
+ *
25
+ * @param data The data for the new agency.
26
+ * @returns Promise
27
+ */
28
+ public static create<T>(data: object): AxiosPromise<Response<T>> {
29
+ return Requests.processRoute(MarketingAgenciesRoute.routes.create, data);
30
+ }
31
+
32
+ /**
33
+ * Retrieve a single marketing agency by its ID.
34
+ *
35
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies-id
36
+ *
37
+ * @param id The UUID of the agency to retrieve.
38
+ * @returns promise
39
+ */
40
+ public static view<T>(id: string): AxiosPromise<Response<T>> {
41
+ return Requests.processRoute(MarketingAgenciesRoute.routes.view, {}, { id });
42
+ }
43
+
44
+ /**
45
+ * Update a marketing agency.
46
+ *
47
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/putMarketing-agencies-id
48
+ *
49
+ * @param id The UUID of the agency to update.
50
+ * @param data The data to update.
51
+ * @returns promise
52
+ */
53
+ public static update<T>(id: string, data: object): AxiosPromise<Response<T>> {
54
+ return Requests.processRoute(MarketingAgenciesRoute.routes.update, data, { id });
55
+ }
56
+
57
+ /**
58
+ * Deletes a marketing agency.
59
+ *
60
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id
61
+ *
62
+ * @param id The UUID of the agency to delete.
63
+ * @returns promise
64
+ */
65
+ public static delete<T>(id: string): AxiosPromise<Response<T>> {
66
+ return Requests.processRoute(MarketingAgenciesRoute.routes.delete, {}, { id });
67
+ }
68
+
69
+ /**
70
+ * Add a user as an administrator to an agency.
71
+ *
72
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-administrators
73
+ *
74
+ * @param id The UUID of the agency.
75
+ * @param data The data containing the user_id to add.
76
+ * @returns Promise
77
+ */
78
+ public static addAdministrator<T>(id: string, data: { user_id: string }): AxiosPromise<Response<T>> {
79
+ return Requests.processRoute(MarketingAgenciesRoute.routes.addAdministrator, data, { id });
80
+ }
81
+
82
+ /**
83
+ * Remove a user as an administrator from an agency.
84
+ *
85
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id-administrators-user_id
86
+ *
87
+ * @param id The UUID of the agency.
88
+ * @param user_id The UUID of the user to remove.
89
+ * @returns Promise
90
+ */
91
+ public static removeAdministrator<T>(id: string, user_id: string): AxiosPromise<Response<T>> {
92
+ return Requests.processRoute(MarketingAgenciesRoute.routes.removeAdministrator, {}, { id, user_id });
93
+ }
94
+
95
+ /**
96
+ * Set the logo for an agency.
97
+ *
98
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-logo
99
+ *
100
+ * @param id The UUID of the agency.
101
+ * @param data The data containing the media_id for the logo.
102
+ * @returns Promise
103
+ */
104
+ public static setLogo<T>(id: string, data: { media_id: string }): AxiosPromise<Response<T>> {
105
+ return Requests.processRoute(MarketingAgenciesRoute.routes.setLogo, data, { id });
106
+ }
107
+
108
+ /**
109
+ * Add a case study to an agency.
110
+ *
111
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-case-studies
112
+ *
113
+ * @param id The UUID of the agency.
114
+ * @param data The data containing the media_id and optional order.
115
+ * @returns Promise
116
+ */
117
+ public static addCaseStudy<T>(id: string, data: { media_id: string, order?: number }): AxiosPromise<Response<T>> {
118
+ return Requests.processRoute(MarketingAgenciesRoute.routes.addCaseStudy, data, { id });
119
+ }
120
+
121
+ /**
122
+ * Remove a case study from an agency.
123
+ *
124
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id-case-studies-media_id
125
+ *
126
+ * @param id The UUID of the agency.
127
+ * @param media_id The UUID of the media to remove.
128
+ * @returns Promise
129
+ */
130
+ public static removeCaseStudy<T>(id: string, media_id: string): AxiosPromise<Response<T>> {
131
+ return Requests.processRoute(MarketingAgenciesRoute.routes.removeCaseStudy, {}, { id, media_id });
132
+ }
133
+
134
+ /**
135
+ * Update the order of case studies for an agency.
136
+ *
137
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-case-studies-order
138
+ *
139
+ * @param id The UUID of the agency.
140
+ * @param order_data An array of objects with media_id and new order.
141
+ * @returns Promise
142
+ */
143
+ public static updateCaseStudyOrder<T>(id: string, order_data: { media_id: string, order: number }[]): AxiosPromise<Response<T>> {
144
+ return Requests.processRoute(MarketingAgenciesRoute.routes.updateCaseStudyOrder, { order_data }, { id });
145
+ }
146
+
147
+ /**
148
+ * Invite a user to become an administrator of an agency.
149
+ *
150
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-id-invites
151
+ *
152
+ * @param id The UUID of the agency.
153
+ * @param data The data containing the email of the user to invite.
154
+ * @returns Promise
155
+ */
156
+ public static invite<T>(id: string, data: { email: string }): AxiosPromise<Response<T>> {
157
+ return Requests.processRoute(MarketingAgenciesRoute.routes.invite, data, { id });
158
+ }
159
+
160
+ /**
161
+ * List all pending invitations for an agency.
162
+ *
163
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies-id-invites
164
+ *
165
+ * @param id The UUID of the agency.
166
+ * @returns Promise
167
+ */
168
+ public static listInvites<T>(id: string): AxiosPromise<Response<T>> {
169
+ return Requests.processRoute(MarketingAgenciesRoute.routes.listInvites, {}, { id });
170
+ }
171
+
172
+ /**
173
+ * Revoke a pending invitation.
174
+ *
175
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/deleteMarketing-agencies-id-invites-invite_id
176
+ *
177
+ * @param id The UUID of the agency.
178
+ * @param invite_id The UUID of the invitation to revoke.
179
+ * @returns Promise
180
+ */
181
+ public static revokeInvite<T>(id: string, invite_id: string): AxiosPromise<Response<T>> {
182
+ return Requests.processRoute(MarketingAgenciesRoute.routes.revokeInvite, {}, { id, invite_id });
183
+ }
184
+
185
+ /**
186
+ * Get the details of a pending invitation using its token.
187
+ *
188
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/getMarketing-agencies-invites-details
189
+ *
190
+ * @param params An object containing the token.
191
+ * @returns Promise
192
+ */
193
+ public static getInviteDetails<T>(params: { token: string }): AxiosPromise<Response<T>> {
194
+ return Requests.processRoute(MarketingAgenciesRoute.routes.getInviteDetails, undefined, undefined, params);
195
+ }
196
+
197
+ /**
198
+ * Accept an invitation to become an administrator.
199
+ *
200
+ * @see https://api.glitch.fun/api/documentation#/Marketing%20Agencies/postMarketing-agencies-invites-accept
201
+ *
202
+ * @param data The data containing the invitation token.
203
+ * @returns Promise
204
+ */
205
+ public static acceptInvite<T>(data: { token: string }): AxiosPromise<Response<T>> {
206
+ return Requests.processRoute(MarketingAgenciesRoute.routes.acceptInvite, data);
207
+ }
208
+ }
209
+
210
+ export default MarketingAgencies;
package/src/api/index.ts CHANGED
@@ -35,6 +35,7 @@ import Hashtags from "./Hashtags";
35
35
  import WebsiteAnalytics from "./WebsiteAnalytics";
36
36
  import ShortLinks from "./ShortLinks";
37
37
  import AIUsage from "./AIUsage";
38
+ import MarketingAgencies from "./MarketingAgencies";
38
39
 
39
40
  export {Ads};
40
41
  export {Auth};
@@ -72,4 +73,5 @@ export {Hashtags};
72
73
  export {WebsiteAnalytics};
73
74
  export {Fingerprinting};
74
75
  export {ShortLinks};
75
- export {AIUsage};
76
+ export {AIUsage};
77
+ export {MarketingAgencies};
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ import {WebsiteAnalytics} from "./api";
39
39
  import {Fingerprinting} from "./api";
40
40
  import {ShortLinks} from "./api";
41
41
  import {AIUsage} from "./api";
42
+ import {MarketingAgencies} from "./api"
42
43
 
43
44
  import Requests from "./util/Requests";
44
45
  import Parser from "./util/Parser";
@@ -106,7 +107,8 @@ class Glitch {
106
107
  WebsiteAnalytics: WebsiteAnalytics,
107
108
  Fingerprinting : Fingerprinting,
108
109
  ShortLinks : ShortLinks,
109
- AIUsage : AIUsage
110
+ AIUsage : AIUsage,
111
+ MarketingAgencies : MarketingAgencies
110
112
  }
111
113
 
112
114
  public static util = {
@@ -0,0 +1,36 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ class MarketingAgenciesRoute {
5
+
6
+ public static routes: { [key: string]: Route } = {
7
+ // CRUD for agencies
8
+ list: { url: '/marketing-agencies', method: HTTP_METHODS.GET },
9
+ create: { url: '/marketing-agencies', method: HTTP_METHODS.POST },
10
+ view: { url: '/marketing-agencies/{id}', method: HTTP_METHODS.GET },
11
+ update: { url: '/marketing-agencies/{id}', method: HTTP_METHODS.PUT },
12
+ delete: { url: '/marketing-agencies/{id}', method: HTTP_METHODS.DELETE },
13
+
14
+ // Administrator management
15
+ addAdministrator: { url: '/marketing-agencies/{id}/administrators', method: HTTP_METHODS.POST },
16
+ removeAdministrator: { url: '/marketing-agencies/{id}/administrators/{user_id}', method: HTTP_METHODS.DELETE },
17
+
18
+ // Logo management
19
+ setLogo: { url: '/marketing-agencies/{id}/logo', method: HTTP_METHODS.POST },
20
+
21
+ // Case Study management
22
+ addCaseStudy: { url: '/marketing-agencies/{id}/case-studies', method: HTTP_METHODS.POST },
23
+ removeCaseStudy: { url: '/marketing-agencies/{id}/case-studies/{media_id}', method: HTTP_METHODS.DELETE },
24
+ updateCaseStudyOrder: { url: '/marketing-agencies/{id}/case-studies/order', method: HTTP_METHODS.POST },
25
+
26
+ // Invitation management
27
+ invite: { url: '/marketing-agencies/{id}/invites', method: HTTP_METHODS.POST },
28
+ listInvites: { url: '/marketing-agencies/{id}/invites', method: HTTP_METHODS.GET },
29
+ revokeInvite: { url: '/marketing-agencies/{id}/invites/{invite_id}', method: HTTP_METHODS.DELETE },
30
+ getInviteDetails: { url: '/marketing-agencies/invites/details', method: HTTP_METHODS.GET },
31
+ acceptInvite: { url: '/marketing-agencies/invites/accept', method: HTTP_METHODS.POST },
32
+ };
33
+
34
+ }
35
+
36
+ export default MarketingAgenciesRoute;