1.4.5 • Published 8 months ago

@hirvi/intellipush-sdk v1.4.5

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

https://www.intellipush.com/

Unofficial Nodejs SDK for Intellipush

This SDK is actively developed and maintained by HIRVI - an official Intellipush partner.

For compatibility with Node.js versions < 12, please install the globalThis polyfill.

Installation

Add @hirvi/intellipush-sdk dependency to your project:

npm install @hirvi/intellipush-sdk

or using Yarn

yarn add @hirvi/intellipush-sdk

TypeScript

This package delivers it's own typings. If you have any problems with typings, add the package to the types array in your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "@hirvi/intellipush-sdk"
    ]
  }
}

Initialize client

Initialize the Intellipush Client by passing in the credentials:

// const globalThis = require('globalthis')(); // uncomment if NodeJS < NodeJS versions < 12
import { Intellipush } from '@hirvi/intellipush-sdk'

const intellipush = new Intellipush({
    clientId: '<client_id>', // e.g process.env.INTELLIPUSH_CLIENT_ID
    clientSecret: '<client_secret>', // e.g process.env.INTELLIPUSH_CLIENT_SECRET
})

Authentication

You can sign in using OAuth2 (Client Credentials) by calling the authenticate method:

// Async
try {
    await intellipush.authenticate()
} catch(err: any) {
    console.log(err)
}

// Promise
intellipush.authenticate().then(() => {
    console.log('Authenticated!')
}).catch(() => {
    console.log('Authentication failed!')
})

Models

This SDK provides you with some convenient data models. All models accepts an object in the constructor as well as some setter functions. See example below.

Initialize model with an object.

const contact = new ContactModel({
    name: 'Tim Cook',
    countrycode: '0047',
    phonenumber: '12345678'
})

const result: IContactResponse = await intellipush.contact.create(contact)

console.log(result.data.name)

Initialize without object, use setters

const contact = new ContactModel()

contact.setName('Tim cook')
    .setCountrycode('0047')
    .setPhonenumber('12345678')
    .setEmail('tim@example.com')

const result: IContactResponse = await intellipush.contact.create(contact)

console.log(result.data.name)

Initialize with object and override with setters

const contact = new ContactModel({
    name: 'Tim Cook',
    countrycode: '0047',
    phonenumber: '12345678'
})

contact.setName('Howard Stewart')

const result: IContactResponse = await intellipush.contact.create(contact)

console.log(result.data.name)

Run without using data model

Since the Data Models is really just an object, you can also pass an object directly to the API methods:

const result: IContactResponse = await intellipush.contact.create({
    name: 'Tim Cook',
    countrycode: '0047',
    phonenumber: '12345678'
})

console.log(result.data.name)

Development status

  • Authentication
    • authenticate
    • getToken
    • setToken
  • API Resources
    • Contact
      • create
      • update
      • get
      • getContacts
      • delete
    • ContactList
      • create
      • update
      • get
      • getContactLists
      • getContactsInList
      • delete
    • SMS
      • create
      • createScheduled
      • createBatch
      • get
      • status
    • TwoFactor
      • generate
      • validate
    • Url
      • generate
      • generateChild
      • details
    • User
      • me

Need help? Feel free to contact us.

MIT

1.4.5

8 months ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.3-beta.0

2 years ago

1.3.3-rc.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago