-
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.
Refactor board-related functions and interfaces
- Renamed `getBoardPin` to `getBoardPins` - Updated `searchBoards` to use a new search boards parser - Restructured board-related interfaces for better type definitions - Updated import and export statements in interfaces index - Modified board search and parsing logic
- Loading branch information
Showing
8 changed files
with
111 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,44 @@ | ||
/** | ||
* Represents the owner of a Pinterest board. | ||
* This is typically the return type when fetching board owner details. | ||
*/ | ||
interface BoardOwner { | ||
/** Unique identifier for the board owner */ | ||
id?: string; | ||
/** Username of the board owner on Pinterest */ | ||
username?: string; | ||
/** Full name of the board owner */ | ||
fullName?: string; | ||
/** URL to the avatar image of the board owner */ | ||
avatarURL?: string; | ||
/** Number of followers the board owner has, can be a string or number */ | ||
followers?: number | string; | ||
} | ||
|
||
/** | ||
* Represents a Pinterest board. | ||
* This is typically the return type when fetching board details. | ||
*/ | ||
export interface IBoards { | ||
title?: string; | ||
user?: User; | ||
id?: string; | ||
aggregatedPinId?: string; | ||
image?: string; | ||
video?: string; | ||
description?: string; | ||
} | ||
|
||
interface User { | ||
name?: string; | ||
username?: string; | ||
image?: string; | ||
id?: string; | ||
nodeId?: string; | ||
type?: string; | ||
} | ||
|
||
export interface IBoardPinsResponse { | ||
bookmark: string; | ||
response: IBoards[]; | ||
} |
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
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,43 @@ | ||
import type { ISearchBoardsResponse } from "../interfaces/index"; | ||
|
||
export default function searchBoardsParser(data: any): ISearchBoardsResponse { | ||
const root = data.resource_response; | ||
const bookmark = root?.bookmark; | ||
const results = root?.data?.results; | ||
|
||
const res = results?.map((response: any, index?: number, _?: any) => { | ||
const name = response?.name; | ||
const id = response?.id; | ||
const type = response?.type; | ||
const thumbnailURL = response?.image_thumbnail_url; | ||
const thumbnailImagesURL = response?.pin_thumbnail_urls; | ||
const coverURL = response?.image_cover_hd_url; | ||
const slashURL = response?.url; | ||
const pinCount = response?.pin_count; | ||
const pinner = response?.owner; | ||
const user = { | ||
name: pinner?.full_name, | ||
username: pinner?.username, | ||
image: pinner?.image_large_url, | ||
id: pinner?.id, | ||
nodeId: pinner?.node_id, | ||
type: pinner?.type, | ||
}; | ||
|
||
return { | ||
name, | ||
id, | ||
type, | ||
thumbnailURL, | ||
thumbnailImagesURL, | ||
coverURL, | ||
slashURL, | ||
pinCount, | ||
user, | ||
}; | ||
}); | ||
return { | ||
bookmark, | ||
response: res, | ||
}; | ||
} |