Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

allegro

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allegro - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

examples/category/index.js

5

examples/user/index.js
'use strict';
var credentials = require('../credentials.json');
var allegro = require('../../lib/allegro');
var options = {key: '', login: '', password: ''};
allegro.createClient(options, function (err, client) {
allegro.createClient(credentials, function (err, client) {
client.getUser(26729811, function (err, user) {

@@ -8,0 +7,0 @@ console.log(user.login);

2

lib/allegro.js
'use strict';
var _ = require('lodash');
var soap = require('soap');
var soap = require('soap-js');
var Country = require('./country');

@@ -6,0 +6,0 @@ var Client = require('./client');

@@ -79,11 +79,14 @@ 'use strict';

if (!err) {
Object.keys(result.siteJournalArray.item).forEach(function (key) {
var row = result.siteJournalArray.item[key];
if (row.changeType === API_CHANGE_BUYNOW) {
self.emit(event, row.itemId);
}
oldestRowId = row.rowId;
});
for (var i = 0; i < result.siteJournalArray.length; i += 1) {
result.siteJournalArray[i].item.forEach(emitEvent);
}
}
});
function emitEvent(item) {
if (item.changeType === API_CHANGE_BUYNOW) {
self.emit(event, item.itemId);
}
oldestRowId = item.rowId;
}
});

@@ -138,3 +141,3 @@ }, JOURNAL_INTERVAL);

var categories = result.categoryPath[0].item.length;
callback(null, new Category(result.categoryPath[0].item[categories - 1]));
callback(null, new Category(result.categoryPath[0].item[categories - 1], self));
}

@@ -141,0 +144,0 @@ });

'use strict';
function Category(apiCategory) {
function Category(apiCategory, client) {
if (!client) {
throw new Error('Client instance required');
}
this._client = client;
this._id = apiCategory.catId;
this._name = apiCategory.catName;
this._parentId = apiCategory.catParent;
}

@@ -14,2 +21,10 @@

return this._name;
},
get parentId() {
return this._parentId;
},
getParent: function (callback) {
this._client.getCategory(this._parentId, function (err, category) {
callback(err, category);
});
}

@@ -16,0 +31,0 @@ };

{
"name": "allegro",
"version": "0.3.0",
"version": "0.4.0",
"description": "Allegro.pl WebAPI client",

@@ -16,3 +16,3 @@ "keywords": [

"dependencies": {
"soap": "~0.4.5",
"soap-js": "^0.2.11",
"lodash": "~1.3.1"

@@ -19,0 +19,0 @@ },

@@ -58,3 +58,3 @@ # allegro.js

client.getCategory(149, function (error, category) {
console.log(category.name); // 'Samochody'
console.log(category.name); // 'Samochody'
});

@@ -72,3 +72,3 @@ });

client.getItem(3482560106, function (error, item) {
console.log(item.name); // 'IGŁA BMW E90'
console.log(item.name); // 'IGŁA BMW E90'
});

@@ -86,3 +86,3 @@ });

client.getUser(26729811, function (error, user) {
console.log(user.login); // 'stendi_pl'
console.log(user.login); // 'stendi_pl'
});

@@ -110,4 +110,19 @@ });

* ```id``` int,
* ```name``` string.
* ```name``` string,
* ```parentId``` int.
### Methods
* ```getParent(callback)``` get [Category](#category) instance of parent. Callback function gets [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) and [Category](#category) instance. Example:
```
allegro.createClient({ … }, function (err, client) {
client.getCategory(122234, function (err, category) {
category.getParent(function (err, category) {
console.log(category.name);
})
});
});
```
## Item

@@ -130,3 +145,3 @@

item.getSeller(function(error, user) {
console.log(user.login); // 'stendi_pl'
console.log(user.login); // 'stendi_pl'
})

@@ -133,0 +148,0 @@ });

'use strict';
require('should');
var sinon = require('sinon');
var soap = require('soap');
var soap = require('soap-js');
var Client = require('../lib/client');

@@ -170,3 +170,3 @@ var User = require('../lib/model/user');

doGetSiteJournalStub.callsArgWith(1, null, {
siteJournalArray: {
siteJournalArray: [{
item: [{

@@ -177,3 +177,3 @@ rowId: 1,

}]
}
}]
});

@@ -180,0 +180,0 @@

'use strict';
require('should');
var sinon = require('sinon');
var Category = require('../../lib/model/category');
describe('Category model', function () {
it('should return basic info (id, name)', function () {
var item = new Category({
catId: 1,
catName: 'test category'
it('should return basic info (id, name, parentId)', function () {
var category = new Category({
catId: 2,
catName: 'test category',
catParent: 1
}, {});
item.id.should.equal(1);
item.name.should.equal('test category');
category.id.should.equal(2);
category.name.should.equal('test category');
category.parentId.should.equal(1);
});
it('should return parent category', function (done) {
var client = { getCategory: function () {} };
var clientStub = sinon.stub(client, 'getCategory');
clientStub.callsArgWith(1, null, new Category({
catId: 2
}, {}));
var category = new Category({
catId: 2,
catName: 'test category',
catParent: 1
}, client);
category.getParent(function (err, category) {
clientStub.calledOnce.should.equal(true);
clientStub.calledWith(1).should.equal(true);
category.should.be.instanceOf(Category);
done();
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc