@gymspace/sdk 1.1.0 → 1.1.2

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.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,
@@ -58,12 +59,18 @@ var ApiClient = class {
58
59
  });
59
60
  this.setupInterceptors();
60
61
  }
62
+ getAccessToken() {
63
+ return this.config.apiKey || null;
64
+ }
61
65
  setupInterceptors() {
62
66
  this.axiosInstance.interceptors.request.use(
63
67
  (config) => {
64
68
  if (this.config.apiKey && config.headers) {
65
69
  config.headers["Authorization"] = `Bearer ${this.config.apiKey}`;
66
70
  }
71
+ if (this.refreshToken && config.url?.includes("current-session") && config.headers) {
72
+ config.headers["X-Refresh-Token"] = this.refreshToken;
73
+ }
67
74
  return config;
68
75
  },
69
76
  (error) => {
@@ -161,11 +168,18 @@ var ApiClient = class {
161
168
  setAuthToken(token) {
162
169
  this.config.apiKey = token;
163
170
  }
171
+ setRefreshToken(token) {
172
+ this.refreshToken = token;
173
+ }
174
+ getRefreshToken() {
175
+ return this.refreshToken;
176
+ }
164
177
  setGymId(gymId) {
165
178
  this.axiosInstance.defaults.headers.common["X-Gym-Id"] = gymId;
166
179
  }
167
180
  clearAuth() {
168
181
  delete this.config.apiKey;
182
+ this.refreshToken = null;
169
183
  delete this.axiosInstance.defaults.headers.common["Authorization"];
170
184
  delete this.axiosInstance.defaults.headers.common["X-Gym-Id"];
171
185
  }
@@ -951,6 +965,9 @@ var SalesResource = class extends BaseResource {
951
965
  async updatePaymentStatus(id, paymentStatus, options) {
952
966
  return this.client.put(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
953
967
  }
968
+ async paySale(id, data, options) {
969
+ return this.client.post(`${this.basePath}/${id}/payment`, data, options);
970
+ }
954
971
  async deleteSale(id, options) {
955
972
  return this.client.delete(`${this.basePath}/${id}`, options);
956
973
  }
@@ -1141,6 +1158,18 @@ var GymSpaceSdk = class {
1141
1158
  setAuthToken(token) {
1142
1159
  this.client.setAuthToken(token);
1143
1160
  }
1161
+ /**
1162
+ * Set the refresh token
1163
+ */
1164
+ setRefreshToken(token) {
1165
+ this.client.setRefreshToken(token);
1166
+ }
1167
+ /**
1168
+ * Get the current refresh token
1169
+ */
1170
+ getRefreshToken() {
1171
+ return this.client.getRefreshToken();
1172
+ }
1144
1173
  /**
1145
1174
  * Set the current gym context
1146
1175
  */