mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
add types for amapa (#20393)
This commit is contained in:
committed by
Wesley Wigham
parent
e1228267bb
commit
d9ca7d7eff
@@ -3,7 +3,7 @@ declare var process: { env: any };
|
||||
|
||||
import amazon = require('amazon-product-api');
|
||||
|
||||
var client = amazon.createClient({
|
||||
let client = amazon.createClient({
|
||||
awsId: process.env.AWS_ACCESS_KEY_ID,
|
||||
awsSecret: process.env.AWS_SECRET,
|
||||
awsTag: process.env.AWS_ASSOCIATE_TAG
|
||||
@@ -12,7 +12,7 @@ var client = amazon.createClient({
|
||||
|
||||
// Item Search
|
||||
|
||||
var searchQuery = {
|
||||
let searchQuery = {
|
||||
director: 'Quentin Tarantino',
|
||||
actor: 'Samuel L. Jackson',
|
||||
searchIndex: 'DVD',
|
||||
@@ -37,11 +37,11 @@ client.itemSearch(searchQuery, (err, results) => {
|
||||
|
||||
// Item Lookup
|
||||
|
||||
var lookupQuery = {
|
||||
let lookupQuery = {
|
||||
itemId: 'B00008OE6I',
|
||||
idType: 'ASIN',
|
||||
responseGroup: 'OfferFull',
|
||||
Condition: 'All'
|
||||
condition: 'All'
|
||||
};
|
||||
|
||||
client.itemLookup(lookupQuery).then((results) => {
|
||||
@@ -58,9 +58,22 @@ client.itemLookup(lookupQuery, (err, results) => {
|
||||
console.log(getResultCount(results) + " lookup results");
|
||||
});
|
||||
|
||||
let lookupQueryWithItemIdArray = {
|
||||
itemId: ['B00008OE6I', 'B00008OE6E'],
|
||||
idType: 'ASIN',
|
||||
responseGroup: 'OfferFull',
|
||||
condition: 'All'
|
||||
};
|
||||
|
||||
client.itemLookup(lookupQueryWithItemIdArray).then((results) => {
|
||||
console.log(getResultCount(results) + " lookup results");
|
||||
}).catch(function(err){
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
// Browse Node Lookup
|
||||
|
||||
var nodeLookupQuery = {
|
||||
let nodeLookupQuery = {
|
||||
browseNodeId: '2625373011'
|
||||
};
|
||||
|
||||
@@ -81,4 +94,4 @@ client.browseNodeLookup(nodeLookupQuery, (err, results) => {
|
||||
|
||||
function getResultCount(results: Object[]) {
|
||||
return results != undefined ? results.length : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+29
-4
@@ -1,6 +1,6 @@
|
||||
// Type definitions for amazon-product-api
|
||||
// Project: https://github.com/t3chnoboy/amazon-product-api
|
||||
// Definitions by: Matti Lehtinen <https://github.com/MattiLehtinen>
|
||||
// Definitions by: Matti Lehtinen <https://github.com/MattiLehtinen>, Alex Leon <https://github.com/alien35>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -15,10 +15,35 @@ interface IAmazonProductQueryCallback {
|
||||
(err: string, results: Object[]): void;
|
||||
}
|
||||
|
||||
interface IItemSearchOptions {
|
||||
condition?: string;
|
||||
keywords?: string;
|
||||
responseGroup?: string;
|
||||
searchIndex?: string;
|
||||
itemPage?: number;
|
||||
sort?: string;
|
||||
}
|
||||
|
||||
interface IItemLookupOptions {
|
||||
condition?: string;
|
||||
idType?: string;
|
||||
includeReviewsSummary?: boolean;
|
||||
itemId?: string | string[];
|
||||
responseGroup?: string;
|
||||
searchIndex?: string;
|
||||
truncateReviewsAt?: number;
|
||||
variationPage?: string;
|
||||
}
|
||||
|
||||
interface IBrowseNodeLookupOptions {
|
||||
browseNodeId?: string;
|
||||
responseGroup?: string;
|
||||
}
|
||||
|
||||
interface IAmazonProductClient {
|
||||
itemSearch(query: any, callback?: IAmazonProductQueryCallback): Promise<Object[]>;
|
||||
itemLookup(query: any, callback?: IAmazonProductQueryCallback): Promise<Object[]>;
|
||||
browseNodeLookup(query: any, callback?: IAmazonProductQueryCallback): Promise<Object[]>;
|
||||
itemSearch(query: IItemSearchOptions, callback?: IAmazonProductQueryCallback): Promise<Object[]>;
|
||||
itemLookup(query: IItemLookupOptions, callback?: IAmazonProductQueryCallback): Promise<Object[]>;
|
||||
browseNodeLookup(query: IBrowseNodeLookupOptions, callback?: IAmazonProductQueryCallback): Promise<Object[]>;
|
||||
}
|
||||
|
||||
export declare function createClient(credentials: ICredentials): IAmazonProductClient;
|
||||
|
||||
Reference in New Issue
Block a user