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

@liberatos/strava.js

v1.1.2

Published

Simple API wrapper for strava.cz

Downloads

5

Readme

strava.js

Simple and intuitive client for communication with strava.cz API.

Installation

You need Node and NPM (Node Package Manager)

npm install @liberatos/strava.js

How to start

Create new strava.js client

  const client = new Client(username, password, code, options)
  
  client.login((sessionId) => {
    console.log(`Logged in with sessionId: ${sessionId}`)
  })

| Parameter | Type | Required | Description | | :-------- | :------- | :-------: | :------------------------- | | username | string | Yes | Strava.cz credentials (username) | | password | string | Yes | Strava.cz credentials (password) | | code | number | Yes | Code of canteen | | options | ClientOptions | No | Custom client settings |

ClientOptions

| Parameter | Type | Default | Description | | :-------- | :------- | :-------: | :------------------------- | | refreshSession | boolean | false | Automatically renews the session if it expires | | autoSave | boolean | false | Saves orders immediately after changing |

Features

The strava.js client provides several methods for retrieving or modifying data. Most of them are asynchronous.

  • login(callback)
  • logout()
  • getOverpayment()
  • getOrders()
  • getDispensings()
  • getPayments()
  • getMessages()
  • changeOrder(orderId, mealId, state)
  • changeOrders(changes)
  • saveOrders(orders)

async login(callback): Promise

Calling the method is necessary before using other client functions that require user authorization. If the login is successful, it returns the sessionId. Similarly, the callback function will be called with the parameter of the retrieved sessionId, if specified.

async logout(): Promise

This method invalidates the sessionId, thus logging the user out. Returns void.

Authorization is required for use

async getOverpayment(): Promise

Returns the current overpayment on the user's account.

Authorization is required for use

async getOrders(): Promise<Order[]>

Returns all available user's orders and meals.

Authorization is required for use

async getDispensings(): Promise<Dispensing[]>

Returns available order dispensing history.

Authorization is required for use

async getPayments(): Promise<Payment[]>

Returns the payment history of the user's account (top-ups).

Authorization is required for use

async getMessages(): Promise<Message[]>

Returns messages that have been sent to the user. Currently only general information about the message can be retrieved, content is not supported for now.

Authorization is required for use

async changeOrder(orderId, mealId, state): Promise<Order[]>

Returns a modified array of orders as requested. The method has validation implemented, so you can't have two types of meals logged per order. If you try to log two meals, the originally logged meal will be checked out. If you can no longer change the status of the order, you will receive an error. Only one order can be edited at a time using this method.

If autoSave is enabled, the change will be automatically saved on the server - otherwise you have to save it manually.

  const modified = await client.changeOrder(1672500000, 1, true)

Authorization is required for use

async changeOrders(changes): Promise<Order[]>

This method is identical to the previous one, but you can change multiple orders at once.

  const changes: ChangeMealOptions[] = [
    { orderId: 1672500000, mealId: 1, state: false },
    { orderId: 1662430000, mealId: 2, state: false },
    { orderId: 1663800000, mealId: 1, state: true }
  ]

  const modified = await client.changeOrders(changes)

Authorization is required for use

async saveOrders(orders): Promise

The method saves all orders that are passed as a parameter. It is necessary to save all available orders as well as those that have not been changed.

I recommend using the autoSave function, which means you won't have to use this feature at all.

  const modified = await client.changeOrder(1672500000, 1, true)
  await client.saveChanges(modified)

Authorization is required for use

Typing

An overview of the interfaces used by the package.

Order

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | id | number | Created from unix timestamp | | date | Date | Date of order | | meals | Array<Meal> | Meals available in order |

Meal

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | id | number | | | name | string | | | description | string | | | selected | boolean | Is meal selected within the order | | canChange | boolean | If the selected state can be changed | | allergens | Array<string> \| null | | | details | MealDetails | Detail infomations |

MealDetails

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | price | FinancialAmount \| null | | | endOfCheckIn | Date \| null | | | endOfCheckOut | Date \| null | |

FinancialAmount

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | amount | number | | | currency | string | |

Dispensing

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | description | string | | | date | Date | | | pickupTime | number \| null | Time when the meal was picked up | | picked | boolean | | | mealVoucher | boolean | If the voucher was used to pick up the meal |

Payment

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | description | string | | | date | Date | | | details | FinancialAmount | |

Message

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | subject | string | | | recipient | string | Most often email | | date | Date | |

ChangeMealOptions

| Parameter | Type | Description | | :-------- | :------- | :------------------------- | | orderId | number | | | mealId | number | | | state | boolean | |

Authors