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

1ot-api

v1.0.5

Published

1ot nodejs connector

Downloads

10

Readme

1ot nodejs connector

Connector for https://1ot.com api

Installation

yarn

yarn add 1ot-api

npm

npm install 1ot-api

Usage

import Connector, { primaryStatuses, secondaryStatuses } from '1ot-api'

const username = '...'
const password = '...'

;(async () => {
    const connector = new Connector(/* tokenData if it was saved */)

    // Happen every time new access token received
    connector.on('token', (tokenData) => {
        const { accessToken, expiresIn, refreshToken } = tokenData
        // store token data for reuse
    })

    await connector.auth(username, password)

    const sims = await connector.getSims({ groupName: 'Test group' })

    for (let sim of sims) {
        const {
            status: { primary, secondary }
        } = sim
        if (primary === primaryStatuses.ON) {
            if (secondary === secondaryStatuses.LIVE) {
                // put sim to sleep mode
                await sim.deactivate()
            } else {
                // resume sim from sleep mode
                await sim.activate()
            }
        }
    }
})()

Description

import Connector from '1ot-api'

const connector = new Connector(tokenData?: { accessToken: string, expiresIn: Date, refreshToken: string })

Common methods

/*
* GET /auth
* when accessToken will be expired, token refreshes automatically
*/
const result: boolean = await connector.auth(username: string, password: string)

// GET /get_account_balance
const balance = await connector.account.balance()

// GET /get_account_groups
const groups = await connector.account.getGroups()

/*
* GET /get_available_profiles
* Account must supports esims
*/
const profiles = await connector.getProfiles()
/*
if groupName is defined     -   GET /get_group_alerts
others                      -   GET /get_account_alerts
*/
const alerts = await connector.getAlerts(params?: { groupName?: string })

Sims selection

import { Sim } from '1ot-api'

// GET /get_sim
const sim: Sim = await connector.getSim(params: { iccid?: string, eid?: string})

/*
* Alternative way, without loading sim data
* Usefull for actions on known sims
*/
const sim: Sim = new Sim({iccid?: string, eid?: string})
// It's not necessary
await sim.load()

/*
if iccid or eid are defined     -   GET /get_sims
if groupName is defined         -   GET /get_gpoup_sims
others                          -   GET /get_account_sims
*/
const sims: {
        /* found, limit, total, offset */
        sims: Array<Sim>
    } = await connector.getSims(params?: {
        offset?: number = 0,
        iccid?: (string|Array<string>),
        eid?: (string|Array<string>),
        groupName?: string
    })

/*
* Selecting all sims in several requests if it needed (more than 1000 sims)
* Filtering - same as getSim
*/
const sims: Sims = await connector.getAllSims(filter?: {
    iccid?: (string|Array<string>),
    eid?: (string|Array<string>),
    groupName?: string
})

Sim info

// GET /get_sim_alerts
const alerts = await sim.getAlerts(params?: { offset?: number = 0, onlyUnread?: boolean = false, markAsRead?: boolean = false })

// GET /get_sim_cost
const cost = await sim.getCost(date?: Date)

// GET /get_sim_sessions
const sessions = await sim.getSessions({ offset?: number = 0, from?: number, to?: number })

Actions

// PUT /close
await sim.close()

/*
* PUT /diagnostics
* Only when feature is enabled in App Store
*/
await sim.diagnostics()

// PUT /esim_profile
await sim.esimProfile(profile: string, action: string)

// PUT /reset
await sim.reset()

// PUT /resume
await sim.resume()

// PUT /sendSms
await sim.sendSms(sms: string)

// PUT /set_data_limit
await sim.setDataLimit(dataLimit: number)

// PUT /set_group
await sim.setGroupt(groupName: string)

// PUT /set_name
await sim.setName(name: string)

// PUT /suspend
await sim.suspend()

// PUT /test
await sim.test()

// PUT /activate
await sim.activate()

// PUT /deactivate
await sim.deactivate()

For Sims object (connector.getAllSims()) all actions are available (will be apply for every sim inside). For example:

const sims = await connector.getAllSims({ groupName: 'Temperature sensors'})
await sims.suspend()