Skip to content

Commit

Permalink
feat: add getAccount query to retrieve account information (#171)
Browse files Browse the repository at this point in the history
* feat: add getAccount query to retrieve account information

This commit adds a new `getAccount` query to retrieve account information. It includes fields such as `id`, `name`, `accountName`, `tradingName`, and `isActive`. This query is implemented in both the GraphQL schema and the LMClient class.
  • Loading branch information
icaroov authored Sep 9, 2024
1 parent 09ae717 commit 1b7f76d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

Adds a new `getAccount` query to retrieve account information. It includes fields such as `id`, `name`, `accountName`, `tradingName`, and `isActive`. This query is implemented in both the GraphQL schema and the LMClient class.

## [0.55.0] - 2024-08-22

### Added
Expand Down
9 changes: 9 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ type Query {
getSellersPaginated(page: Int, pageSize: Int): GetSellersPaginatedResponse
@validateAdminUserAccess
@cacheControl(scope: PRIVATE)
getAccount: Account @validateAdminUserAccess @cacheControl(scope: PRIVATE)
}

type Account {
id: ID
name: String
accountName: String
tradingName: String
isActive: Boolean
}

type PaginationResponse {
Expand Down
52 changes: 52 additions & 0 deletions node/clients/LMClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,59 @@ export default class LMClient extends ExternalClient {
})
}

public getAccount = async () => {
return this.get<GetAccountResponse>(`/api/license-manager/account`).then(
(res) => {
return res
}
)
}

protected get = <T>(url: string) => {
return this.http.get<T>(url)
}
}

interface GetAccountResponse {
isActive: boolean
id: string
name: string
accountName: string
lv: unknown
isOperating: boolean
defaultUrl: unknown
district: unknown
country: unknown
complement: unknown
compunknownName: string
cnpj: string
haveParentAccount: boolean
parentAccountId: unknown
parentAccountName: unknown
city: unknown
address: unknown
logo: unknown
hasLogo: boolean
number: unknown
postalCode: unknown
state: unknown
telephone: string
tradingName: string
licenses: unknown[]
sponsor: {
name: string
email: string
phone: string
}
contact: {
name: string
email: string
phone: string
}
operationDate: unknown
inactivationDate: unknown
creationDate: string
hosts: unknown[]
sites: unknown[]
appKeys: unknown[]
}
15 changes: 15 additions & 0 deletions node/resolvers/Queries/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ const B2BSettings = {
}
}
},
getAccount: async (_: void, __: void, ctx: Context) => {
const {
clients: { lm },
} = ctx

return lm.getAccount().catch((e) => {
if (e.message) {
throw new GraphQLError(e.message)
} else if (e.response?.data?.message) {
throw new GraphQLError(e.response.data.message)
} else {
throw new GraphQLError(e)
}
})
},
}

export default B2BSettings

0 comments on commit 1b7f76d

Please sign in to comment.