Skip to content

Commit e96f45b

Browse files
fix: remove all params from axios request config object which is causing 422 errors
1 parent bd95c63 commit e96f45b

File tree

38 files changed

+1695
-1285
lines changed

38 files changed

+1695
-1285
lines changed

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,6 @@ const campaigns = await ghl.campaigns.getCampaigns({
259259
});
260260
```
261261

262-
#### Opportunities
263-
```typescript
264-
// Get opportunities
265-
const opportunities = await ghl.opportunities.getOpportunities({
266-
locationId: 'location-id',
267-
limit: 20
268-
});
269-
```
270-
271262
## Error Handling
272263

273264
The SDK uses a custom `GHLError` class that provides detailed error information:

lib/HighLevel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ export class HighLevel {
645645
const resourceId = this.extractResourceId(
646646
securityRequirements,
647647
originalRequest.headers || {},
648-
originalRequest.params || {},
648+
{ ...originalRequest.params || {}, ...originalRequest.__pathParams || {} },
649649
originalRequest.data || {},
650650
preferredTokenType
651651
);

lib/code/associations/associations.ts

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
22
import * as Models from './models/associations';
3-
import { buildUrl, extractParams, getAuthToken } from '../../utils/request-utils';
3+
import { buildUrl, extractParams, getAuthToken, RequestConfig } from '../../utils/request-utils';
44

55
/**
66
* Associations Service
@@ -25,18 +25,19 @@ export class Associations {
2525
const extracted = extractParams(null, paramDefs);
2626
const requirements: string[] = ["bearer"];
2727

28-
const config: AxiosRequestConfig = {
28+
const config: RequestConfig = {
2929
method: 'POST',
3030
url: buildUrl('/associations/relations', extracted.path),
31-
params: { ...extracted.query, ...extracted.all },
31+
params: extracted.query,
3232
headers: { ...extracted.header, ...options?.headers },
3333
data: requestBody,
3434
__secutiryRequirements: requirements,
3535

36+
__pathParams: extracted.path,
3637
...options
3738
};
3839

39-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, requestBody);
40+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, requestBody);
4041
if (authToken) {
4142
config.headers = { ...config.headers, Authorization: authToken };
4243
}
@@ -63,18 +64,19 @@ export class Associations {
6364
const extracted = extractParams(params, paramDefs);
6465
const requirements: string[] = ["bearer"];
6566

66-
const config: AxiosRequestConfig = {
67+
const config: RequestConfig = {
6768
method: 'GET',
6869
url: buildUrl('/associations/relations/{recordId}', extracted.path),
69-
params: { ...extracted.query, ...extracted.all },
70+
params: extracted.query,
7071
headers: { ...extracted.header, ...options?.headers },
7172

7273
__secutiryRequirements: requirements,
7374

75+
__pathParams: extracted.path,
7476
...options
7577
};
7678

77-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
79+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
7880
if (authToken) {
7981
config.headers = { ...config.headers, Authorization: authToken };
8082
}
@@ -98,18 +100,19 @@ export class Associations {
98100
const extracted = extractParams(params, paramDefs);
99101
const requirements: string[] = ["bearer"];
100102

101-
const config: AxiosRequestConfig = {
103+
const config: RequestConfig = {
102104
method: 'DELETE',
103105
url: buildUrl('/associations/relations/{relationId}', extracted.path),
104-
params: { ...extracted.query, ...extracted.all },
106+
params: extracted.query,
105107
headers: { ...extracted.header, ...options?.headers },
106108

107109
__secutiryRequirements: requirements,
108110

111+
__pathParams: extracted.path,
109112
...options
110113
};
111114

112-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
115+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
113116
if (authToken) {
114117
config.headers = { ...config.headers, Authorization: authToken };
115118
}
@@ -133,18 +136,19 @@ export class Associations {
133136
const extracted = extractParams(params, paramDefs);
134137
const requirements: string[] = ["bearer"];
135138

136-
const config: AxiosRequestConfig = {
139+
const config: RequestConfig = {
137140
method: 'GET',
138141
url: buildUrl('/associations/key/{key_name}', extracted.path),
139-
params: { ...extracted.query, ...extracted.all },
142+
params: extracted.query,
140143
headers: { ...extracted.header, ...options?.headers },
141144

142145
__secutiryRequirements: requirements,
143146

147+
__pathParams: extracted.path,
144148
...options
145149
};
146150

147-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
151+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
148152
if (authToken) {
149153
config.headers = { ...config.headers, Authorization: authToken };
150154
}
@@ -168,18 +172,19 @@ export class Associations {
168172
const extracted = extractParams(params, paramDefs);
169173
const requirements: string[] = ["bearer"];
170174

171-
const config: AxiosRequestConfig = {
175+
const config: RequestConfig = {
172176
method: 'GET',
173177
url: buildUrl('/associations/objectKey/{objectKey}', extracted.path),
174-
params: { ...extracted.query, ...extracted.all },
178+
params: extracted.query,
175179
headers: { ...extracted.header, ...options?.headers },
176180

177181
__secutiryRequirements: requirements,
178182

183+
__pathParams: extracted.path,
179184
...options
180185
};
181186

182-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
187+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
183188
if (authToken) {
184189
config.headers = { ...config.headers, Authorization: authToken };
185190
}
@@ -203,18 +208,19 @@ export class Associations {
203208
const extracted = extractParams(params, paramDefs);
204209
const requirements: string[] = ["bearer"];
205210

206-
const config: AxiosRequestConfig = {
211+
const config: RequestConfig = {
207212
method: 'PUT',
208213
url: buildUrl('/associations/{associationId}', extracted.path),
209-
params: { ...extracted.query, ...extracted.all },
214+
params: extracted.query,
210215
headers: { ...extracted.header, ...options?.headers },
211216
data: requestBody,
212217
__secutiryRequirements: requirements,
213218

219+
__pathParams: extracted.path,
214220
...options
215221
};
216222

217-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, requestBody);
223+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, requestBody);
218224
if (authToken) {
219225
config.headers = { ...config.headers, Authorization: authToken };
220226
}
@@ -237,18 +243,19 @@ export class Associations {
237243
const extracted = extractParams(params, paramDefs);
238244
const requirements: string[] = ["bearer"];
239245

240-
const config: AxiosRequestConfig = {
246+
const config: RequestConfig = {
241247
method: 'DELETE',
242248
url: buildUrl('/associations/{associationId}', extracted.path),
243-
params: { ...extracted.query, ...extracted.all },
249+
params: extracted.query,
244250
headers: { ...extracted.header, ...options?.headers },
245251

246252
__secutiryRequirements: requirements,
247253

254+
__pathParams: extracted.path,
248255
...options
249256
};
250257

251-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
258+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
252259
if (authToken) {
253260
config.headers = { ...config.headers, Authorization: authToken };
254261
}
@@ -271,18 +278,19 @@ export class Associations {
271278
const extracted = extractParams(params, paramDefs);
272279
const requirements: string[] = ["bearer"];
273280

274-
const config: AxiosRequestConfig = {
281+
const config: RequestConfig = {
275282
method: 'GET',
276283
url: buildUrl('/associations/{associationId}', extracted.path),
277-
params: { ...extracted.query, ...extracted.all },
284+
params: extracted.query,
278285
headers: { ...extracted.header, ...options?.headers },
279286

280287
__secutiryRequirements: requirements,
281288

289+
__pathParams: extracted.path,
282290
...options
283291
};
284292

285-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
293+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
286294
if (authToken) {
287295
config.headers = { ...config.headers, Authorization: authToken };
288296
}
@@ -303,18 +311,19 @@ export class Associations {
303311
const extracted = extractParams(null, paramDefs);
304312
const requirements: string[] = ["bearer"];
305313

306-
const config: AxiosRequestConfig = {
314+
const config: RequestConfig = {
307315
method: 'POST',
308316
url: buildUrl('/associations/', extracted.path),
309-
params: { ...extracted.query, ...extracted.all },
317+
params: extracted.query,
310318
headers: { ...extracted.header, ...options?.headers },
311319
data: requestBody,
312320
__secutiryRequirements: requirements,
313321

322+
__pathParams: extracted.path,
314323
...options
315324
};
316325

317-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, requestBody);
326+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, requestBody);
318327
if (authToken) {
319328
config.headers = { ...config.headers, Authorization: authToken };
320329
}
@@ -339,18 +348,19 @@ export class Associations {
339348
const extracted = extractParams(params, paramDefs);
340349
const requirements: string[] = ["bearer"];
341350

342-
const config: AxiosRequestConfig = {
351+
const config: RequestConfig = {
343352
method: 'GET',
344353
url: buildUrl('/associations/', extracted.path),
345-
params: { ...extracted.query, ...extracted.all },
354+
params: extracted.query,
346355
headers: { ...extracted.header, ...options?.headers },
347356

348357
__secutiryRequirements: requirements,
349358

359+
__pathParams: extracted.path,
350360
...options
351361
};
352362

353-
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, config.params || {}, {});
363+
const authToken = await getAuthToken(this.client, requirements, config.headers || {}, { ...config.params || {}, ...config.__pathParams }, {});
354364
if (authToken) {
355365
config.headers = { ...config.headers, Authorization: authToken };
356366
}

0 commit comments

Comments
 (0)