Commit 1da3454e authored by Evgeniy Zaitsev's avatar Evgeniy Zaitsev
Browse files

v0.0.14

parent f81c228f
...@@ -25,6 +25,7 @@ class SDK { ...@@ -25,6 +25,7 @@ class SDK {
constructor(config) { constructor(config) {
this.server = koa(); this.server = koa();
this.config = config; this.config = config;
this.logger = logger;
validate(this.server); validate(this.server);
...@@ -40,7 +41,7 @@ class SDK { ...@@ -40,7 +41,7 @@ class SDK {
this.server.context.tablesNames = tablesNames; this.server.context.tablesNames = tablesNames;
this.server.context.db = mysql.createConnection(this.config.mySql); this.server.context.db = mysql.createConnection(this.config.mySql);
this.server.context.logger = logger; this.server.context.logger = this.logger;
this.server.context.config = this.config; this.server.context.config = this.config;
this.server.context.throwResponseErrorIfNeed = throwResponseErrorIfNeed.bind(this.server.context); this.server.context.throwResponseErrorIfNeed = throwResponseErrorIfNeed.bind(this.server.context);
...@@ -52,32 +53,46 @@ class SDK { ...@@ -52,32 +53,46 @@ class SDK {
} }
fetchPrivateListings(feedEndpoint, projectFeedUUID) { fetchPrivateListings(feedEndpoint, projectFeedUUID) {
this.logger.log('fetch private listings', feedEndpoint, projectFeedUUID);
return this._fetchPrivateFeed('privateListings', feedEndpoint, projectFeedUUID); return this._fetchPrivateFeed('privateListings', feedEndpoint, projectFeedUUID);
} }
fetchPrivateLatestResultsByEventFeedUUID(feedEndpoint, eventFeedUUID) { fetchPrivateLatestResultsByEventFeedUUID(feedEndpoint, eventFeedUUID) {
this.logger.log('fetch private latest result by event feed uuid', feedEndpoint, eventFeedUUID);
return this._fetchPrivateFeed('privateLatestResults', feedEndpoint, eventFeedUUID); return this._fetchPrivateFeed('privateLatestResults', feedEndpoint, eventFeedUUID);
} }
fetchPrivateAllPublishedElementsByEventFeedUUID(feedEndpoint, eventFeedUUID) { fetchPrivateAllPublishedElementsByEventFeedUUID(feedEndpoint, eventFeedUUID) {
this.logger.log('fetch private all publish elements by event feed uuid', feedEndpoint, eventFeedUUID);
return this._fetchPrivateFeed('privateAllPublishedElements', feedEndpoint, eventFeedUUID); return this._fetchPrivateFeed('privateAllPublishedElements', feedEndpoint, eventFeedUUID);
} }
fetchPrivateAllElementsByEventFeedUUID(feedEndpoint, eventFeedUUID) { fetchPrivateAllElementsByEventFeedUUID(feedEndpoint, eventFeedUUID) {
this.logger.log('fetch private all elements by event feed uuid', feedEndpoint, eventFeedUUID);
return this._fetchPrivateFeed('privateAllElements', feedEndpoint, eventFeedUUID); return this._fetchPrivateFeed('privateAllElements', feedEndpoint, eventFeedUUID);
} }
fetchPrivateLatestResultsByEventId(feedEndpoint, projectFeedUUID, eventId) { fetchPrivateLatestResultsByEventId(feedEndpoint, projectFeedUUID, eventId) {
this.logger.log('fetch private latest result by event uuid', feedEndpoint, eventId);
return this._fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId) return this._fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId)
.then(eventFeedUUID => this.fetchPrivateLatestResultsByEventFeedUUID(feedEndpoint, eventFeedUUID)); .then(eventFeedUUID => this.fetchPrivateLatestResultsByEventFeedUUID(feedEndpoint, eventFeedUUID));
} }
fetchPrivateAllPublishedElementsByEventId(feedEndpoint, projectFeedUUID, eventId) { fetchPrivateAllPublishedElementsByEventId(feedEndpoint, projectFeedUUID, eventId) {
this.logger.log('fetch private all publish elements by event uuid', feedEndpoint, eventId);
return this._fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId) return this._fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId)
.then(eventFeedUUID => this.fetchPrivateAllPublishedElementsByEventFeedUUID(feedEndpoint, eventFeedUUID)); .then(eventFeedUUID => this.fetchPrivateAllPublishedElementsByEventFeedUUID(feedEndpoint, eventFeedUUID));
} }
fetchPrivateAllElementsByEventId(feedEndpoint, projectFeedUUID, eventId) { fetchPrivateAllElementsByEventId(feedEndpoint, projectFeedUUID, eventId) {
this.logger.log('fetch private all elements by event uuid', feedEndpoint, eventId);
return this._fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId) return this._fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId)
.then(eventFeedUUID => this.fetchPrivateAllElementsByEventFeedUUID(feedEndpoint, eventFeedUUID)); .then(eventFeedUUID => this.fetchPrivateAllElementsByEventFeedUUID(feedEndpoint, eventFeedUUID));
} }
...@@ -112,8 +127,11 @@ class SDK { ...@@ -112,8 +127,11 @@ class SDK {
} }
_fetchPrivateFeed(feedName, feedEndpoint, feedUUID) { _fetchPrivateFeed(feedName, feedEndpoint, feedUUID) {
return fetch(lvisEndpoints[feedName](feedEndpoint, this.config.feedVersion, feedUUID)) const url = lvisEndpoints[feedName](feedEndpoint, this.config.feedVersion, feedUUID);
.then(res => res.json());
this.logger.log('fetch private feed', url);
return fetch(url).then(res => res.json());
} }
_fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId) { _fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId) {
......
{ {
"name": "service-sdk", "name": "service-sdk",
"version": "0.0.12", "version": "0.0.13",
"private": true, "private": true,
"description": "Service SDK for LViS", "description": "Service SDK for LViS",
"keywords": [], "keywords": [],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment