This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 158
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 #160 from unsplash/feature/response-types
Feature: Response types
- Loading branch information
Showing
14 changed files
with
212 additions
and
16 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
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,28 @@ | ||
import { Nullable } from '../../helpers/typescript'; | ||
import { Entity } from '../../types/entities'; | ||
import * as Photo from '../photos/types'; | ||
import * as User from '../users/types'; | ||
|
||
export interface Basic extends Entity { | ||
cover_photo: Nullable<Photo.Basic>; | ||
description: Nullable<string>; | ||
featured: boolean; | ||
/** | ||
* This is different from `updated_at` because that may also change when a photo inside changes or | ||
* is deleted. | ||
*/ | ||
last_collected_at: string; | ||
links: { | ||
self: string; | ||
html: string; | ||
photos: string; | ||
download?: string; | ||
related?: string; | ||
}; | ||
preview_photos: Nullable<Photo.VeryBasic[]>; | ||
published_at: string; | ||
title: string; | ||
total_photos: number; | ||
updated_at: string; | ||
user: User.Basic; | ||
} |
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,93 @@ | ||
import { Nullable } from '../../helpers/typescript'; | ||
import { Entity } from '../../types/entities'; | ||
import * as Collection from '../collections/types'; | ||
import * as User from '../users/types'; | ||
|
||
interface StatValue { | ||
value: number; | ||
date: string; | ||
} | ||
|
||
interface Stat { | ||
total: number; | ||
historical: { | ||
change: number; | ||
quantity: number; | ||
resolution: string; | ||
values: StatValue[]; | ||
}; | ||
} | ||
|
||
export interface Stats extends Entity { | ||
views: Stat; | ||
downloads: Stat; | ||
} | ||
|
||
export interface VeryBasic extends Entity { | ||
created_at: string; | ||
updated_at: string; | ||
urls: { | ||
full: string; | ||
raw: string; | ||
regular: string; | ||
small: string; | ||
thumb: string; | ||
}; | ||
} | ||
|
||
export interface Basic extends VeryBasic { | ||
alt_description: Nullable<string>; | ||
blur_hash: Nullable<string>; | ||
color: Nullable<string>; | ||
description: Nullable<string>; | ||
height: number; | ||
likes: number; | ||
links: { | ||
self: string; | ||
html: string; | ||
download: string; | ||
download_location: string; | ||
}; | ||
promoted_at: Nullable<string>; | ||
width: number; | ||
user: User.Basic; | ||
} | ||
|
||
interface ExifAndLocation { | ||
exif: { | ||
make: Nullable<string>; | ||
model: Nullable<string>; | ||
exposure_time: Nullable<string>; | ||
aperture: Nullable<string>; | ||
focal_length: Nullable<string>; | ||
iso: Nullable<number>; | ||
}; | ||
location: { | ||
city: Nullable<string>; | ||
country: Nullable<string>; | ||
|
||
/** full string representation of the location, including `city` and `country` if they exist. */ | ||
name: Nullable<string>; | ||
|
||
position: { | ||
latitude: Nullable<number>; | ||
longitude: Nullable<number>; | ||
}; | ||
}; | ||
} | ||
|
||
export interface Random extends Basic, ExifAndLocation {} | ||
|
||
type RelatedCollectionsType = | ||
// Ambiguously related collections | ||
| 'related' | ||
// Collections the photo belongs to | ||
| 'collected'; | ||
|
||
export interface Full extends Basic, ExifAndLocation { | ||
related_collections: { | ||
type: RelatedCollectionsType; | ||
results: Collection.Basic[]; | ||
total: number; | ||
}; | ||
} |
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
File renamed without changes.
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,13 @@ | ||
import * as CollectionApi from '../../collections/types'; | ||
import * as PhotoApi from '../../photos/types'; | ||
import * as UserApi from '../../users/types'; | ||
|
||
interface Response<A> { | ||
results: A[]; | ||
total: number; | ||
total_pages: number; | ||
} | ||
|
||
export interface Photos extends Response<PhotoApi.Basic> {} | ||
export interface Collections extends Response<CollectionApi.Basic> {} | ||
export interface Users extends Response<UserApi.Medium> {} |
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 { Nullable } from '../../helpers/typescript'; | ||
import { Entity } from '../../types/entities'; | ||
import * as Photo from '../photos/types'; | ||
|
||
export interface Basic extends Entity { | ||
bio: Nullable<string>; | ||
first_name: string; | ||
instagram_username: Nullable<string>; | ||
last_name: Nullable<string>; | ||
links: { | ||
followers: string; | ||
following: string; | ||
html: string; | ||
likes: string; | ||
photos: string; | ||
portfolio: string; | ||
self: string; | ||
}; | ||
location: Nullable<string>; | ||
name: string; | ||
portfolio_url: Nullable<string>; | ||
profile_image: { | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
total_collections: number; | ||
total_likes: number; | ||
total_photos: number; | ||
twitter_username: Nullable<string>; | ||
updated_at: string; | ||
username: string; | ||
} | ||
|
||
export interface Medium extends Basic { | ||
photos: Photo.VeryBasic[]; | ||
} | ||
|
||
export interface Full extends Medium { | ||
downloads: number; | ||
followers_count: number; | ||
following_count: number; | ||
} |
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,3 @@ | ||
export interface Entity { | ||
id: string; | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.