This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
generated from KennethTrecy/web_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.
- Loading branch information
Angelo Magtoto
committed
Oct 8, 2022
1 parent
e81282d
commit 2431e48
Showing
1 changed file
with
54 additions
and
0 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
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 | ||
> | ||
} | ||
} |