Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(front): semester fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Oct 8, 2022
1 parent e81282d commit 2431e48
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions common_front-end/fetchers/semester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { JSON_API_MEDIA_TYPE } from "$/types/server"
import type { Response } from "$@/types/independent"
import type {
SemesterResourceIdentifier,
SemesterAttributes,
SemesterResource,
DeserializedSemesterResource,
SemesterDocument,
SemesterListDocument,
DeserializedSemesterDocument,
DeserializedSemesterListDocument
} from "$/types/documents/semester"

import { SEMESTER_LINK } from "$/constants/template_links"

import BaseFetcher from "$@/fetchers/base"

export default class SemesterFetcher extends BaseFetcher<
SemesterResourceIdentifier<"read">,
SemesterAttributes<"serialized">,
SemesterAttributes<"deserialized">,
SemesterResource,
DeserializedSemesterResource,
SemesterDocument,
SemesterListDocument,
DeserializedSemesterDocument,
DeserializedSemesterListDocument
> {
constructor() {
super(SEMESTER_LINK)
}

async createWithFile(details: FormData): Promise<Response<
SemesterResourceIdentifier<"read">,
SemesterAttributes<"serialized">,
SemesterAttributes<"deserialized">,
SemesterResource,
DeserializedSemesterResource,
DeserializedSemesterDocument
>> {
const headers = new Headers({ "Accept": JSON_API_MEDIA_TYPE })

return await this.handleResponse(
this.postTo(this.links.unbound, details, headers)
) as Response<
SemesterResourceIdentifier<"read">,
SemesterAttributes<"serialized">,
SemesterAttributes<"deserialized">,
SemesterResource,
DeserializedSemesterResource,
DeserializedSemesterDocument
>
}
}

0 comments on commit 2431e48

Please sign in to comment.