@larisarozin/dodone-shared 1.1.6 → 1.1.8

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.
@@ -52,6 +52,8 @@ export interface VerifyPurchaseRequest {
52
52
  purchaseToken?: string;
53
53
  receiptData?: string;
54
54
  transactionId?: string;
55
+ signedTransactionInfo?: string;
56
+ signedRenewalInfo?: string;
55
57
  }
56
58
  export interface VerifyPurchaseResponse {
57
59
  success: boolean;
@@ -55,17 +55,18 @@ class ApiClient {
55
55
  const response = yield fetch(this.config.baseUrl + route, Object.assign(Object.assign({ method: 'POST' }, options), { headers: Object.assign({ 'Content-Type': 'application/json', Authorization: `Bearer ${this.config.token}` }, options.headers), body: body ? JSON.stringify(body) : undefined }));
56
56
  if (!response.ok) {
57
57
  // Read the error response body to get the detailed error message
58
+ let errorMessage = '';
58
59
  try {
59
60
  const errorBody = yield response.json();
60
- const errorMessage = errorBody.message || `Failed to post ${route}: ${response.status} - ${response.statusText}`;
61
+ errorMessage = errorBody.message || `Failed to post ${route}: ${response.status} - ${response.statusText}`;
61
62
  console.error(`Error posting ${route}:`, response.status, errorMessage);
62
- throw new Error(errorMessage);
63
63
  }
64
64
  catch (parseError) {
65
65
  // If parsing fails, fall back to status text
66
66
  console.error(`Error posting ${route}:`, response.status, response.statusText);
67
67
  throw new Error(`Failed to post ${route}: ${response.status} - ${response.statusText}`);
68
68
  }
69
+ throw new Error(errorMessage);
69
70
  }
70
71
  return response.json();
71
72
  });
@@ -75,17 +76,18 @@ class ApiClient {
75
76
  const response = yield fetch(this.config.baseUrl + route, Object.assign(Object.assign({ method: 'POST' }, options), { headers: Object.assign({ Authorization: `Bearer ${this.config.token}` }, options.headers), body: body }));
76
77
  if (!response.ok) {
77
78
  // Read the error response body to get the detailed error message
79
+ let errorMessage = '';
78
80
  try {
79
81
  const errorBody = yield response.json();
80
- const errorMessage = errorBody.message || `Failed to post multimedia ${route}: ${response.status} - ${response.statusText}`;
82
+ errorMessage = errorBody.message || `Failed to post multimedia ${route}: ${response.status} - ${response.statusText}`;
81
83
  console.error(`Error posting multimedia ${route}:`, response.status, errorMessage);
82
- throw new Error(errorMessage);
83
84
  }
84
85
  catch (parseError) {
85
86
  // If parsing fails, fall back to status text
86
87
  console.error(`Error posting multimedia ${route}:`, response.status, response.statusText);
87
88
  throw new Error(`Failed to post multimedia ${route}: ${response.status} - ${response.statusText}`);
88
89
  }
90
+ throw new Error(errorMessage);
89
91
  }
90
92
  return response.json();
91
93
  });
@@ -98,17 +100,18 @@ class ApiClient {
98
100
  const response = yield fetch(this.config.baseUrl + route, Object.assign(Object.assign({ method: 'PUT' }, options), { headers: Object.assign({ 'Content-Type': 'application/json', Authorization: `Bearer ${this.config.token}` }, options.headers), body: body ? JSON.stringify(body) : undefined }));
99
101
  if (!response.ok) {
100
102
  // Read the error response body to get the detailed error message
103
+ let errorMessage = '';
101
104
  try {
102
105
  const errorBody = yield response.json();
103
- const errorMessage = errorBody.message || `Failed to update ${route}: ${response.status} - ${response.statusText}`;
106
+ errorMessage = errorBody.message || `Failed to update ${route}: ${response.status} - ${response.statusText}`;
104
107
  console.error(`Error updating ${route}:`, response.status, errorMessage);
105
- throw new Error(errorMessage);
106
108
  }
107
109
  catch (parseError) {
108
110
  // If parsing fails, fall back to status text
109
111
  console.error(`Error updating ${route}:`, response.status, response.statusText);
110
112
  throw new Error(`Failed to update ${route}: ${response.status} - ${response.statusText}`);
111
113
  }
114
+ throw new Error(errorMessage);
112
115
  }
113
116
  return response.json();
114
117
  });
@@ -121,17 +124,18 @@ class ApiClient {
121
124
  const response = yield fetch(this.config.baseUrl + route, Object.assign(Object.assign({ method: 'DELETE' }, options), { headers: Object.assign({ Authorization: `Bearer ${this.config.token}` }, options.headers) }));
122
125
  if (!response.ok) {
123
126
  // Read the error response body to get the detailed error message
127
+ let errorMessage = '';
124
128
  try {
125
129
  const errorBody = yield response.json();
126
- const errorMessage = errorBody.message || `Failed to delete ${route}: ${response.status} - ${response.statusText}`;
130
+ errorMessage = errorBody.message || `Failed to delete ${route}: ${response.status} - ${response.statusText}`;
127
131
  console.error(`Error deleting ${route}:`, response.status, errorMessage);
128
- throw new Error(errorMessage);
129
132
  }
130
133
  catch (parseError) {
131
134
  // If parsing fails, fall back to status text
132
135
  console.error(`Error deleting ${route}:`, response.status, response.statusText);
133
136
  throw new Error(`Failed to delete ${route}: ${response.status} - ${response.statusText}`);
134
137
  }
138
+ throw new Error(errorMessage);
135
139
  }
136
140
  return response.json();
137
141
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larisarozin/dodone-shared",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Shared utilities and components for DoDone",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",