-
Notifications
You must be signed in to change notification settings - Fork 1
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 #6 from cloudblue/sprint/s158
Sprint/s158
- Loading branch information
Showing
33 changed files
with
2,924 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ node_modules | |
.env | ||
.nyc_output | ||
coverage | ||
docs/build | ||
docs/build | ||
.devcontainer | ||
.vscode |
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,5 @@ | ||
docs | ||
test | ||
coverage | ||
.nyc_output | ||
yarn.lock |
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,2 +1,3 @@ | ||
Sphinx==2.2.1 | ||
Sphinx==1.8.5 | ||
sphinx-js==2.8 | ||
sphinx_rtd_theme==0.4.3 |
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,76 @@ | ||
/** | ||
* This file is part of the Ingram Micro Cloud Blue Connect SDK. | ||
* | ||
* @copyright (c) 2019. Ingram Micro. All Rights Reserved. | ||
*/ | ||
|
||
const BaseService = require('./base'); | ||
|
||
/** | ||
* The ConversationService class provides methods to access the conversations | ||
* endpoint of the Cloud Blue Connect API. | ||
*/ | ||
class ConversationService extends BaseService { | ||
/** | ||
* Retrieves the id of the conversation of request. | ||
* | ||
* @param {string} id The unique request identifier for which retrieve the conversationId. | ||
* | ||
* @returns {string} Conversation ID. | ||
*/ | ||
|
||
async getConversationIdByRequest(id) { | ||
const url = this.addParams('/conversations', { instance_id: id }); | ||
const response = await this.fetch(url); | ||
this.checkResponse(response); | ||
const conv = await response.json(); | ||
if (conv.length === 1) { | ||
return conv[0].id; | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Publish a message in a convesation of the id request. | ||
* | ||
* @param {string} id The unique request identifier for which publish. | ||
* @param {string} msg The message to publish. | ||
* | ||
* @returns {string} An array with the id oof the message. | ||
*/ | ||
async createMessage(id, msg) { | ||
const messageId = await this.getConversationIdByRequest(id); | ||
const url = `/conversations/${messageId}/messages`; | ||
const options = { | ||
method: 'POST', | ||
body: { | ||
text: msg, | ||
}, | ||
}; | ||
const response = await this.fetch(url, options); | ||
await this.checkResponse(response); | ||
return response.json(); | ||
} | ||
|
||
/** | ||
* Get messages of the id request. | ||
* | ||
* @param {string} id The unique request identifier for which publish. | ||
* | ||
* @returns {object} An object with the messages. | ||
*/ | ||
async getMessages(id) { | ||
const conversationId = await this.getConversationIdByRequest(id); | ||
const url = `/conversations/${conversationId}`; | ||
const options = { | ||
method: 'GET', | ||
}; | ||
const response = await this.fetch(url, options); | ||
await this.checkResponse(response); | ||
return response.json(); | ||
} | ||
|
||
|
||
} | ||
|
||
module.exports = ConversationService; |
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,26 @@ | ||
/** | ||
* This file is part of the Ingram Micro Cloud Blue Connect SDK. | ||
* | ||
* @copyright (c) 2019. Ingram Micro. All Rights Reserved. | ||
*/ | ||
|
||
const BaseService = require('./base'); | ||
|
||
/** | ||
* The AccountService class provides methods to access the accounts | ||
* endpoint of the Cloud Blue Connect API. | ||
*/ | ||
class HubService extends BaseService { | ||
/** | ||
* Get a list of tier accounts. | ||
* | ||
* @return {Array} Returns an Array of the Hub object. | ||
*/ | ||
async list() { | ||
const response = await this.fetch('/hubs'); | ||
await this.checkResponse(response); | ||
return response.json(); | ||
} | ||
} | ||
|
||
module.exports = HubService; |
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
Oops, something went wrong.