generated from bscotch/typescript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Have all API data wrapped in a class extending a base 'FavroEnt…
…ity' class, with access to the client.
- Loading branch information
1 parent
c69391b
commit 546cc98
Showing
7 changed files
with
81 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { BravoClient } from './BravoClient.js'; | ||
|
||
/** | ||
* Base class for Favro Entities (wrapping raw API data) | ||
*/ | ||
export class FavroEntity<EntityData> { | ||
constructor(protected _client: BravoClient, protected _data: EntityData) {} | ||
|
||
toJSON() { | ||
return { ...this._data }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { FavroDataOrganization } from '../types/FavroApi'; | ||
import { FavroEntity } from './FavroEntity.js'; | ||
import { FavroUser } from './FavroUser.js'; | ||
|
||
export class FavroOrganization extends FavroEntity<FavroDataOrganization> { | ||
get name() { | ||
return this._data.name; | ||
} | ||
|
||
get sharedToUsers() { | ||
return this._data.sharedToUsers.map((u) => new FavroUser(this._client, u)); | ||
} | ||
|
||
get organizationId() { | ||
return this._data.organizationId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters