@dawntech/blip-tools 0.3.1 → 0.5.0

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.
Files changed (40) hide show
  1. package/dist/exceptions/index.d.ts +5 -0
  2. package/dist/helpers/validate-instance.d.ts +1 -1
  3. package/dist/index.cjs +673 -0
  4. package/dist/index.d.ts +4 -110
  5. package/dist/{index.js → index.mjs} +451 -123
  6. package/dist/modules/blip-attendance.d.ts +11 -0
  7. package/dist/modules/blip-bucket.d.ts +3 -1
  8. package/dist/modules/blip-contact.d.ts +15 -0
  9. package/dist/modules/blip-context.d.ts +19 -0
  10. package/dist/modules/blip-dispatch.d.ts +63 -0
  11. package/dist/modules/blip-event.d.ts +12 -0
  12. package/dist/modules/blip-interaction.d.ts +13 -0
  13. package/dist/modules/blip-main.d.ts +27 -0
  14. package/dist/modules/blip-media.d.ts +3 -1
  15. package/dist/modules/blip-monitoring.d.ts +11 -0
  16. package/dist/modules/blip-ticket.d.ts +12 -0
  17. package/dist/modules/blip-whatsapp.d.ts +10 -0
  18. package/dist/modules/index.d.ts +11 -0
  19. package/dist/types/attendance-hour-container.d.ts +25 -0
  20. package/dist/types/blip-constructor.d.ts +4 -0
  21. package/dist/types/blip.d.ts +26 -0
  22. package/dist/types/campaign-notification-status.d.ts +21 -0
  23. package/dist/types/campaign-notification.d.ts +14 -0
  24. package/dist/types/campaing-request.d.ts +26 -0
  25. package/dist/types/contact.d.ts +8 -0
  26. package/dist/types/index.d.ts +7 -0
  27. package/dist/types/monitoring.d.ts +27 -0
  28. package/dist/types/template.d.ts +18 -0
  29. package/dist/types/ticket-search-result.d.ts +6 -0
  30. package/dist/types/ticket.d.ts +17 -0
  31. package/package.json +20 -5
  32. package/dist/exceptions/blip-error.js +0 -7
  33. package/dist/helpers/encode-blip-params.js +0 -11
  34. package/dist/helpers/encode-strings.js +0 -3
  35. package/dist/helpers/format-template-params.js +0 -6
  36. package/dist/helpers/handle-error.js +0 -14
  37. package/dist/helpers/validate-instance.js +0 -9
  38. package/dist/helpers/validate-response.js +0 -6
  39. package/dist/modules/blip-bucket.js +0 -88
  40. package/dist/modules/blip-media.js +0 -55
@@ -1,55 +0,0 @@
1
- import axios from 'axios';
2
- import { randomUUID } from 'crypto';
3
- import validateResponse from '../helpers/validate-response.js';
4
- import handleError from '../helpers/handle-error.js';
5
- export default class BlipMedia {
6
- api;
7
- constructor(api) {
8
- this.api = api;
9
- }
10
- /**
11
- * Uploads an media file to Blip storage to be used later when sending messages
12
- * @param content A Blob containing a image, PDF or video
13
- * @returns A public URL
14
- */
15
- async uploadMedia(content) {
16
- try {
17
- const response = await this.api.post('/commands', {
18
- id: randomUUID(),
19
- to: 'postmaster@media.msging.net',
20
- method: 'get',
21
- uri: '/upload-media-uri',
22
- });
23
- validateResponse(response);
24
- const uploadResponse = await axios.post(response.data.resource, content, {
25
- headers: { 'Content-Type': 'application/octet-stream' },
26
- });
27
- return uploadResponse.data.mediaUri;
28
- }
29
- catch (error) {
30
- throw handleError(error);
31
- }
32
- }
33
- /**
34
- * Generates a new public URI to access blip chat media. Blip medias have expiration dates so you need to generate new ones to access the data.
35
- * @param expiredMediaUri Blip media expired URI
36
- * @returns A new public URI
37
- */
38
- async refreshMediaUri(expiredMediaUri) {
39
- try {
40
- const response = await this.api.post('/commands', {
41
- id: randomUUID(),
42
- to: 'postmaster@media.msging.net',
43
- method: 'set',
44
- type: 'text/plain',
45
- uri: '/refresh-media-uri',
46
- resource: expiredMediaUri,
47
- });
48
- validateResponse(response);
49
- return response.data.resource;
50
- }
51
- catch (error) {
52
- throw handleError(error);
53
- }
54
- }
55
- }