diff --git a/pinterest-sdk/pinterest-sdk-tests.ts b/pinterest-sdk/pinterest-sdk-tests.ts new file mode 100644 index 000000000..0c0f9a934 --- /dev/null +++ b/pinterest-sdk/pinterest-sdk-tests.ts @@ -0,0 +1,17 @@ +/// + +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); diff --git a/pinterest-sdk/pinterest-sdk.d.ts b/pinterest-sdk/pinterest-sdk.d.ts index 2c7b32b0d..6c9d48493 100644 --- a/pinterest-sdk/pinterest-sdk.d.ts +++ b/pinterest-sdk/pinterest-sdk.d.ts @@ -1,9 +1,13 @@ // Type definitions for pinterest-sdk -// Project: +// Project: https://assets.pinterest.com/sdk/sdk.js // Definitions by: Adam Burmister // 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; }