New Programs Makers

    @lancero/node
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.18 • Public • Published

    Lancero Node.js

    This project contains the helper library for interacting with the Lancero API using Node.js.

    Table of contents

    Card

    Installation

    Installing the latest version can be done through your package manager.

    npm i @lancero/node
    
    yarn add @lancero/node

    Getting started

    Any interaction you want to make with the Lancero API needs to be done through the Lancero client. You can use a default import to get started.

    import Lancero from '@lancero/node';
    
    const lancero = new Lancero("Your secret key");

    API

    Leads

    find()

    Used to search for a lead

    Parameters
    • String, the email of the lead you want to look up
    const lead = await lancero.leads.find("hello@lancero.app");

    delete()

    Used to delete a lead

    Parameters
    • String, the email of the lead you want to delete
    const lead = await lancero.leads.delete("hello@lancero.app");

    create()

    Used to create a lead

    Parameters
    • Object, data
      • email, the email of the new lead
      • firstname (optional), the firstname of the new lead
      • lastname (optional), the lastname of the new lead
      • referralCode (optional), the 8-character referral code of another lead
      • waitlist (optional, default false), should this lead be added to the waitlist
    const lead = await lancero.leads.create({ 
      email: "hello@lancero.app",
      waitlist: true,
    });

    Codes

    find()

    Used to search for a code

    Parameters
    • String, the code you want to look up
    const code = await lancero.codes.find("curious-pineapple");

    send()

    Used to email a code to leads

    Parameters
    • Object, data
      • code, the code you want to send
      • leads, an array of emails you want to send this code to
    const result = await lancero.codes.send({
      code: "fantastic-apple",
      leads: ["hello@lancero.app", "thelegend27@lancero.app"],
    });

    delete()

    Used to delete a code

    Parameters
    • String, the code you want to delete
    const code = await lancero.codes.delete("curious-pineapple");

    generate()

    Used to generate codes

    Parameters
    • Object, data
      • amount, the amount of codes you want to generate
      • validFrom (optional), when this code starts to be valid
      • validUntil (optional), when this code expires
      • allowedClaims (optional, default 1), how many leads are allowed to claim this code
      • reservedFor (optional), the lead you want to reserve this code for
      • type (optional, default "creative"), what type of code do you want to generate
        • "creative", a random adjective and noun (e.g. curious-pineapple)
        • "alphanumeric", a 6 character combination of lowercase letters and digits
        • "numeric", 6 random digits
    const codes = await lancero.codes.generate({
      "amount": 3,
      "type": "creative",
      "reservedFor": "hello@lancero.app"
    });

    claim()

    Used to claim a code.

    Note, when using the Node.js library to claim a code we automatically call the exchange endpoint with the received claim token. This claims.exchange() method should be used when receiving a claim token via the Lancero Portal.

    Parameters
    • Object, data
      • code, the code you want to claim
      • email, the email of the lead you want to claim this code for
    const claim = await lancero.codes.claim({
      "code": "curious-pineapple",
      "lead": "hello@lancero.app",
    });

    Claims

    exchange()

    Used to exchange a unique Lancero claim token for the lead and code.

    Parameters
    • String, the Lancero claim token
    const claim = await lancero.claims.exchange("4501fa85e737df9af5f91ab4");

    Webhooks

    construct()

    Used to exchange a webhook event for data.

    Parameters
    • String, the event your webhook received
    const event = await lancero.webhooks.construct("fdbc0cc8-7718-4e4f-a8cb-c969d31b543e");
    
    // Get the type of the event
    if (event.data.event === 'LEAD_CREATION') {
        // This webhook was triggered because a lead was created
    }
    
    if (event.data.event === 'CODE_CREATION') {
      // This webhook was triggered because a code was generated
    }
    
    if (event.data.event === 'CODE_CLAIM') {
        // This webhook was triggered because a code was claimed
    }

    Keywords

    Install

    npm i @lancero/node

    DownloadsWeekly Downloads

    23

    Version

    0.0.18

    License

    MIT

    Unpacked Size

    18.6 kB

    Total Files

    20

    Last publish

    Collaborators

    • driaug