@gymspace/sdk 1.0.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/README.md +160 -0
- package/dist/index.js +1379 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1321 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +76 -0
- package/src/client.ts +200 -0
- package/src/errors.ts +49 -0
- package/src/index.ts +15 -0
- package/src/models/assets.ts +24 -0
- package/src/models/auth.ts +155 -0
- package/src/models/check-ins.ts +75 -0
- package/src/models/clients.ts +109 -0
- package/src/models/contracts.ts +61 -0
- package/src/models/dashboard.ts +32 -0
- package/src/models/evaluations.ts +91 -0
- package/src/models/files.ts +23 -0
- package/src/models/gyms.ts +73 -0
- package/src/models/index.ts +24 -0
- package/src/models/invitations.ts +29 -0
- package/src/models/leads.ts +52 -0
- package/src/models/membership-plans.ts +71 -0
- package/src/models/onboarding.ts +171 -0
- package/src/models/organizations.ts +25 -0
- package/src/models/products.ts +99 -0
- package/src/models/sales.ts +108 -0
- package/src/models/suppliers.ts +57 -0
- package/src/models/users.ts +17 -0
- package/src/resources/assets.ts +102 -0
- package/src/resources/auth.ts +137 -0
- package/src/resources/base.ts +50 -0
- package/src/resources/check-ins.ts +63 -0
- package/src/resources/clients.ts +57 -0
- package/src/resources/contracts.ts +59 -0
- package/src/resources/dashboard.ts +30 -0
- package/src/resources/evaluations.ts +63 -0
- package/src/resources/files.ts +95 -0
- package/src/resources/gyms.ts +61 -0
- package/src/resources/health.ts +28 -0
- package/src/resources/index.ts +20 -0
- package/src/resources/invitations.ts +38 -0
- package/src/resources/leads.ts +48 -0
- package/src/resources/membership-plans.ts +54 -0
- package/src/resources/onboarding.ts +58 -0
- package/src/resources/organizations.ts +23 -0
- package/src/resources/products.ts +91 -0
- package/src/resources/public-catalog.ts +61 -0
- package/src/resources/sales.ts +83 -0
- package/src/resources/suppliers.ts +44 -0
- package/src/resources/users.ts +27 -0
- package/src/sdk.ts +104 -0
- package/src/types.ts +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @gymspace/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the GymSpace API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gymspace/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @gymspace/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @gymspace/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { GymSpaceSDK } from '@gymspace/sdk';
|
|
19
|
+
|
|
20
|
+
// Initialize the SDK
|
|
21
|
+
const sdk = new GymSpaceSDK({
|
|
22
|
+
baseURL: 'https://api.gymspace.com',
|
|
23
|
+
apiKey: 'your-api-key', // Optional
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Login
|
|
27
|
+
const { user, token } = await sdk.auth.login({
|
|
28
|
+
email: 'user@example.com',
|
|
29
|
+
password: 'password123',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Set authentication token
|
|
33
|
+
sdk.setAuthToken(token);
|
|
34
|
+
|
|
35
|
+
// Use the SDK
|
|
36
|
+
const gyms = await sdk.gyms.list();
|
|
37
|
+
const clients = await sdk.clients.list();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- 🔐 **Authentication**: Login, logout, and session management
|
|
43
|
+
- 🏢 **Organizations**: Manage organizations and permissions
|
|
44
|
+
- 🏋️ **Gyms**: Complete gym management operations
|
|
45
|
+
- 👥 **Clients**: Client registration and management
|
|
46
|
+
- 📊 **Membership Plans**: Create and manage membership plans
|
|
47
|
+
- 📝 **Contracts**: Handle client contracts
|
|
48
|
+
- ✅ **Check-ins**: Track client check-ins
|
|
49
|
+
- 📈 **Evaluations**: Client evaluation management
|
|
50
|
+
- 🎯 **Leads**: Lead tracking and conversion
|
|
51
|
+
- 📁 **Files**: File upload and management
|
|
52
|
+
- 📊 **Dashboard**: Analytics and statistics
|
|
53
|
+
|
|
54
|
+
## API Reference
|
|
55
|
+
|
|
56
|
+
### Authentication
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// Login
|
|
60
|
+
const result = await sdk.auth.login({ email, password });
|
|
61
|
+
|
|
62
|
+
// Get current session
|
|
63
|
+
const session = await sdk.auth.getCurrentSession();
|
|
64
|
+
|
|
65
|
+
// Logout
|
|
66
|
+
await sdk.auth.logout();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Gyms
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// List gyms
|
|
73
|
+
const gyms = await sdk.gyms.list({ page: 1, limit: 10 });
|
|
74
|
+
|
|
75
|
+
// Get gym by ID
|
|
76
|
+
const gym = await sdk.gyms.get('gym-id');
|
|
77
|
+
|
|
78
|
+
// Create gym
|
|
79
|
+
const newGym = await sdk.gyms.create({
|
|
80
|
+
name: 'Fitness Center',
|
|
81
|
+
address: '123 Main St',
|
|
82
|
+
// ...
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Update gym
|
|
86
|
+
const updated = await sdk.gyms.update('gym-id', { name: 'New Name' });
|
|
87
|
+
|
|
88
|
+
// Delete gym
|
|
89
|
+
await sdk.gyms.delete('gym-id');
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Clients
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// List clients
|
|
96
|
+
const clients = await sdk.clients.list({ page: 1, limit: 20 });
|
|
97
|
+
|
|
98
|
+
// Create client
|
|
99
|
+
const client = await sdk.clients.create({
|
|
100
|
+
email: 'client@example.com',
|
|
101
|
+
name: 'John Doe',
|
|
102
|
+
// ...
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Get client details
|
|
106
|
+
const clientDetails = await sdk.clients.get('client-id');
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const sdk = new GymSpaceSDK({
|
|
113
|
+
baseURL: 'https://api.gymspace.com',
|
|
114
|
+
timeout: 30000, // 30 seconds
|
|
115
|
+
headers: {
|
|
116
|
+
'X-Custom-Header': 'value',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Set auth token after login
|
|
121
|
+
sdk.setAuthToken('your-auth-token');
|
|
122
|
+
|
|
123
|
+
// Set gym context
|
|
124
|
+
sdk.setGymId('gym-id');
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Error Handling
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
try {
|
|
131
|
+
const result = await sdk.gyms.create(data);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (error.response) {
|
|
134
|
+
// Server responded with error
|
|
135
|
+
console.error('Error:', error.response.data);
|
|
136
|
+
} else if (error.request) {
|
|
137
|
+
// Request made but no response
|
|
138
|
+
console.error('Network error:', error.message);
|
|
139
|
+
} else {
|
|
140
|
+
// Other errors
|
|
141
|
+
console.error('Error:', error.message);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## TypeScript Support
|
|
147
|
+
|
|
148
|
+
This SDK is written in TypeScript and provides full type definitions for all API responses and requests.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import type {
|
|
152
|
+
IGym,
|
|
153
|
+
IClient,
|
|
154
|
+
IMembershipPlan
|
|
155
|
+
} from '@gymspace/sdk';
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT © GymSpace Team
|