Skip to content

Commit

Permalink
Merge pull request #27 from mohammadzade98/main
Browse files Browse the repository at this point in the history
feat: grant method on AuthService
  • Loading branch information
aminmokhtari94 authored Sep 28, 2023
2 parents 4a662d6 + e69030a commit 48f0bc5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- grants method on AuthService

## 2.8.0 - 2023-09-26

Expand Down
25 changes: 17 additions & 8 deletions src/common/enums/resource.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,30 @@ export enum Resource {
Session = 'session',
Workflow = 'workflow',
Artifact = 'artifact',
Chat = 'chat',
Stat = 'stat',

// Chat
ChatRoom = 'chat_room',
ChatMessage = 'chat_message',

// OTP
AuthOtp = 'auth_otp',

// Logistics
LogisticsLocation = 'logistics_location',
LogisticsTransportsVehicle = 'logistics_transports_vehicle',
LogisticsTransportsDriver = 'logistics_transports_drivers',
LogisticLocation = 'logistic_location',
LogisticTransportVehicle = 'logistic_transport_vehicle',
LogisticTransportDriver = 'logistic_transport_driver',

// Financial
Wallet = 'wallet',
FinancialTransactions = 'financial_transactions',
FinancialTransaction = 'financial_transaction',

// Notifications
NotificationsNotifier = 'notifications_notifier',
NotificationsProvider = 'notifications_provider',
NotificationsTemplate = 'notifications_template',
NotificationNotifier = 'notification_notifier',
NotificationProvider = 'notification_provider',
NotificationTemplate = 'notification_template',
NotificationRecipient = 'notification_recipient',
NotificationRole = 'notification_role',
}

// TODO: remove `s` at the end
17 changes: 16 additions & 1 deletion src/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosPromise, AxiosRequestConfig } from 'axios';
import { AccessTokenObject, AuthTokenReq, AuthTokenRes } from '../common';
import { AccessTokenObject, AuthTokenReq, AuthTokenRes, Grant, Items } from '../common';
import { RequestService } from './core';
import { AXIOS_CLIENT, ServiceOption } from '../common/infrastructure';

Expand Down Expand Up @@ -33,4 +33,19 @@ export class AuthService extends RequestService {
...config,
});
}

public async grants(
resources: string[],
{ config }: { config?: AxiosRequestConfig } = {},
): AxiosPromise<Items<Grant>> {
return this.get(`${this.path}/grants`, {
headers: {
Authorization: `Bearer ${(config ?? this.options)?.headers?.common?.Authorization}`,
},
params: {
resources,
},
...config,
});
}
}
2 changes: 1 addition & 1 deletion src/services/logistics/locations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class LocationsService extends RequestService {
{ config }: { config?: AxiosRequestConfig },
): AxiosPromise<Location<Meta, Prop>> {
return this.put(
{ url: `${this.path}/${type}/restore` },
{ url: `${this.path}/${type}/restore/one` },
{
params: filter,
headers: {
Expand Down

0 comments on commit 48f0bc5

Please sign in to comment.