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

ayoba-microapp-api

v2.0.0

Published

A brief description of what this project does and who it's for ## Installation

Downloads

3

Readme

Ayoba Webpack API for ayoba microapps

A brief description of what this project does and who it's for

Installation

NPM

npm i ayoba-microapp-api

CDN

<script src="https://cdn.jsdelivr.net/gh/The-DigitalAcademy/ayoba-microapp-cdn@/microapp.js"></script>

Features

Get the following user's info
excecute the following functions

getUserPhoneNumber()

returns user's phone number

import { getUserPhoneNumber } from 'ayoba-microapp-api'

const userPhone = getUserPhoneNumber()

// OR

function myFunction() {
    const userPhone = getUserPhoneNumber(
        (val) => {console.log('success:', val)},
        (err) => {console.error(err)}
    )
    console.log("user's phone number:", userPhone)
}

parameters

successCb?: (res:string) => { }
  • optional. callback function for handling success response
errorCb?: (err:any) => { }
  • optional. callback function for handling error response

returns

phoneNumber: string

getUserCountryCode()

returns user's country code

import { getUserCountryCode } from 'ayoba-microapp-api'

const userCountry = getUserCountryCode()

//OR

function myFunction() {
    const userCountry = getUserCountryCode(
        (val) => {console.log('success:', val)},
        (err) => {console.error(err)}
    )
    console.log("user's phone number:", userCountry)
}

parameters

successCb?: (res:string) => { }
  • optional. callback function for handling success response
errorCb?: (err:any) => { }
  • optional. callback function for handling error response

returns

phoneNumber: string

getUserLanguageCode()

returns user's language code

import { getUserLanguageCode } from 'ayoba-microapp-api'

const language = getUserLanguageCode()

//OR

function myFunction() {
    const language = getUserLanguageCode(
        (val) => {console.log('success:', val)},
        (err) => {console.error(err)}
    )
    console.log("user's phone number:", language)
}

parameters

successCb?: (res:string) => { }
  • optional. callback function for handling success response
errorCb?: (err:any) => { }
  • optional. callback function for handling error response

returns

phoneNumber: string

getUserAyobaContacts()

returns user's ayoba registered contacts

import { getUserAyobaContacts } from 'ayoba-microapp-api'

const userContacts = getUserAyobaContacts()

//OR

function myFunction() {
    const userContacts = getUserAyobaContacts(
        (val) => {console.log('success:', val)},
        (err) => {console.error(err)}
    )
    console.log("user's contacts:", userContacts)
}

parameters

successCb?: (res:string) => { }
  • optional. callback function for handling success response
errorCb?: (err:any) => { }
  • optional. callback function for handling error response

returns

contacts: string JSON: [ {name:string, phoneNumber: string}, . . . ]

getAllUserContacts()

returns all user's contacts

import { getAllUserContacts } from 'ayoba-microapp-api'

const allUserContacts = getAllUserContacts()

//OR

function myFunction() {
    const allUserContacts = getAllUserContacts(
        (val) => {console.log('success:', val)},
        (err) => {console.error(err)}
    )
    console.log("user's contacts:", allUserContacts)
}

parameters

successCb?: (res:string) => { }
  • optional. callback function for handling success response
errorCb?: (err:any) => { }
  • optional. callback function for handling error response

returns

contacts: string JSON: [ {name:string, phoneNumber: string}, . . . ]

observeUserLocation()

passes the user's observed realtime location to onchange callback

import { observeUserLocation } from 'ayoba-microapp-api'

observeUserLocation(
    (val) => {console.log('current location:', val)},
    (err) => {console.error(err)}
)

parameters

onchange: (location: {lon: string, lat: string}) => { }
  • required. callback function. receives location value
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value

observeUserPresence()

passes the user's observed realtime presence to onchange callback

import { observeUserPresence } from 'ayoba-microapp-api'

observeUserPresence(
    (val) => {console.log('presence:', val)},
    (err) => {console.error(err)}
)

parameters

onchange: (online: 0|1) => { }
  • required. callback function. receives user presence
  • 1 = user is present
  • 0 = user is not present
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value

getUserName()

passes a username to onsuccess callback

import { getUserName } from 'ayoba-microapp-api'

getUserName(
    (val) => {console.log('username:', val)},
    (err) => {console.error(err)}
)

parameters

onsuccess: (username: string) => { }
  • required. callback function. receives username
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value

getUserAvatar()

passes an image url to onsuccess callback

import { getUserAvatar } from 'ayoba-microapp-api'

getUserAvatar(
    (val) => {console.log('avatar:', val)},
    (err) => {console.error(err)}
)

parameters

onsuccess: (imageUrl: string) => { }
  • required. callback function. receives image url
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value

closeApp()

closes application

import { closeApp } from 'ayoba-microapp-api'

function onInput() {
    closeApp()
}

startConversation()

opens chat with an ayoba phone Number

import { startConversation } from 'ayoba-microapp-api'

function onInput() {
    startConversation('+27974549153')
}

parameters

ayobaNumber: string
  • required. ayoba registered number
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value

shareUrl()

opens a dialogue to share url string

import { shareUrl } from 'ayoba-microapp-api'

function onInput() {
    shareUrl('https://www.npmjs.com/package/ayoba-microapp-api')
}

parameters

url: string
  • required. data string to be shared
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value

startPayment()

opens a dialogue to share url string

import { startPayment } from 'ayoba-microapp-api'

function onInput() {
    shareUrl('https://www.npmjs.com/package/ayoba-microapp-api')
}

parameters

payload: {method:string, amount:Number, currency: string, description?: string }
  • required. payment data
onerror?: (err:any) => { }
  • optional. callback function for handling error response

no return value