Skip to content

API_Documentation

CMaytom edited this page Jun 2, 2020 · 20 revisions

API Reference

Members

API_TOKEN : string

Signed-in member's API key

WORKSPACE : string

Name of the workspace (workspace URL slug, actually) that the signed-in member is a part of

MEMBER_ID : string

Signed-in member's member ID

MEMBER_MAP : object.<string, Member>

Object mapping member ID -> member object. Contains all members

STORIES : Array.<Story>

All stories in the workspace

SETUP : Promise.<void>

A promise to all global variables being initialized; promise that fulfills when all global vars are initialized. Once all global vars are initialized (without errors), all methods can execute correctly.

Functions

fetchFromClubhouse(url, params)Promise.<(Array.<(Project|Story|BasicMember)>|MemberInfo|Error)>

Fetch from a Clubhouse API endpoint. Fetch calls from this method differ from regular fetches in that they send the desired fetch call through a CORS proxy.

fetchMemberInfoAsync(apiToken)Promise.<MemberInfo>

Fetch info about a member

fetchMembersAsync(apiToken)Promise.<Array.<BasicMember>>

Fetch all members in the workspace

validateMember(apiKey)

Validates a potential member using their API key. First, validates their API key by checking with the Clubhouse API. If the API key is valid, stores the member's API key, member ID, name, and workspace in browser storage, then changes window to popup. If the API key is invalid or another error occurs, this method does nothing (TODO).

isComplete(story)boolean

Check if a story is complete

getStories([params])Array.<Story>

Get stories - using optional filters - from the set of all stories in the workspace (STORIES).

getMyIncompleteStories()Array.<Story>

Get incomplete stories that are assigned to the signed-in member

getAllIncompleteStories()Array.<Story>

Get all incomplete stories in the workspace

getTopWarriors()Array.<Contributor>

Get up to top 3 point contributors. If less than 3 members have completed any stories (and have more than 0 points), only return those that do.

getAllMembers()Array.<Member>

Get all team members.

getBattleLog()Array.<Story>

Returns stories in sorted by most recently completed Get stories to show in the battle log - all completed stories sorted by most recently completed.

getMemberName(memberId)string

Get the name of a member

getMemberProfile()MemberDisplay

Get the display info - workspace, name, and display icon - of the signed-in member.

getProgress()Progress

Get the overall progress of stories, in terms of points completed

setup()Promise.<void>

Get the SETUP promise. If SETUP hasn't been initialized yet, create it. Otherwise, return the existing promise - do not recreate/restart it.

signout()

Signout by removing all items from StorageArea storage.sync

toggleMemberMenu()

Show member profile menu

selectTab(tabIndex)

Apply appropriate styles to selected tab and panel item

toggleMembersList()

Toggle members list for honors

honorMember(member)

TODO: Record honoring of member in database

completeStory(story)

TODO: Complete story

Typedefs

Project : object
Story : object
BasicMember : object

Basic (not modified/enhanced by us) member object fetched from Clubhouse

Member : object

BasicMember that we have enhanced with additional attributes (i.e. points)

MemberDisplay : object

Sub-object of BasicMember, with simplified structure

Contributor : object

Sub-object of Member, with simplified structure

MemberInfo : object

Member object, containing workspace info (but less member info than BasicMember), fetched from Clubhouse

Progress : object

API_TOKEN : string

Signed-in member's API key

Kind: global variable

WORKSPACE : string

Name of the workspace (workspace URL slug, actually) that the signed-in member is a part of

Kind: global variable

MEMBER_ID : string

Signed-in member's member ID

Kind: global variable

MEMBER_MAP : object.<string, Member>

Object mapping member ID -> member object. Contains all members

Kind: global variable

STORIES : Array.<Story>

All stories in the workspace

Kind: global variable

SETUP : Promise.<void>

A promise to all global variables being initialized; promise that fulfills when all global vars are initialized. Once all global vars are initialized (without errors), all methods can execute correctly.

Kind: global variable
See: setup

fetchFromClubhouse(url, params) ⇒ Promise.<(Array.<(Project|Story|BasicMember)>|MemberInfo|Error)>

Fetch from a Clubhouse API endpoint. Fetch calls from this method differ from regular fetches in that they send the desired fetch call through a CORS proxy.

Kind: global function
Returns: Promise.<(Array.<(Project|Story|BasicMember)>|MemberInfo|Error)> - If successful, a promise to the requested object. Otherwise, an Error with message equal to the value of:

  • ERR_MSG_INTERNET
  • ERR_MSG_INVALID_API_TOKEN
  • ERR_MSG_CLUBHOUSE_API_QUOTA_EXCEEDED
  • ERR_MSG_UNKNOWN_CLUBHOUSE_RESPONSE
Param Type Description
url string The Clubhouse URL to fetch from
params object Optional parameters to pass to fetch (i.e. headers)

fetchMemberInfoAsync(apiToken) ⇒ Promise.<MemberInfo>

Fetch info about a member

Kind: global function
Returns: Promise.<MemberInfo> - A promise to the member info object

Param Type Description
apiToken string Member's API token

fetchMembersAsync(apiToken) ⇒ Promise.<Array.<BasicMember>>

Fetch all members in the workspace

Kind: global function
Returns: Promise.<Array.<BasicMember>> - A promise to the array of member objects

Param Type Description
apiToken string Member's API token

validateMember(apiKey)

Validates a potential member using their API key. First, validates their API key by checking with the Clubhouse API. If the API key is valid, stores the member's API key, member ID, name, and workspace in browser storage, then changes window to popup. If the API key is invalid or another error occurs, this method does nothing (TODO).

Kind: global function

Param Type Description
apiKey string The API key of the potential member

isComplete(story) ⇒ boolean

Check if a story is complete

Kind: global function
Returns: boolean - True if the story is complete, false otherwise

Param Type Description
story Story Story to check

getStories([params]) ⇒ Array.<Story>

Get stories - using optional filters - from the set of all stories in the workspace (STORIES).

Kind: global function
Returns: Array.<Story> - Stories specified by the filters (if any). If no filters are specified, returns all stories in the workspace (STORIES). If STORIES is null, returns null.

Param Type Default Description
[params] object.<string, boolean> Optional parameter to specify filter flags.
[params.memberOnly] boolean false Flag to only include stories assigned to the signed-in member.
[params.incompleteOnly] boolean false Flag to only include stories that are incomplete.
[params.completeOnly] boolean false Flag to only include stories that are complete.

getMyIncompleteStories() ⇒ Array.<Story>

Get incomplete stories that are assigned to the signed-in member

Kind: global function
Returns: Array.<Story> - Incomplete stories assigned to the signed-in member. If STORIES is null, returns null.
See: getStories

getAllIncompleteStories() ⇒ Array.<Story>

Get all incomplete stories in the workspace

Kind: global function
Returns: Array.<Story> - All incomplete stories in the workspace. If STORIES is null, returns null.
See: getStories

getTopWarriors() ⇒ Array.<Contributor>

Get up to top 3 point contributors. If less than 3 members have completed any stories (and have more than 0 points), only return those that do.

Kind: global function
Returns: Array.<Contributor> - An array of top contributors (max 3). If less than 3 top contributors exist, the returned array will have length less than 3. If there are no top contributors, an empty array is returned.

getAllMembers() ⇒ Array.<Member>

Get all team members.

Kind: global function
Returns: Array.<Member> - Array of all members.

getBattleLog() ⇒ Array.<Story>

Returns stories in sorted by most recently completed Get stories to show in the battle log - all completed stories sorted by most recently completed.

Kind: global function
Returns: Array.<Story> - Stories for battle log. If STORIES is null, returns null

getMemberName(memberId) ⇒ string

Get the name of a member

Kind: global function
Returns: string - Name of the specified member

Param Type Description
memberId string ID of the member to get the name of

getMemberProfile() ⇒ MemberDisplay

Get the display info - workspace, name, and display icon - of the signed-in member.

Kind: global function
Returns: MemberDisplay - The display info of the signed-in member

getProgress() ⇒ Progress

Get the overall progress of stories, in terms of points completed

Kind: global function
Returns: Progress - Completed points and total points

setup() ⇒ Promise.<void>

Get the SETUP promise. If SETUP hasn't been initialized yet, create it. Otherwise, return the existing promise - do not recreate/restart it.

Kind: global function
Returns: Promise.<void> - A promise to all global variables being initialized without error and all methods being ready for execution.
See: SETUP

signout()

Signout by removing all items from StorageArea storage.sync

Kind: global function

toggleMemberMenu()

Show member profile menu

Kind: global function

selectTab(tabIndex)

Apply appropriate styles to selected tab and panel item

Kind: global function

Param Type Description
tabIndex number index of tab

toggleMembersList()

Toggle members list for honors

Kind: global function

honorMember(member)

TODO: Record honoring of member in database

Kind: global function

Param Type Description
member Member Member object that is being honored

completeStory(story)

TODO: Complete story

Kind: global function

Param Type Description
story Story Story that is being completed

Project : object

Kind: global typedef
Properties

Name Type Description
id string ID of the project

Story : object

Kind: global typedef
Properties

Name Type Description
completed boolean Whether the story is completed
completed_at string String representation of the time of completion
estimate number Story point estimate
name string Name of the story
owner_ids Array.<string> Member IDs of members assigned to the story

BasicMember : object

Basic (not modified/enhanced by us) member object fetched from Clubhouse

Kind: global typedef
Properties

Name Type Description
profile object Profile of the member containing personal info
profile.name string Name of the member

Member : object

BasicMember that we have enhanced with additional attributes (i.e. points)

Kind: global typedef
Properties

Name Type Description
points number Total story points completed by the member
profile object Profile of the member containing personal info
profile.name string Name of the member

MemberDisplay : object

Sub-object of BasicMember, with simplified structure

Kind: global typedef
Properties

Name Type Description
workspace string Name of the member's workspace
name name Name of the member
icon string URL of the member's display icon

Contributor : object

Sub-object of Member, with simplified structure

Kind: global typedef
Properties

Name Type Description
name string Name of the contributor (member)
points string Total story points completed by the member

MemberInfo : object

Member object, containing workspace info (but less member info than BasicMember), fetched from Clubhouse

Kind: global typedef
Properties

Name Type Description
name string Name of the member
workspace2 object Info about the member's workspace
workspace2.url_slug string Member's workspace URL slug

Progress : object

Kind: global typedef
Properties

Name Type Description
total number Number of total story points
Clone this wiki locally