-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43f4723
commit 5b949c8
Showing
4 changed files
with
79 additions
and
79 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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
console.log("Get a payload of message inside one one species chat room"); | ||
const env = require('./env'); | ||
const Amino = require('../index'); | ||
(async function () { | ||
const sid = await Amino.login(env.email, env.password); | ||
const myCommunities = await Amino.getJoinedComs(); | ||
const firstCommunity = myCommunities.coms[0]; | ||
const users = await Amino.getComUsers(firstCommunity.id); | ||
console.log(users) | ||
console.log("Get a payload of message inside one one species chat room"); | ||
const env = require('./env'); | ||
const Amino = require('../index'); | ||
(async function () { | ||
const sid = await Amino.login(env.email, env.password); | ||
const myCommunities = await Amino.getJoinedComs(); | ||
const firstCommunity = myCommunities.coms[0]; | ||
const users = await Amino.getComUsers(firstCommunity.id); | ||
console.log(users) | ||
})(); |
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,36 +1,36 @@ | ||
const fetch = require('isomorphic-fetch'); | ||
const endpoints = require('../helpers/endpoints.js'); //For Creating shorter URL's in this Module | ||
const objs = require('../helpers/objects.js'); //For Storing the Objects that the Framework returns. | ||
const { getConfig, errorMessages } = require('../index'); | ||
|
||
/** | ||
* Gets a JSON-Object were all Community ID's, Name's and URL's for the current Logged-In Account are obainted in. | ||
* @param {SecurityString} sid For authenticating with the Narvii-API. | ||
* @returns {Object} Object containing all Joined Coms with the Logged in Account. | ||
*/ | ||
|
||
module.exports = async function getComUsers(communityId) { | ||
let communityUsers = objs.communityUsers; | ||
communityUsers.users = []; | ||
const sid = getConfig('sid'); | ||
if (typeof sid != 'string') { | ||
throw new Error(errorMessages.missingSid); | ||
} | ||
try { | ||
const response = await fetch(endpoints.getComUsers(communityId), { | ||
headers: { | ||
'NDCAUTH': `sid=${sid}` | ||
} | ||
}); | ||
const body = await response.json(); | ||
communityUsers.users = body.userProfileList; | ||
communityUsers.count = body.userProfileCount; | ||
communityUsers.error = null; | ||
communityUsers.status = 'ok'; | ||
} | ||
catch (err) { | ||
communityUsers.error = err; | ||
throw 'Error while calling getComUsers: ' + err; | ||
} | ||
return communityUsers; | ||
const fetch = require('isomorphic-fetch'); | ||
const endpoints = require('../helpers/endpoints.js'); //For Creating shorter URL's in this Module | ||
const objs = require('../helpers/objects.js'); //For Storing the Objects that the Framework returns. | ||
const { getConfig, errorMessages } = require('../index'); | ||
|
||
/** | ||
* Gets a JSON-Object were all Community ID's, Name's and URL's for the current Logged-In Account are obainted in. | ||
* @param {SecurityString} sid For authenticating with the Narvii-API. | ||
* @returns {Object} Object containing all Joined Coms with the Logged in Account. | ||
*/ | ||
|
||
module.exports = async function getComUsers(communityId) { | ||
let communityUsers = objs.communityUsers; | ||
communityUsers.users = []; | ||
const sid = getConfig('sid'); | ||
if (typeof sid != 'string') { | ||
throw new Error(errorMessages.missingSid); | ||
} | ||
try { | ||
const response = await fetch(endpoints.getComUsers(communityId), { | ||
headers: { | ||
'NDCAUTH': `sid=${sid}` | ||
} | ||
}); | ||
const body = await response.json(); | ||
communityUsers.users = body.userProfileList; | ||
communityUsers.count = body.userProfileCount; | ||
communityUsers.error = null; | ||
communityUsers.status = 'ok'; | ||
} | ||
catch (err) { | ||
communityUsers.error = err; | ||
throw 'Error while calling getComUsers: ' + err; | ||
} | ||
return communityUsers; | ||
}; |
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,22 +1,22 @@ | ||
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){ | ||
require('../helpers/loadEnv'); | ||
describe('how the methods should response (With NO false input)', () => { | ||
it('Get the latest blog feed of one specie community', async () => { | ||
const Amino = require('../../index'); | ||
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD); | ||
const myCommunities = await Amino.getJoinedComs(); | ||
const firstCommunity = myCommunities.coms[0]; | ||
const myCommunityBlogFeed = await Amino.getComBlogFeed(firstCommunity.id); | ||
const comments = await Amino.getCommentsPost(firstCommunity.id, myCommunityBlogFeed.blogs[0].blogId); | ||
expect(comments.comments).toBeDefined(); | ||
expect( | ||
Array.isArray(comments.comments) | ||
) | ||
.toBe(true); | ||
expect(comments.status).toBe('ok'); | ||
expect(comments.error).toBeNull(); | ||
}); | ||
}); | ||
}else{ | ||
describe.skip(); | ||
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){ | ||
require('../helpers/loadEnv'); | ||
describe('how the methods should response (With NO false input)', () => { | ||
it('Get the latest blog feed of one specie community', async () => { | ||
const Amino = require('../../index'); | ||
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD); | ||
const myCommunities = await Amino.getJoinedComs(); | ||
const firstCommunity = myCommunities.coms[0]; | ||
const myCommunityBlogFeed = await Amino.getComBlogFeed(firstCommunity.id); | ||
const comments = await Amino.getCommentsPost(firstCommunity.id, myCommunityBlogFeed.blogs[0].blogId); | ||
expect(comments.comments).toBeDefined(); | ||
expect( | ||
Array.isArray(comments.comments) | ||
) | ||
.toBe(true); | ||
expect(comments.status).toBe('ok'); | ||
expect(comments.error).toBeNull(); | ||
}); | ||
}); | ||
}else{ | ||
describe.skip(); | ||
} |
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,15 +1,15 @@ | ||
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){ | ||
require('../helpers/loadEnv'); | ||
describe('how the methods should response (With NO false input)', () => { | ||
it('should post a Blog into a given Community', async () => { | ||
const Amino = require('../../index'); | ||
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD); | ||
const blog = await Amino.postBlog(process.env.AMINO_DEBUG_COMMUNITY, `Debug Testcase ${process.env.TRAVIS_JOB_ID}`, `The Commitname was: ${process.env.TRAVIS_COMMIT} and the Message was: ${process.env.TRAVIS_COMMIT_MESSAGE}`); | ||
expect(blog.blog).toBeDefined(); | ||
expect(blog.status).toBe('ok'); | ||
expect(blog.error).toBeNull(); | ||
}); | ||
}); | ||
}else{ | ||
describe.skip(); | ||
if(process.env.TRAVIS_PULL_REQUEST === 'false' || typeof process.env.TRAVIS_PULL_REQUEST === 'undefined'){ | ||
require('../helpers/loadEnv'); | ||
describe('how the methods should response (With NO false input)', () => { | ||
it('should post a Blog into a given Community', async () => { | ||
const Amino = require('../../index'); | ||
const sid = await Amino.login(process.env.AMINO_EMAIL, process.env.AMINO_PASSWORD); | ||
const blog = await Amino.postBlog(process.env.AMINO_DEBUG_COMMUNITY, `Debug Testcase ${process.env.TRAVIS_JOB_ID}`, `The Commitname was: ${process.env.TRAVIS_COMMIT} and the Message was: ${process.env.TRAVIS_COMMIT_MESSAGE}`); | ||
expect(blog.blog).toBeDefined(); | ||
expect(blog.status).toBe('ok'); | ||
expect(blog.error).toBeNull(); | ||
}); | ||
}); | ||
}else{ | ||
describe.skip(); | ||
} |
5b949c8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AAAAAA i commited wrong, lost all the changes i made!