1.0.0 • Published 11 months ago

@breu.io/nozl-nodejs-sdk v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

nozl-nodejs-sdk

Offical JavaScript SDK for Nozl

Installation

npm i nozl-nodejs-sdk

Prerequisites

  1. A registrered service e.g Twilio, SendGrid, Stripe etc. You can register your service via Nozl dashboard.
  2. Tenant API key. A Tenant is represents a team or a group which is going to use a Service.

Quick Start

const { Nozl, Payload } = require("nozl-nodejs-sdk");

const testMsg = async () => {
  const serviceId: string = "a0c236b8-b401-4ced-836e-a533b480d490"; // get this from dashboard
  const operationId: string = "CreateMessage"; // get this value from Service's official OpenAPI spec.
  const requestBody: object = {
    To: "RECEIVER_PHONE_NUMBER",
    Body: "test message from nodejs SDK",
    From: "SENDERS_PHONE_NUMBER", // get this from twilio's console
    user_id: "7f47fa0c-3035-4fbf-aff1-c3f7b639cwbz",
  };
  const pathParams: object = {
    AccountSid: "AC9f560ea30baaaf8013e4e44284eb6769",
  };
  const queryParams: object = {};
  const payload: Payload = new Payload(
    serviceId,
    operationId,
    requestBody,
    pathParams,
    queryParams
  );
  const url: string = "http://localhost:1323"; // replace this the actual domain
  const tenantApiKey: string = "7a5987c7-18c7-497d-8d27-e5765471e410"; // retrieve this after registrating a tenant.
  const nozl: Nozl = new Nozl(url, tenantApiKey);

  const data = await nozl.sendMessage(payload)
  console.log(data)
};

testMsg();
1.0.0

11 months ago