npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@catapultsports/amsapi

v1.0.5

Published

JavaScript SDK for AMS API

Downloads

9

Readme

Installation

yarn add @catapultsports/amsapi

Peer Dependencies:

  • axios
  • lodash
  • moment-timezone

Usage

import AMSAPI from '@catapultsports/amsapi

let amsApi = new AMSAPI();

getServers()

Returns a list of available servers

Request:

let servers = await amsApi.getServers();

login(username, password, server)

let response = await amsApi.login('[email protected]', 'yourpassword', 'AU DEV SERVER 1');

// Will throw an exception if login fails

Response:

{
    message: response.message,
    id: 4000,
    email: '[email protected]',
    name: 'Example User',
    defaultTeam: 1,
    teams: [1, 2],
    token: bf812324-2a71-40a4-ba48-7eb696565610-sportsmed',
    requires2FA: false,
    passcode: 'required',
    blockLogin: false
}

restoreUser

await amsApi.restoreUser(token, server);

getUserDetails()

let userDetails = await amsApi.getUserDetails();

{
    id: 1,
    firstName: 'User',
    lastName: 'Name',
    email: '[email protected]',
    phone: '0400 000 000' || null,
    address1: '123 Main Street' || null,
    address2: '123 Main Street' || null,
    city: 'Melbourne' || null,
    state: 'Victoria' || null,
    postcode: '3000' || null,
    birthdate: '2000-01-01' || null,
    gender: 'Male' || null, // Male/Female/null
    height: 180 || null,
    weight: 80 || null,
    eulaAccepted: true,
    timezone: 'Australia/Melbourne',
    profileImage: 'https://ams-au-assets.s3.amazonaws.com/ui/missing-profile-v2.23.27.jpg,
    numUnreadItems: 0,
    passcodeStatus: 'disabled', // disabled/optional/required 
    language: 'en',
    defaultTeam: 27,
    teams: [{
        id: 27
        description: 'The team you are a part of',
        name: 'Your Team',
        language: 'en',
        isStaff: false,
        timezone: 'Australia/Brisbane'
    }]
}

updateUserDetails(details)

Accepts partial updates for [firstName, lastName, birthdate, phone, height, weight, gender, timezone, language]

let updatedUserDetails = await amsApi.updateUserDetails({ firstName: 'NewName', weight: 75 });

Gives same response structure as getUserDetails

createEvent(event, ?options)

event = {
    title: 'Event Title', // Required,
    type: 51, // Required
    start: '2019-01-01 01:00:00', // Required. Perspective time. Any valid moment time will work
    end: '2019-01-01 01:00:00', // Required. Perspective time. Any valid moment time will work
    teamId: 27, // Defaults to null (individual context)
    description: 'Event description',
    mandatory: false,
    timezone: 'Australia/Melbourne', // Will default to user timezone if not set
    repeat: 'onceoff', // [onceoff, daily, weekly, monthly, yearly],
    repeatUntil: '2019-01-08 01:00:00', // Only required if repeat is not onceoff,
    repeatDays: {
        monday: false,
        tuesday: false,
        wednesday: false,
        thursday: false,
        friday: false,
        saturday: false,
        sunday: false
    },
    alert: 'none', [none, min5, min15, min30, min60],
    venue: 15,
    attendingUsers: [4184], // Can only invite users of the same team
    attendingGroups: []
}

// Options is not required, and will default to { notifyUsers: false }
options = {
    notifyUsers: false, // whether notifications will be sent to users of the new event, defaults to false
    recurringStart: '2019-01-01 01:00:00', // if creating a recurring event will return all new events between this and recurringEnd
    recurringEnd: '2019-01-08 01:00:00'
}

let createdEvents = await amsApi.createEvent(event);

createdEvents = {
    [event1Id]: { ...event1 },
    [event2Id]: { ...event2 },
    ...
};

deleteEvents(ids)

Takes both arrays and single event/group ids

let response = await amsApi.deleteEvents(ids);

If passing a single id will return a single response object

{
    id: 1
    success: true,
    error: ''
}

If passing an array of ids will return an array of responses

[{
    id: 1
    success: true,
    error: ''
}, {
    id: 'INVALID ID'
    success: false,
    error: 'Invalid event id'
}]

getTests

let tests = await amsApi.getTests();
{
    [testId]: {
        id: 1
        name: 'Test Title',
        description: 'Test description',
        createdAt: '2019-01-01 00:00:00',
        updatedAt: '2019-01-01 00:00:00',
        canSubmit: true, // Whether the user can submit a test as themselves
        teams: {
            [teamId]: {
                canView: true, // Whether the team allows viewing this test
                canSubmitForOthers: false // Whether the user can submit a test as a different user
            }
        },
        groups: [{ // A section of a test
            id: 1,
            name: 'Group name',
            description: 'Group description',
            elements: [{ // An item/question of a test
                id: 1,
                name: 'Is this a question?',
                description: 'Please chooose an answer',
                type: 'string', // ['date', 'select', 'number', 'string', 'timer', 'range', 'time', 'boolean', 'url'],
                unit: 'Date', // Free text unit description
                items: [{ // Items used in select, range
                    label: 'Item 1',
                    value: 'item_1'
                }],
                validators: {
                    required: false, // Always included
                    min: 0.5, // Only for type 'number'
                    max: 10, // Only for type 'number'
                    dateMustBeFuture: false, // Only for type 'date'. Always included
                    dateMustBePast: false, // Only for type 'date'. Always included
                    type: 'string', ['string', 'number'] // The required value type
                }
            }]
        }]
    }
}

Underlying API

The underlaying api (https://ams-au-live.catapultsports.com/api/v4/docs) is available to be called directly if needed.

Calls not requiring login or restoreUser:

  • getServers()
  • resetPassword(host, email)
  • login(username, password, hostname)
  • restoreUser(token, hostname)

v1 calls:

  • login
  • getUserDetails
  • updateUserDetails
let amsApi = new AMSAPI();
let v1Api = amsApi.api.v1;
let v4Api = amsApi.api.v4;