teamcowboy
Usage
Install the teamcowboy
module from npm.
npm install teamcowboy --save
Initialize the teamcowboy
module by calling it with your Team Cowboy API credentials, in return you'll get an initialized api module (exported as a JavaScript object) that you can then use to interact with the Team Cowboy API.
const teamcowboyApi = require('teamcowboy')({
privateKey: 'xxx',
publicKey: 'xxx',
});
The teamcowboy
JavaScript wrapper is divided by module after initialization. Each method accepts a single argument, which should be a JavaScript object with key/values that map directly to the parameters accepted by the Team Cowboy API for the specific method being called. Method calls will return a JavaScript promise.
const {
auth,
events,
message,
team,
user,
} = teamcowboyApi;
Method calls will return a JavaScript promise. Here is an example that uses the teamcowboy
library to get a user token, which then takes the token and makes another request to get teams for the user.
auth.getUserToken({
username: 'my@email.com',
password: 'p@ssw0rd',
}).then(res => {
user.getTeams({ userToken: res.body.token})
.then(resp => {console.log(resp)})
.catch(err => {console.log(err)})
}).catch(err => {
console.log(err);
});
Team Cowboy method mapping
Authentication Methods
-
Auth_GetUserToken ->
auth.getUserToken()
Event Methods
Since event is a reserved word in JavaScript, this module has been named events
-
Event_Get ->
events.get()
-
Event_GetAttendanceList ->
events.getAttendanceList()
-
Event_SaveRSVP ->
events.saveRSVP()
Message Methods
-
Message_Get ->
message.get()
-
Message_Delete ->
message.del()
-
Message_Save ->
message.save()
-
MessageComment_Delete ->
message.deleteComment()
-
MessageComment_Add ->
message.addComment()
Team Methods
-
Team_Get ->
team.get()
-
Team_GetEvents ->
team.getEvents()
-
Team_GetMessages ->
team.getMessages()
-
Team_GetRoster ->
team.getRoster()
-
Team_GetSeasons ->
team.getSeasons()
User Methods
-
User_Get ->
user.get()
-
User_GetNextTeamEvent ->
user.getNextTeamEvent()
-
User_GetTeamEvents ->
user.getTeamEvents()
-
User_GetTeamMessages ->
user.getTeamMessages()
-
User_GetTeams ->
user.getTeams()