-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added WIP Content and Finished Download modules
- Loading branch information
Showing
6 changed files
with
235 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Client } from './Client.js' | ||
import { ContentDTO } from './utility/Global.js' | ||
|
||
export const ContentEndpoint = 'content' | ||
export class Content { | ||
private client: Client | ||
constructor(client: Client) { | ||
this.client = client | ||
} | ||
|
||
async getVersions(contentId: number, language: string): Promise<ContentDTO[]> { | ||
const response = await this.client.call('GET', `${ContentEndpoint}/${contentId}/${language}/version`, null) | ||
return response?.ok ? await response.json() : null | ||
} | ||
|
||
async get(contentId: number, language: string, sectionId: number): Promise<ContentDTO> { | ||
const response = await this.client.call('GET', `${ContentEndpoint}/${sectionId}/${contentId}/${language}`, null) | ||
return response?.ok ? await response.json() : null | ||
} | ||
|
||
async getWithoutSection(contentId: number, language: string, version?: string) { | ||
if (!version) version = (await this.getVersions(contentId, language))[0].version | ||
const response = await this.client.call('GET', `${ContentEndpoint}/${contentId}/${language}/version/${version}`, null) | ||
return response?.ok ? await response.json() : null | ||
} | ||
} |
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,22 @@ | ||
import { Client } from "./Client" | ||
import { FileDownload } from './utility/Global.js' | ||
|
||
|
||
export const DownloadEndpoint = 'download' | ||
export class Download { | ||
private client: Client | ||
constructor(client: Client) { | ||
this.client = client | ||
} | ||
|
||
async getFileFromElement(element: string, contentId: number, language: string): Promise<FileDownload> { | ||
const response = await this.client.call('GET', `${DownloadEndpoint}/${contentId}/${language}/${element}`, null) | ||
return response?.ok ? await response.json() : null | ||
} | ||
|
||
async getFileFromElementVersion(element: string, contentId: number, language: string, version: number): Promise<FileDownload> { | ||
const response = await this.client.call('GET', `${DownloadEndpoint}/${contentId}/${language}/${version}/${element}`, null) | ||
return response?.ok ? await response.json() : null | ||
} | ||
} | ||
|
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
Oops, something went wrong.