@zennify/sdk-js 1.7.2 → 1.10.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zennify/sdk-js",
3
- "version": "1.7.2",
3
+ "version": "1.10.0",
4
4
  "description": "A simple package to work with https://api.zennify.app",
5
5
  "main": "dist/main.js",
6
6
  "keywords": [],
package/src/errors.ts CHANGED
@@ -83,6 +83,7 @@ export interface APIErrors {
83
83
  'INVALID_REFUND_VALUE_EXCEEDS_ORDER_VALUE': {};
84
84
  'ORDER_TRANSACTION_ALREADY_REFUNDED': {};
85
85
  'FAILED_REFUND': {};
86
+ 'INVALID_METADATA': { details: string };
86
87
  // MP errors
87
88
  'MP_ACCOUNT_OFFLINE': {};
88
89
  'MP_PIX_KEY_NOT_CONFIGURED': {};
@@ -1,29 +1,39 @@
1
- export type FullTransaction = {
1
+ export type BaseTransaction<TransactionMetadata extends any = any> = {
2
2
  id: string,
3
+ created_at: string,
3
4
  entity: 'semiauto' | 'mercadopago',
4
5
  method: 'pix',
5
- managed: null,
6
+ managed?: boolean | null,
6
7
  status: 'approved' | 'cancelled' | 'expired' | 'pending' | 'refused' | 'rejected' | 'analysis',
7
8
  value: number,
8
9
  base_value: number,
9
10
  refunded_value: number,
10
- refund_reason: null,
11
- refund_comment: null,
12
- refund_requested_by: null,
13
- pix_e2eid: null,
14
- pix_qrcode: null,
15
- payer_bank: null,
16
- order: {
11
+ refund_reason?: string | null,
12
+ refund_comment?: string | null,
13
+ refund_requested_by?: string | null,
14
+ pix_e2eid?: string | null,
15
+ pix_qrcode?: string | null,
16
+ payer_bank?: string | null,
17
+ metadata?: TransactionMetadata | null
18
+ };
19
+
20
+ type DiscordOrder = {
21
+ platform: 'discord',
22
+ discord_guild_id?: string | null,
23
+ discord_channel_id?: string | null,
24
+ discord_channel_message_id?: string | null
25
+ }
26
+
27
+ export type SaleTransaction = BaseTransaction & {
28
+ type: 'sale',
29
+ order: DiscordOrder & {
17
30
  id: string,
18
31
  created_at: string,
19
- platform: 'discord',
20
- discord_guild_id: null,
21
32
  discount: number,
22
33
  subtotal: number,
23
34
  total_value: number,
24
- rating: null,
25
- rating_message: null,
26
- metadata: null,
35
+ rating?: number | null,
36
+ rating_message?: number | null,
27
37
  payer: {
28
38
  id: number,
29
39
  username: string,
@@ -37,19 +47,21 @@ export type FullTransaction = {
37
47
  store: {
38
48
  id: number,
39
49
  name: string,
40
- icon_id: null,
41
- banner_id: null
50
+ icon_id?: number | null,
51
+ banner_id?: number | null
42
52
  },
43
53
  products: [
44
54
  {
45
55
  id: number,
46
56
  name: string,
47
57
  value: number,
48
- icon_id: null,
49
- banner_id: null,
58
+ icon_id?: number | null,
59
+ banner_id?: number | null
50
60
  amount: number,
51
61
  delivered: string[]
52
62
  }
53
63
  ]
54
64
  }
55
- }
65
+ };
66
+
67
+ export type FullTransaction<TransactionMetadata extends any = any> = BaseTransaction<TransactionMetadata> & SaleTransaction;
@@ -231,6 +231,10 @@
231
231
  "name": "Failed to refund this order",
232
232
  "message": "Please contact support."
233
233
  },
234
+ "INVALID_METADATA": {
235
+ "name": "Invalid metadata for update",
236
+ "message": "Must be a JSON array or JSON object with up to 1000 characters"
237
+ },
234
238
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX": {
235
239
  "name": "This seller has not yet configured receipt via PIX",
236
240
  "message": "Choose another method or wait for seller configuration."
@@ -227,6 +227,10 @@
227
227
  "name": "Ocorreu uma falha ao reembolsar este pedido",
228
228
  "message": "Entre em contato com o suporte."
229
229
  },
230
+ "INVALID_METADATA": {
231
+ "name": "Metadados inválidos para atualização",
232
+ "message": "Precisa ser um array JSON ou objeto JSON com até 1000 caracteres"
233
+ },
230
234
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX": {
231
235
  "name": "O vendedor não configurou o recebimento via Pix",
232
236
  "message": "Escolha outro método ou aguarde a configuração do vendedor."
package/types/errors.d.ts CHANGED
@@ -76,6 +76,9 @@ export interface APIErrors {
76
76
  'INVALID_REFUND_VALUE_EXCEEDS_ORDER_VALUE': {};
77
77
  'ORDER_TRANSACTION_ALREADY_REFUNDED': {};
78
78
  'FAILED_REFUND': {};
79
+ 'INVALID_METADATA': {
80
+ details: string;
81
+ };
79
82
  'MP_ACCOUNT_OFFLINE': {};
80
83
  'MP_PIX_KEY_NOT_CONFIGURED': {};
81
84
  'MP_NOT_ALLOWED_TO_SELL': {};
@@ -1,29 +1,37 @@
1
- export type FullTransaction = {
1
+ export type BaseTransaction<TransactionMetadata extends any = any> = {
2
2
  id: string;
3
+ created_at: string;
3
4
  entity: 'semiauto' | 'mercadopago';
4
5
  method: 'pix';
5
- managed: null;
6
+ managed?: boolean | null;
6
7
  status: 'approved' | 'cancelled' | 'expired' | 'pending' | 'refused' | 'rejected' | 'analysis';
7
8
  value: number;
8
9
  base_value: number;
9
10
  refunded_value: number;
10
- refund_reason: null;
11
- refund_comment: null;
12
- refund_requested_by: null;
13
- pix_e2eid: null;
14
- pix_qrcode: null;
15
- payer_bank: null;
16
- order: {
11
+ refund_reason?: string | null;
12
+ refund_comment?: string | null;
13
+ refund_requested_by?: string | null;
14
+ pix_e2eid?: string | null;
15
+ pix_qrcode?: string | null;
16
+ payer_bank?: string | null;
17
+ metadata?: TransactionMetadata | null;
18
+ };
19
+ type DiscordOrder = {
20
+ platform: 'discord';
21
+ discord_guild_id?: string | null;
22
+ discord_channel_id?: string | null;
23
+ discord_channel_message_id?: string | null;
24
+ };
25
+ export type SaleTransaction = BaseTransaction & {
26
+ type: 'sale';
27
+ order: DiscordOrder & {
17
28
  id: string;
18
29
  created_at: string;
19
- platform: 'discord';
20
- discord_guild_id: null;
21
30
  discount: number;
22
31
  subtotal: number;
23
32
  total_value: number;
24
- rating: null;
25
- rating_message: null;
26
- metadata: null;
33
+ rating?: number | null;
34
+ rating_message?: number | null;
27
35
  payer: {
28
36
  id: number;
29
37
  username: string;
@@ -37,19 +45,21 @@ export type FullTransaction = {
37
45
  store: {
38
46
  id: number;
39
47
  name: string;
40
- icon_id: null;
41
- banner_id: null;
48
+ icon_id?: number | null;
49
+ banner_id?: number | null;
42
50
  };
43
51
  products: [
44
52
  {
45
53
  id: number;
46
54
  name: string;
47
55
  value: number;
48
- icon_id: null;
49
- banner_id: null;
56
+ icon_id?: number | null;
57
+ banner_id?: number | null;
50
58
  amount: number;
51
59
  delivered: string[];
52
60
  }
53
61
  ];
54
62
  };
55
63
  };
64
+ export type FullTransaction<TransactionMetadata extends any = any> = BaseTransaction<TransactionMetadata> & SaleTransaction;
65
+ export {};