glitch-javascript-sdk 0.8.2 → 0.8.4
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 +108 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Campaigns.d.ts +49 -0
- package/dist/esm/index.js +108 -35
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +49 -0
- package/package.json +1 -1
- package/src/api/Campaigns.ts +69 -0
- package/src/routes/CampaignsRoute.ts +6 -1
- package/src/util/Requests.ts +1 -1
|
@@ -155,5 +155,54 @@ declare class Campaigns {
|
|
|
155
155
|
* @returns promise
|
|
156
156
|
*/
|
|
157
157
|
static listInfluencerCampaignLinks<T>(campaign_id: string, user_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
158
|
+
/**
|
|
159
|
+
* List all the campaign mentions.
|
|
160
|
+
*
|
|
161
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLinks
|
|
162
|
+
*
|
|
163
|
+
* @returns promise
|
|
164
|
+
*/
|
|
165
|
+
static listCampaignMentions<T>(campaign_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
166
|
+
/**
|
|
167
|
+
* Create a new campaign mention.
|
|
168
|
+
*
|
|
169
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/storeCampaignLink
|
|
170
|
+
*
|
|
171
|
+
* @param data The data to be passed when creating a campaign.
|
|
172
|
+
*
|
|
173
|
+
* @returns Promise
|
|
174
|
+
*/
|
|
175
|
+
static createCampaignMention<T>(campaign_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
176
|
+
/**
|
|
177
|
+
* Update a campaign mention.
|
|
178
|
+
*
|
|
179
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/1bb1492981b4529693604b03aade8bf6
|
|
180
|
+
*
|
|
181
|
+
* @param campaign_id The id of the campaign to update.
|
|
182
|
+
* @param data The data to update.
|
|
183
|
+
*
|
|
184
|
+
* @returns promise
|
|
185
|
+
*/
|
|
186
|
+
static updateCampaignMention<T>(campaign_id: string, mention_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
187
|
+
/**
|
|
188
|
+
* Retrieve the information for a single campaign mention.
|
|
189
|
+
*
|
|
190
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLink
|
|
191
|
+
*
|
|
192
|
+
* @param campaign_id The id fo the campaign to retrieve.
|
|
193
|
+
*
|
|
194
|
+
* @returns promise
|
|
195
|
+
*/
|
|
196
|
+
static getCampaignMention<T>(campaign_id: string, mention_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
197
|
+
/**
|
|
198
|
+
* Delete the information for a single campaign mention.
|
|
199
|
+
*
|
|
200
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLink
|
|
201
|
+
*
|
|
202
|
+
* @param campaign_id The id fo the campaign to retrieve.
|
|
203
|
+
*
|
|
204
|
+
* @returns promise
|
|
205
|
+
*/
|
|
206
|
+
static deleteCampaignMention<T>(campaign_id: string, mention_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
158
207
|
}
|
|
159
208
|
export default Campaigns;
|
package/dist/esm/index.js
CHANGED
|
@@ -5453,7 +5453,7 @@ var Requests = /** @class */ (function () {
|
|
|
5453
5453
|
// Method adapted for browser environments
|
|
5454
5454
|
Requests.uploadFileInChunks = function (file, uploadUrl, onProgress, data, chunkSize) {
|
|
5455
5455
|
return __awaiter(this, void 0, void 0, function () {
|
|
5456
|
-
var fileSize, totalChunks, currentChunkIndex,
|
|
5456
|
+
var fileSize, totalChunks, currentChunkIndex, array, identifier, _loop_1;
|
|
5457
5457
|
return __generator(this, function (_a) {
|
|
5458
5458
|
switch (_a.label) {
|
|
5459
5459
|
case 0:
|
|
@@ -5463,48 +5463,57 @@ var Requests = /** @class */ (function () {
|
|
|
5463
5463
|
fileSize = file.size;
|
|
5464
5464
|
totalChunks = Math.ceil(fileSize / chunkSize);
|
|
5465
5465
|
currentChunkIndex = 0;
|
|
5466
|
-
totalUploaded = 0;
|
|
5467
5466
|
array = new Uint32Array(4);
|
|
5468
5467
|
window.crypto.getRandomValues(array);
|
|
5469
5468
|
identifier = Array.from(array, function (dec) { return ('0' + dec.toString(16)).substr(-2); }).join('');
|
|
5469
|
+
_loop_1 = function () {
|
|
5470
|
+
var start, end, chunk, formData, key, fullUploadUrl, headers;
|
|
5471
|
+
return __generator(this, function (_b) {
|
|
5472
|
+
switch (_b.label) {
|
|
5473
|
+
case 0:
|
|
5474
|
+
start = currentChunkIndex * chunkSize;
|
|
5475
|
+
end = Math.min(start + chunkSize, fileSize);
|
|
5476
|
+
chunk = file.slice(start, end);
|
|
5477
|
+
formData = new FormData();
|
|
5478
|
+
formData.append('video', chunk, file.name);
|
|
5479
|
+
formData.append('chunkIndex', currentChunkIndex.toString());
|
|
5480
|
+
formData.append('totalChunks', totalChunks.toString());
|
|
5481
|
+
formData.append('identifier', identifier);
|
|
5482
|
+
// If there's additional data, append each key-value pair to the formData
|
|
5483
|
+
if (data) {
|
|
5484
|
+
for (key in data) {
|
|
5485
|
+
formData.append(key, data[key]);
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
fullUploadUrl = "".concat(Requests.baseUrl).concat(uploadUrl);
|
|
5489
|
+
headers = {};
|
|
5490
|
+
if (Requests.authToken) {
|
|
5491
|
+
headers['Authorization'] = "Bearer ".concat(Requests.authToken);
|
|
5492
|
+
}
|
|
5493
|
+
// Perform the upload
|
|
5494
|
+
return [4 /*yield*/, axios$1.post(fullUploadUrl, formData, {
|
|
5495
|
+
headers: headers,
|
|
5496
|
+
onUploadProgress: function (progressEvent) {
|
|
5497
|
+
progressEvent.loaded; // Bytes uploaded of the current chunk
|
|
5498
|
+
if (onProgress) {
|
|
5499
|
+
onProgress(fileSize, end);
|
|
5500
|
+
}
|
|
5501
|
+
}
|
|
5502
|
+
})];
|
|
5503
|
+
case 1:
|
|
5504
|
+
// Perform the upload
|
|
5505
|
+
_b.sent();
|
|
5506
|
+
currentChunkIndex++;
|
|
5507
|
+
return [2 /*return*/];
|
|
5508
|
+
}
|
|
5509
|
+
});
|
|
5510
|
+
};
|
|
5470
5511
|
_a.label = 1;
|
|
5471
5512
|
case 1:
|
|
5472
5513
|
if (!(currentChunkIndex <= totalChunks)) return [3 /*break*/, 3];
|
|
5473
|
-
|
|
5474
|
-
end = Math.min(start + chunkSize, fileSize);
|
|
5475
|
-
chunk = file.slice(start, end);
|
|
5476
|
-
formData = new FormData();
|
|
5477
|
-
formData.append('video', chunk, file.name);
|
|
5478
|
-
formData.append('chunkIndex', currentChunkIndex.toString());
|
|
5479
|
-
formData.append('totalChunks', totalChunks.toString());
|
|
5480
|
-
formData.append('identifier', identifier);
|
|
5481
|
-
// If there's additional data, append each key-value pair to the formData
|
|
5482
|
-
if (data) {
|
|
5483
|
-
for (key in data) {
|
|
5484
|
-
formData.append(key, data[key]);
|
|
5485
|
-
}
|
|
5486
|
-
}
|
|
5487
|
-
fullUploadUrl = "".concat(Requests.baseUrl).concat(uploadUrl);
|
|
5488
|
-
headers = {};
|
|
5489
|
-
if (Requests.authToken) {
|
|
5490
|
-
headers['Authorization'] = "Bearer ".concat(Requests.authToken);
|
|
5491
|
-
}
|
|
5492
|
-
// Perform the upload
|
|
5493
|
-
return [4 /*yield*/, axios$1.post(fullUploadUrl, formData, {
|
|
5494
|
-
headers: headers,
|
|
5495
|
-
onUploadProgress: function (progressEvent) {
|
|
5496
|
-
var currentChunkProgress = progressEvent.loaded; // Bytes uploaded of the current chunk
|
|
5497
|
-
// Calculate the total uploaded size including previous chunks and the current chunk's progress
|
|
5498
|
-
var totalProgress = totalUploaded + currentChunkProgress;
|
|
5499
|
-
if (onProgress) {
|
|
5500
|
-
onProgress(fileSize, totalProgress);
|
|
5501
|
-
}
|
|
5502
|
-
}
|
|
5503
|
-
})];
|
|
5514
|
+
return [5 /*yield**/, _loop_1()];
|
|
5504
5515
|
case 2:
|
|
5505
|
-
// Perform the upload
|
|
5506
5516
|
_a.sent();
|
|
5507
|
-
currentChunkIndex++;
|
|
5508
5517
|
return [3 /*break*/, 1];
|
|
5509
5518
|
case 3: return [2 /*return*/];
|
|
5510
5519
|
}
|
|
@@ -8853,6 +8862,11 @@ var CampaignsRoute = /** @class */ (function () {
|
|
|
8853
8862
|
markInfluencerCampaignComplete: { url: '/campaigns/{campaign_id}/influencers/{user_id}/setComplete', method: HTTP_METHODS.POST },
|
|
8854
8863
|
markInfluencerCampaignIncomplete: { url: '/campaigns/{campaign_id}/influencers/{user_id}/setIncomplete', method: HTTP_METHODS.POST },
|
|
8855
8864
|
listInfluencerCampaignLinks: { url: '/campaigns/{campaign_id}/influencers/{user_id}/links', method: HTTP_METHODS.GET },
|
|
8865
|
+
listCampaignMentions: { url: '/campaigns/{campaign_id}/mentions', method: HTTP_METHODS.GET },
|
|
8866
|
+
createCampaignMention: { url: '/campaigns/{campaign_id}/mentions', method: HTTP_METHODS.POST },
|
|
8867
|
+
getCampaignMention: { url: '/campaigns/{campaign_id}/mentions/{mention_id}', method: HTTP_METHODS.GET },
|
|
8868
|
+
updateCampaignMention: { url: '/campaigns/{campaign_id}/mentions/{mention_id}', method: HTTP_METHODS.PUT },
|
|
8869
|
+
deleteCampaignMention: { url: '/campaigns/{campaign_id}/mentions/{mention_id}', method: HTTP_METHODS.PUT },
|
|
8856
8870
|
};
|
|
8857
8871
|
return CampaignsRoute;
|
|
8858
8872
|
}());
|
|
@@ -9046,6 +9060,65 @@ var Campaigns = /** @class */ (function () {
|
|
|
9046
9060
|
Campaigns.listInfluencerCampaignLinks = function (campaign_id, user_id, params) {
|
|
9047
9061
|
return Requests.processRoute(CampaignsRoute.routes.listInfluencerCampaignLinks, undefined, { campaign_id: campaign_id, user_id: user_id }, params);
|
|
9048
9062
|
};
|
|
9063
|
+
/**
|
|
9064
|
+
* List all the campaign mentions.
|
|
9065
|
+
*
|
|
9066
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLinks
|
|
9067
|
+
*
|
|
9068
|
+
* @returns promise
|
|
9069
|
+
*/
|
|
9070
|
+
Campaigns.listCampaignMentions = function (campaign_id, params) {
|
|
9071
|
+
return Requests.processRoute(CampaignsRoute.routes.listCampaignMentions, undefined, { campaign_id: campaign_id }, params);
|
|
9072
|
+
};
|
|
9073
|
+
/**
|
|
9074
|
+
* Create a new campaign mention.
|
|
9075
|
+
*
|
|
9076
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/storeCampaignLink
|
|
9077
|
+
*
|
|
9078
|
+
* @param data The data to be passed when creating a campaign.
|
|
9079
|
+
*
|
|
9080
|
+
* @returns Promise
|
|
9081
|
+
*/
|
|
9082
|
+
Campaigns.createCampaignMention = function (campaign_id, data, params) {
|
|
9083
|
+
return Requests.processRoute(CampaignsRoute.routes.createCampaignMention, data, { campaign_id: campaign_id }, params);
|
|
9084
|
+
};
|
|
9085
|
+
/**
|
|
9086
|
+
* Update a campaign mention.
|
|
9087
|
+
*
|
|
9088
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/1bb1492981b4529693604b03aade8bf6
|
|
9089
|
+
*
|
|
9090
|
+
* @param campaign_id The id of the campaign to update.
|
|
9091
|
+
* @param data The data to update.
|
|
9092
|
+
*
|
|
9093
|
+
* @returns promise
|
|
9094
|
+
*/
|
|
9095
|
+
Campaigns.updateCampaignMention = function (campaign_id, mention_id, data, params) {
|
|
9096
|
+
return Requests.processRoute(CampaignsRoute.routes.updateCampaignMention, data, { campaign_id: campaign_id, mention_id: mention_id }, params);
|
|
9097
|
+
};
|
|
9098
|
+
/**
|
|
9099
|
+
* Retrieve the information for a single campaign mention.
|
|
9100
|
+
*
|
|
9101
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLink
|
|
9102
|
+
*
|
|
9103
|
+
* @param campaign_id The id fo the campaign to retrieve.
|
|
9104
|
+
*
|
|
9105
|
+
* @returns promise
|
|
9106
|
+
*/
|
|
9107
|
+
Campaigns.getCampaignMention = function (campaign_id, mention_id, params) {
|
|
9108
|
+
return Requests.processRoute(CampaignsRoute.routes.getCampaignMention, {}, { campaign_id: campaign_id, mention_id: mention_id }, params);
|
|
9109
|
+
};
|
|
9110
|
+
/**
|
|
9111
|
+
* Delete the information for a single campaign mention.
|
|
9112
|
+
*
|
|
9113
|
+
* @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLink
|
|
9114
|
+
*
|
|
9115
|
+
* @param campaign_id The id fo the campaign to retrieve.
|
|
9116
|
+
*
|
|
9117
|
+
* @returns promise
|
|
9118
|
+
*/
|
|
9119
|
+
Campaigns.deleteCampaignMention = function (campaign_id, mention_id, params) {
|
|
9120
|
+
return Requests.processRoute(CampaignsRoute.routes.deleteCampaignMention, {}, { campaign_id: campaign_id, mention_id: mention_id }, params);
|
|
9121
|
+
};
|
|
9049
9122
|
return Campaigns;
|
|
9050
9123
|
}());
|
|
9051
9124
|
|