@gymspace/sdk 1.1.0 → 1.1.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.
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +15 -0
- package/src/models/auth.ts +1 -0
- package/src/models/contracts.ts +1 -1
- package/src/models/sales.ts +6 -0
- package/src/resources/sales.ts +11 -2
- package/src/sdk.ts +13 -0
package/dist/index.mjs
CHANGED
|
@@ -47,6 +47,7 @@ var NetworkError = class extends GymSpaceError {
|
|
|
47
47
|
// src/client.ts
|
|
48
48
|
var ApiClient = class {
|
|
49
49
|
constructor(config) {
|
|
50
|
+
this.refreshToken = null;
|
|
50
51
|
this.config = config;
|
|
51
52
|
this.axiosInstance = axios.create({
|
|
52
53
|
baseURL: config.baseURL,
|
|
@@ -64,6 +65,9 @@ var ApiClient = class {
|
|
|
64
65
|
if (this.config.apiKey && config.headers) {
|
|
65
66
|
config.headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
66
67
|
}
|
|
68
|
+
if (this.refreshToken && config.url?.includes("current-session") && config.headers) {
|
|
69
|
+
config.headers["X-Refresh-Token"] = this.refreshToken;
|
|
70
|
+
}
|
|
67
71
|
return config;
|
|
68
72
|
},
|
|
69
73
|
(error) => {
|
|
@@ -161,11 +165,18 @@ var ApiClient = class {
|
|
|
161
165
|
setAuthToken(token) {
|
|
162
166
|
this.config.apiKey = token;
|
|
163
167
|
}
|
|
168
|
+
setRefreshToken(token) {
|
|
169
|
+
this.refreshToken = token;
|
|
170
|
+
}
|
|
171
|
+
getRefreshToken() {
|
|
172
|
+
return this.refreshToken;
|
|
173
|
+
}
|
|
164
174
|
setGymId(gymId) {
|
|
165
175
|
this.axiosInstance.defaults.headers.common["X-Gym-Id"] = gymId;
|
|
166
176
|
}
|
|
167
177
|
clearAuth() {
|
|
168
178
|
delete this.config.apiKey;
|
|
179
|
+
this.refreshToken = null;
|
|
169
180
|
delete this.axiosInstance.defaults.headers.common["Authorization"];
|
|
170
181
|
delete this.axiosInstance.defaults.headers.common["X-Gym-Id"];
|
|
171
182
|
}
|
|
@@ -951,6 +962,9 @@ var SalesResource = class extends BaseResource {
|
|
|
951
962
|
async updatePaymentStatus(id, paymentStatus, options) {
|
|
952
963
|
return this.client.put(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
|
|
953
964
|
}
|
|
965
|
+
async paySale(id, data, options) {
|
|
966
|
+
return this.client.post(`${this.basePath}/${id}/payment`, data, options);
|
|
967
|
+
}
|
|
954
968
|
async deleteSale(id, options) {
|
|
955
969
|
return this.client.delete(`${this.basePath}/${id}`, options);
|
|
956
970
|
}
|
|
@@ -1141,6 +1155,18 @@ var GymSpaceSdk = class {
|
|
|
1141
1155
|
setAuthToken(token) {
|
|
1142
1156
|
this.client.setAuthToken(token);
|
|
1143
1157
|
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Set the refresh token
|
|
1160
|
+
*/
|
|
1161
|
+
setRefreshToken(token) {
|
|
1162
|
+
this.client.setRefreshToken(token);
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Get the current refresh token
|
|
1166
|
+
*/
|
|
1167
|
+
getRefreshToken() {
|
|
1168
|
+
return this.client.getRefreshToken();
|
|
1169
|
+
}
|
|
1144
1170
|
/**
|
|
1145
1171
|
* Set the current gym context
|
|
1146
1172
|
*/
|