mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #3981 from lukewestby/master
Add typings for Imgur API
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/// <reference path="imgur-rest-api.d.ts" />
|
||||
|
||||
function testAccount(account: ImgurRestApi.Account) : ImgurRestApi.Account {
|
||||
return account;
|
||||
}
|
||||
|
||||
function testAccountSettings(accountSettings: ImgurRestApi.AccountSettings) : ImgurRestApi.AccountSettings {
|
||||
return accountSettings;
|
||||
}
|
||||
|
||||
function testAlbum(album: ImgurRestApi.Album) : ImgurRestApi.Album {
|
||||
return album;
|
||||
}
|
||||
|
||||
function testAlbumImages(album: ImgurRestApi.Album) : ImgurRestApi.Image {
|
||||
return album.images[0];
|
||||
}
|
||||
|
||||
function testComment(comment: ImgurRestApi.Comment) : ImgurRestApi.Comment {
|
||||
return comment;
|
||||
}
|
||||
|
||||
function testConversation(conversation: ImgurRestApi.Conversation) : ImgurRestApi.Conversation {
|
||||
return conversation;
|
||||
}
|
||||
|
||||
function testCustomGallery(customGallery: ImgurRestApi.CustomGallery) : ImgurRestApi.CustomGallery {
|
||||
return customGallery;
|
||||
}
|
||||
|
||||
function testGalleryItem(galleryItem: ImgurRestApi.GalleryItem) : ImgurRestApi.GalleryItem {
|
||||
return galleryItem;
|
||||
}
|
||||
|
||||
function testGalleryAlbum(galleryItem: ImgurRestApi.GalleryItem) : ImgurRestApi.GalleryAlbum {
|
||||
if(galleryItem.is_album) {
|
||||
var galleryAlbum = <ImgurRestApi.GalleryAlbum> galleryItem;
|
||||
return galleryAlbum;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function testGalleryImage(galleryItem: ImgurRestApi.GalleryItem) : ImgurRestApi.GalleryImage {
|
||||
if(!galleryItem.is_album) {
|
||||
var galleryImage = <ImgurRestApi.GalleryImage> galleryItem;
|
||||
return galleryImage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function testGalleryProfile(galleryProfile: ImgurRestApi.GalleryProfile) : ImgurRestApi.GalleryProfile {
|
||||
return galleryProfile;
|
||||
}
|
||||
|
||||
function testImage(image: ImgurRestApi.Image) : ImgurRestApi.Image {
|
||||
return image;
|
||||
}
|
||||
|
||||
function testMemeMeta(meta: ImgurRestApi.MemeMetadata) : ImgurRestApi.MemeMetadata {
|
||||
return meta;
|
||||
}
|
||||
|
||||
function testMessage(message: ImgurRestApi.Message) : ImgurRestApi.Message {
|
||||
return message;
|
||||
}
|
||||
|
||||
function testAccountNotificationsReply(accountNotif: ImgurRestApi.AccountNotifications) : ImgurRestApi.Notification<ImgurRestApi.Comment> {
|
||||
return accountNotif.replies[0];
|
||||
}
|
||||
|
||||
function testAccountNotificationsMessage(accountNotif: ImgurRestApi.AccountNotifications) : ImgurRestApi.Notification<ImgurRestApi.Conversation> {
|
||||
return accountNotif.messages[0];
|
||||
}
|
||||
|
||||
function testTag(tag: ImgurRestApi.Tag) : ImgurRestApi.Tag {
|
||||
return tag;
|
||||
}
|
||||
|
||||
function testTagVote(tagVote: ImgurRestApi.TagVote) : ImgurRestApi.TagVote {
|
||||
return tagVote;
|
||||
}
|
||||
|
||||
function testTopic(topic: ImgurRestApi.Topic) : ImgurRestApi.Topic {
|
||||
return topic;
|
||||
}
|
||||
|
||||
function testVote(vote: ImgurRestApi.Vote) : ImgurRestApi.Vote {
|
||||
return vote;
|
||||
}
|
||||
|
||||
function testResponseWithError(response: ImgurRestApi.Response<ImgurRestApi.GalleryProfile>) : ImgurRestApi.Error {
|
||||
if(response.success === false) {
|
||||
return <ImgurRestApi.Error> response.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function testResponseWithValue(response: ImgurRestApi.Response<ImgurRestApi.GalleryProfile>) : ImgurRestApi.GalleryProfile {
|
||||
if(response.success === true) {
|
||||
return <ImgurRestApi.GalleryProfile> response.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Vendored
+252
@@ -0,0 +1,252 @@
|
||||
// Type definitions for Imgur REST API v3
|
||||
// Project: https://api.imgur.com/
|
||||
// Definitions by: Luke William Westby <http://github.com/lukewestby>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module ImgurRestApi {
|
||||
|
||||
interface Response<T> {
|
||||
data: any; //T|Error;
|
||||
status: number;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
interface Account {
|
||||
id: number;
|
||||
url: string;
|
||||
bio: string;
|
||||
reputation: number;
|
||||
created: number;
|
||||
pro_expiration: any; //number|boolean;
|
||||
}
|
||||
|
||||
interface AccountSettings {
|
||||
email: string;
|
||||
high_quality: boolean;
|
||||
public_images: boolean;
|
||||
album_privacy: string;
|
||||
pro_expiration: any; //number|boolean;
|
||||
accepted_gallery_terms: boolean;
|
||||
active_emails: Array<string>;
|
||||
messaging_enabled: boolean;
|
||||
blocked_users: Array<BlockedUser>;
|
||||
}
|
||||
|
||||
interface Album {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
datetime: number;
|
||||
cover: string;
|
||||
cover_width: number;
|
||||
cover_height: number;
|
||||
account_url?: string;
|
||||
account_id?: number;
|
||||
privacy: string;
|
||||
layout: string;
|
||||
views: number;
|
||||
link: string;
|
||||
favorite: boolean;
|
||||
nsfw?: boolean;
|
||||
section: string;
|
||||
order: number;
|
||||
deletehash?: string;
|
||||
images_count: number;
|
||||
images: Array<Image>;
|
||||
}
|
||||
|
||||
interface BlockedUser {
|
||||
blocked_id: number;
|
||||
blocked_url: string;
|
||||
}
|
||||
|
||||
interface Comment {
|
||||
id: number;
|
||||
image_id: string;
|
||||
comment: string;
|
||||
author: string;
|
||||
author_id: number;
|
||||
on_album: boolean;
|
||||
album_cover: string;
|
||||
ups: number;
|
||||
downs: number;
|
||||
points: number;
|
||||
datetime: number;
|
||||
parent_id: number;
|
||||
deleted: boolean;
|
||||
vote?: string;
|
||||
children: Array<Comment>
|
||||
}
|
||||
|
||||
interface Conversation {
|
||||
id: number;
|
||||
last_message_preview: string;
|
||||
datetime: number;
|
||||
with_account_id: number;
|
||||
with_account: string;
|
||||
message_count: number;
|
||||
messages?: Array<Message>;
|
||||
done?: boolean;
|
||||
page?: number;
|
||||
}
|
||||
|
||||
interface CustomGallery {
|
||||
account_url: string;
|
||||
link: string;
|
||||
tags: Array<string>
|
||||
item_count: number;
|
||||
items: Array<GalleryItem>;
|
||||
}
|
||||
|
||||
interface GalleryItem {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
datetime: number;
|
||||
account_url?: string;
|
||||
account_id?: number;
|
||||
ups: number;
|
||||
downs: number;
|
||||
score: number;
|
||||
is_album: boolean;
|
||||
views: number;
|
||||
link: string;
|
||||
vote?: string;
|
||||
favorite: boolean;
|
||||
nsfw?: boolean;
|
||||
comment_count: number;
|
||||
topic: string;
|
||||
topic_id: number;
|
||||
}
|
||||
|
||||
interface GalleryAlbum extends GalleryItem {
|
||||
cover: string;
|
||||
cover_width: number;
|
||||
cover_height: number;
|
||||
privacy: string;
|
||||
layout: string;
|
||||
images_count: number;
|
||||
images: Array<Image>;
|
||||
}
|
||||
|
||||
interface GalleryImage extends GalleryItem {
|
||||
type: string;
|
||||
animated: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
size: number;
|
||||
bandwidth: number;
|
||||
deletehash?: string;
|
||||
gifv?: string;
|
||||
mp4?: string;
|
||||
webm?: string;
|
||||
looping?: boolean;
|
||||
section: string;
|
||||
}
|
||||
|
||||
interface GalleryProfile {
|
||||
total_gallery_comments: number;
|
||||
total_gallery_favorites: number;
|
||||
total_gallery_submissions: number;
|
||||
trophies: Array<Trophy>;
|
||||
}
|
||||
|
||||
interface Trophy {
|
||||
id: number;
|
||||
name: string;
|
||||
name_clean: string;
|
||||
description: string;
|
||||
data: string;
|
||||
data_link: string;
|
||||
datetime: number;
|
||||
image: string;
|
||||
}
|
||||
|
||||
interface Image {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
datetime: number;
|
||||
type: string;
|
||||
animated: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
size: number;
|
||||
views: number;
|
||||
bandwidth: number;
|
||||
deletehash?: string;
|
||||
name?: string;
|
||||
section: string;
|
||||
link: string;
|
||||
gifv?: string;
|
||||
mp4?: string;
|
||||
webm?: string;
|
||||
looping?: boolean;
|
||||
vote?: string;
|
||||
favorite: boolean;
|
||||
nsfw?: boolean;
|
||||
account_url?: string;
|
||||
account_id?: number;
|
||||
}
|
||||
|
||||
interface MemeMetadata {
|
||||
meme_name: string;
|
||||
top_text: string;
|
||||
bottom_text: string;
|
||||
bg_image: string;
|
||||
}
|
||||
|
||||
interface Message {
|
||||
id: number;
|
||||
from: string;
|
||||
account_id: number;
|
||||
sender_id: number;
|
||||
body: string;
|
||||
conversation_id: number;
|
||||
datetime: number;
|
||||
}
|
||||
|
||||
interface Notification<T> {
|
||||
id: number;
|
||||
account_id: number;
|
||||
viewed: boolean;
|
||||
content: T;
|
||||
}
|
||||
|
||||
interface AccountNotifications {
|
||||
replies: Array<Notification<Comment>>;
|
||||
messages: Array<Notification<Conversation>>;
|
||||
}
|
||||
|
||||
interface Tag {
|
||||
name: string;
|
||||
followers: number;
|
||||
total_items: number;
|
||||
following?: boolean;
|
||||
items: Array<GalleryItem>
|
||||
}
|
||||
|
||||
interface TagVote {
|
||||
ups: number;
|
||||
downs: number;
|
||||
name: string;
|
||||
author: string;
|
||||
}
|
||||
|
||||
interface Topic {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
interface Vote {
|
||||
ups: number;
|
||||
downs: number;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
error: string;
|
||||
request: string;
|
||||
method: string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user