-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from fagbokforlaget/EP-3907-update-erudio-client
EP-3907-update-erudio-client
- Loading branch information
Showing
9 changed files
with
221 additions
and
12 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,51 @@ | ||
import { TagObject } from '../../tag/dto/tag.dto'; | ||
|
||
export interface LearningPathDto { | ||
readonly id: string; | ||
readonly name: string; | ||
readonly slug: string; | ||
readonly metadata?: Metadata; | ||
readonly forkId?: string; | ||
readonly status: string; | ||
readonly namespaceId?: string; | ||
readonly learningPathElements: LearningPathElementOutputDto[]; | ||
readonly tags: TagObject[]; | ||
localizations: { | ||
readonly locale: string; | ||
readonly content: Record<string, unknown>; | ||
}[]; | ||
readonly createdBy: string; | ||
readonly createdAt: string; | ||
readonly updatedAt: string; | ||
} | ||
|
||
interface Metadata { | ||
readonly description?: string; | ||
readonly descriptionInstructor?: string; | ||
readonly author?: string; | ||
readonly coverId?: string; | ||
readonly coverAlt?: string; | ||
readonly coverCopyright?: string; | ||
readonly bannerId?: string; | ||
readonly bannerAlt?: string; | ||
readonly bannerCopyright?: string; | ||
readonly duration?: number; | ||
} | ||
|
||
class LearningPathElementOutputDto { | ||
readonly id: string; | ||
readonly createdAt: string; | ||
readonly updatedAt: string; | ||
readonly namespaceId: string; | ||
readonly description?: string; | ||
readonly contentId?: string; | ||
readonly contentType?: string; | ||
readonly condition?: Record<string, unknown>; | ||
} | ||
|
||
export type LearningPathWithLocalizationDto = Omit< | ||
LearningPathDto, | ||
'localizations' | ||
> & { | ||
readonly localization?: Record<string, unknown>; | ||
}; |
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,30 @@ | ||
import { HttpClientProxy } from '../utils/http-client-proxy'; | ||
import { | ||
LearningPathDto, | ||
LearningPathWithLocalizationDto, | ||
} from './dto/learning-path.dto'; | ||
|
||
export class LearningPath { | ||
private readonly baseUrl: string; | ||
|
||
constructor(host: string) { | ||
this.baseUrl = `http://edtech-learning-path-runner-service.${host}`; | ||
} | ||
|
||
public async getLearningPath( | ||
id: string, | ||
locale: string, | ||
): Promise<LearningPathWithLocalizationDto> { | ||
let localization: Record<string, unknown>; | ||
|
||
const url = `${this.baseUrl}/learning-paths/${id}`; | ||
const learningPath = await new HttpClientProxy().get<LearningPathDto>(url); | ||
if (locale && learningPath?.localizations) { | ||
localization = learningPath.localizations.find( | ||
(l) => l.locale === locale, | ||
)?.content; | ||
learningPath.localizations = undefined; | ||
} | ||
return { ...learningPath, localization }; | ||
} | ||
} |
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
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,24 @@ | ||
import { LearningPathDto } from '../../src/learning-path/dto/learning-path.dto'; | ||
|
||
export const learningPath: LearningPathDto = { | ||
id: 'b942d4de-921c-4406-abbd-464dabb7b323', | ||
name: 'name', | ||
slug: 'slug', | ||
status: 'status', | ||
createdBy: 'created_by', | ||
createdAt: 'created_at', | ||
updatedAt: 'updated_at', | ||
learningPathElements: [ | ||
{ | ||
id: 'id', | ||
namespaceId: 'namespaceId', | ||
createdAt: 'created_at', | ||
updatedAt: 'updated_at', | ||
}, | ||
], | ||
tags: [], | ||
localizations: [ | ||
{ locale: 'locale123', content: { con1: 'con1', con2: 'con2' } }, | ||
{ locale: 'locale456', content: { con3: 'con4', con5: 'con6' } }, | ||
], | ||
}; |
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