-
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.
Fetch Cítov items from rhinventory API
- Loading branch information
Showing
5 changed files
with
58 additions
and
15 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,32 @@ | ||
import type { AssetData } from "$src/types"; | ||
|
||
type RHInventoryAPIAsset = { | ||
id: number; | ||
name: string; | ||
note: string; | ||
primary_image_path: string; | ||
primary_document_path: string; | ||
primary_dump_path: string; | ||
} | ||
|
||
type RHInventoryAssetsResponse = { | ||
assets: RHInventoryAPIAsset[]; | ||
} | ||
|
||
export async function loadRHInventoryAssetData(params: {tagId: number, page: number}): Promise<AssetData[]> { | ||
// TODO handle page | ||
const url = `https://api.inventory.herniarchiv.cz/asset/list-by-tag?tag_id=${params.tagId}`; | ||
const response = await fetch(url); | ||
const APIAssets = (await response.json()) as RHInventoryAssetsResponse; | ||
|
||
console.log(APIAssets); | ||
|
||
return APIAssets.assets.map(APIAsset => { | ||
return { | ||
name: APIAsset.name, | ||
picture: {url: APIAsset.primary_image_path}, | ||
description: APIAsset.note, | ||
inventory_url: `https://inventory.herniarchiv.cz/asset/${APIAsset.id}` /* TODO use slug */ | ||
} | ||
}); | ||
} |
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