mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-28 12:43:06 +08:00
Test suite for Pinterest SDK
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/// <reference path="pinterest-sdk.d.ts" />
|
||||
|
||||
const PIN_FIELDS = "id,name,image[small]";
|
||||
const PIN_SCOPE = "read_public, write_public";
|
||||
const CALLBACK = (...args: any[]) => {};
|
||||
const DATA = { board: "test", note: "test", link: "tets", image_url: "test" };
|
||||
|
||||
// Examples from https://github.com/pinterest/pinterest-api-demo
|
||||
|
||||
// Auth
|
||||
PDK.login({ scope : PIN_SCOPE }, CALLBACK);
|
||||
PDK.logout();
|
||||
PDK.getSession();
|
||||
|
||||
// Requests
|
||||
PDK.request("/pins/", "POST", DATA, CALLBACK);
|
||||
PDK.me("boards", { fields: PIN_FIELDS }, CALLBACK);
|
||||
Vendored
+10
-7
@@ -1,9 +1,13 @@
|
||||
// Type definitions for pinterest-sdk
|
||||
// Project:
|
||||
// Project: https://assets.pinterest.com/sdk/sdk.js
|
||||
// Definitions by: Adam Burmister <https://github.com/adamburmister>
|
||||
// Definitions: https://github.com/adamburmister/DefinitelyTyped
|
||||
declare module PDK {
|
||||
|
||||
enum OAuthScopes { 'read_public', 'write_public', 'read_relationships', 'write_relationships' }
|
||||
|
||||
enum HttpMethod { 'get', 'put', 'post', 'delete' }
|
||||
|
||||
type OauthSession = {
|
||||
accessToken?: string;
|
||||
scope?: string;
|
||||
@@ -11,6 +15,7 @@ declare module PDK {
|
||||
}
|
||||
|
||||
interface LoginOptions {
|
||||
scope: string|OAuthScopes;
|
||||
method?: string;
|
||||
appId?: string;
|
||||
cookie?: boolean;
|
||||
@@ -31,8 +36,6 @@ declare module PDK {
|
||||
session?: OauthSession;
|
||||
}
|
||||
|
||||
enum HttpMethod { 'get', 'put', 'post', 'delete' }
|
||||
|
||||
/**
|
||||
* Get information on the currently authenticated user
|
||||
* @param path the url path
|
||||
@@ -61,7 +64,7 @@ declare module PDK {
|
||||
*
|
||||
* Need to call login to re-connect, unless session is saved on server.
|
||||
*/
|
||||
export function logout(callback: (session: OauthSession) => any): void;
|
||||
export function logout(callback?: (session: OauthSession) => any): void;
|
||||
|
||||
/**
|
||||
* Get the active session for the current user
|
||||
@@ -118,9 +121,9 @@ declare module PDK {
|
||||
/**
|
||||
* Allow an unauthenticated user to pin using a popup
|
||||
*
|
||||
* @param imageUrl URL for image being pinned
|
||||
* @param note description for pin
|
||||
* @param url url where pin is from
|
||||
* @param imageUrl URL for image that you want to Pin.
|
||||
* @param note The Pin's description.
|
||||
* @param url The URL the Pin will link to when you click through.
|
||||
*/
|
||||
export function pin(imageUrl: string, note: string, url: string, callback: Function): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user