Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getAccount query to retrieve account information #171

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading