-
-
Notifications
You must be signed in to change notification settings - Fork 66
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 #3 from bhushankumarl/development
Development
- Loading branch information
Showing
18 changed files
with
198 additions
and
62 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
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
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,22 @@ | ||
'use strict'; | ||
|
||
const clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY'; | ||
const clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; | ||
|
||
const eBay = require('../../../lib/eBay-node-client')(clientId, clientSecret); | ||
|
||
const applicationRequest = async function () { | ||
|
||
try { | ||
const token = await eBay.application.getOAuthToken({ | ||
grant_type: 'client_credentials', | ||
scope: 'https://api.ebay.com/oauth/api_scope' | ||
}); | ||
console.log('token.access_token ', token.access_token); | ||
eBay.setToken(token.access_token); | ||
} catch (error) { | ||
console.log('error ', error); | ||
} | ||
}; | ||
|
||
applicationRequest(); |
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,30 @@ | ||
'use strict'; | ||
|
||
const clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY'; | ||
const clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; | ||
|
||
const eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); | ||
|
||
const browseRequest = async function () { | ||
try { | ||
const token = await eBay.application.getOAuthToken({ | ||
grant_type: 'client_credentials', | ||
scope: 'https://api.ebay.com/oauth/api_scope' | ||
}); | ||
eBay.setToken(token.access_token); | ||
} catch (error) { | ||
console.log('error ', error); | ||
return; | ||
} | ||
|
||
const itemId = 'v1|110329773707|410089528845'; | ||
eBay.browse.getItem(itemId, function (error, response) { | ||
if (error) { | ||
console.log('error ', error); | ||
return; | ||
} | ||
console.log('response', response); | ||
}); | ||
}; | ||
|
||
browseRequest(); |
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,33 @@ | ||
'use strict'; | ||
|
||
var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY'; | ||
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; | ||
|
||
var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); | ||
|
||
var browseRequest = async function () { | ||
try { | ||
var token = await eBay.application.getOAuthToken({ | ||
grant_type: 'client_credentials', | ||
scope: 'https://api.ebay.com/oauth/api_scope' | ||
}); | ||
eBay.setToken(token.access_token); | ||
} catch (error) { | ||
console.log('error ', error); | ||
return; | ||
} | ||
|
||
var data = { | ||
gtin: '010942122258', | ||
limit: '1' | ||
}; | ||
eBay.browse.search(data, function (error, response) { | ||
if (error) { | ||
console.log('error ', error); | ||
return; | ||
} | ||
console.log('response', response); | ||
}); | ||
}; | ||
|
||
browseRequest(); |
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 |
---|---|---|
@@ -1,93 +1,74 @@ | ||
// Type definitions for amazon-mws | ||
// Type definitions for ebay-node-client | ||
|
||
declare class BaseAmazonMWS { | ||
|
||
search(params: any): Promise<any>; | ||
declare class BaseeBayNodeClient { | ||
|
||
} | ||
|
||
declare class Feeds extends BaseAmazonMWS { | ||
declare class Application extends BaseeBayNodeClient { | ||
|
||
submit(params: any): Promise<any>; | ||
getOAuthToken(params: any): Promise<any>; | ||
|
||
} | ||
|
||
declare class Finances extends BaseAmazonMWS { | ||
|
||
} | ||
declare class Browse extends BaseeBayNodeClient { | ||
|
||
declare class FulfillmentInboundShipment extends BaseAmazonMWS { | ||
getItem(itemId: string): Promise<any>; | ||
|
||
create(params: any): Promise<any>; | ||
search(params: any): Promise<any>; | ||
|
||
} | ||
|
||
declare class FulfillmentInventory extends BaseAmazonMWS { | ||
declare class Taxonomy extends BaseeBayNodeClient { | ||
|
||
} | ||
getCategorySubtree(categoryTreeId: string, params: any): Promise<any>; | ||
|
||
declare class FulfillmentOutboundShipment extends BaseAmazonMWS { | ||
getCategorySuggestions(categoryTreeId: string, params: any): Promise<any>; | ||
|
||
} | ||
getItemAspectsForCategory(categoryTreeId: string, params: any): Promise<any>; | ||
|
||
declare class MerchantFulfillment extends BaseAmazonMWS { | ||
getCategoryTree(categoryTreeId: string): Promise<any>; | ||
|
||
create(params: any): Promise<any>; | ||
getDefaultCategoryTreeId(params: any): Promise<any>; | ||
|
||
} | ||
|
||
declare class Orders extends BaseAmazonMWS { | ||
|
||
} | ||
declare class Inventory extends BaseeBayNodeClient { | ||
|
||
declare class Products extends BaseAmazonMWS { | ||
createOrReplaceInventoryItem(sku: string, params: any): Promise<any>; | ||
|
||
searchFor(params: any): Promise<any>; | ||
getInventoryItem(sku: string): Promise<any>; | ||
|
||
getInventoryItems(params: any): Promise<any>; | ||
|
||
} | ||
|
||
declare class Reports extends BaseAmazonMWS { | ||
declare class eBayNodeClient { | ||
|
||
} | ||
application: Application; | ||
|
||
declare class Sellers extends BaseAmazonMWS { | ||
browse: Browse; | ||
|
||
} | ||
taxonomy: Taxonomy; | ||
|
||
declare class AmazonMWS { | ||
inventory: Inventory; | ||
|
||
constructor() | ||
|
||
constructor(key: string, token: string); | ||
constructor(clientId: string, clientSecret: string); | ||
|
||
setApiKey(key: string, secret: string): void; | ||
constructor(clientId: string, clientSecret: string, isSandbox: boolean); | ||
|
||
setHost(host?: string, port?: string, protocol?: string): void; | ||
|
||
feeds: Feeds; | ||
|
||
finances: Finances; | ||
|
||
fulfillmentInboundShipment: FulfillmentInboundShipment; | ||
|
||
fulfillmentInventory: FulfillmentInventory; | ||
setApiKey(clientId: string, clientSecret: string): void; | ||
|
||
fulfillmentOutboundShipment: FulfillmentOutboundShipment; | ||
|
||
merchantFulfillment: MerchantFulfillment; | ||
|
||
orders: Orders; | ||
|
||
products: Products; | ||
|
||
reports: Reports; | ||
setHost(host?: string, port?: string, protocol?: string): void; | ||
|
||
sellers: Sellers; | ||
setToken(applicationToken: string): void; | ||
|
||
setUserToken(userToken: string): void; | ||
} | ||
|
||
|
||
declare namespace AmazonMWS { | ||
declare namespace eBayNodeClient { | ||
|
||
} | ||
export = AmazonMWS; | ||
export = eBayNodeClient; |
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,6 @@ | ||
'use strict'; | ||
module.exports = { | ||
clientId: process.env.EBAY_CLIENT_ID, | ||
clientSecret: process.env.EBAY_CLIENT_SECRET, | ||
USER_TOKEN: process.env.EBAY_USER_TOKEN, | ||
}; |
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,11 @@ | ||
### | ||
### mocha.opts | ||
### | ||
|
||
--bail | ||
--silly | ||
--full-trace | ||
--recursive | ||
--timeout 20000 | ||
--reporter spec | ||
./test/specs/**/*.spec.js |
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,40 @@ | ||
'use strict'; | ||
var config = require('../../intialize/config'); | ||
var clientId = config.clientId; | ||
var clientSecret = config.clientSecret; | ||
|
||
var chai = require('chai'); | ||
var expect = chai.expect; | ||
|
||
var eBay = require('../../../lib/eBay-node-client')(clientId, clientSecret); | ||
|
||
describe('Application', function () { | ||
|
||
before(function () { | ||
expect(clientId).to.be.a('string'); | ||
expect(clientSecret).to.be.a('string'); | ||
}); | ||
|
||
it('It should get Application OAuth Token ', async function () { | ||
var options = { | ||
grant_type: 'client_credentials', | ||
scope: 'https://api.ebay.com/oauth/api_scope' | ||
}; | ||
|
||
expect(options.grant_type).to.be.a('string'); | ||
expect(options.scope).to.be.a('string'); | ||
|
||
try { | ||
var response = await eBay.application.getOAuthToken(options); | ||
eBay.setToken(response.access_token); | ||
expect(response).to.be.a('object'); | ||
expect(response).to.have.property('access_token').to.be.a('string'); | ||
expect(response).to.have.property('expires_in').to.be.a('number'); | ||
expect(response).to.have.property('token_type').to.be.a('string'); | ||
} catch (error) { | ||
console.log('error ', error); | ||
expect(response).to.be.a(undefined); | ||
} | ||
|
||
}); | ||
}); |