Skip to content

Commit

Permalink
Remove lodash.get from apiRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
ksvirkou-hubspot committed Feb 25, 2025
1 parent 34f74df commit 83fd6e6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/services/http/Auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import get from 'lodash.get'
import IConfiguration from '../../configuration/IConfiguration'
import { AuthTypes } from './AuthTypes'
import { IHttpOptions } from './IHttpOptions'
Expand All @@ -12,7 +11,7 @@ export class Auth {
}
} else {
for (const key in AuthTypes) {
if (get(config, key)) {
if (config[key as keyof typeof AuthTypes]) {
type = key
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/services/http/AuthTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { AuthMethods } from './AuthMethods'

export enum AuthTypes {
apiKey = AuthMethods.hapikey,
accessToken = AuthMethods.accessToken,
developerApiKey = AuthMethods.hapikey,
apiKey = 'hapikey',
accessToken = 'accessToken',
developerApiKey = 'hapikey'

Check failure on line 4 in src/services/http/AuthTypes.ts

View workflow job for this annotation

GitHub Actions / Run eslint

Duplicate enum member value hapikey
}
6 changes: 2 additions & 4 deletions src/services/http/Request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import get from 'lodash.get'
import { ApiClientConfigurator } from '../../configuration/ApiClientConfigurator'
import IConfiguration from '../../configuration/IConfiguration'
import { Auth } from './Auth'
Expand Down Expand Up @@ -54,9 +53,8 @@ export class Request {

if (authType && authType in AuthTypes) {
const type = authType as keyof typeof AuthTypes

const method: keyof typeof AuthMethods = AuthTypes[type]
const value = get(this.config, authType)
const method: string = AuthTypes[type]
const value: string = this.config[type] ?? ""
if (method === AuthMethods.hapikey) {
this.url.searchParams.set('hapikey', value)
}
Expand Down

0 comments on commit 83fd6e6

Please sign in to comment.