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 🙏

© 2026 – Pkg Stats / Ryan Hefner

haraloyalty-sdk

v0.0.1-beta.0.8

Published

SDK for the Haraloyalty API

Readme

Haraloyalty JavaScript SDK

SDK for the Haraloyalty API

Full API docs are available here.

Changelog

View our Changelog for details about our releases.

Table Of Contents

Installation

With NPM:

$ npm install haraloyalty-sdk

CDN:

There is a minified UMD build available via CDN (see the Changelog for details about the latest release):

<script src="https://cdn-loyalty.xxx/sdk/v1/latest/index.umd.min.js"></script>

Builds

The JS Buy SDK has four build versions: ES, CommonJS, AMD, and UMD.

ES, CommonJS:

import HaraloyaltySdk from 'haraloyalty-sdk';

Examples

Initializing the haraloyaltySDK

import HaraloyaltySdk from 'haraloyalty-sdk';

// Initializing a sdk to return haraloyalty api
const sdk = HaraloyaltySdk.init({
  accessToken: 'haraloyalty-access-token',
  host: 'host haraloyalty api' // ex host.com
});

Fetching Segments

// Fetch all segments 
sdk.Segments.FetchAll().then((segments) => {
  // Do something with the segments
  console.log(segments);
});

// Fetch all segments with pagination ( page, limit )
sdk.Segments.Page(1)
            .Limit(20)
            .FetchAll()
            .then((segments) => {
  // Do something with the segments
  console.log(segments);
});

// Fetch all segments with search ( keyword )
sdk.Segments.Keyword('search-keyword')
            .FetchAll()
            .then((segments) => {
  // Do something with the segments
  console.log(segments);
});

// Fetch all segments with sort ( sort_by & sort_type )
sdk.Segments.SortBy('id')
            .SortType('DESC')
            .FetchAll()
            .then((segments) => {
  // Do something with the segments
  console.log(segments);
});

// Fetch a single segment by ID
const segmentId = 'Z2lkOi8';

sdk.Segments.Fetch(segmentId).then((segment) => {
  // Do something with the segment
  console.log(segment);
});

Store new Segments

// Store new segments 
const newSegment = {
    title: 'Segment name',
    ..
}

sdk.Segments.Create(newSegment);

Update Segment

// Update Segment by ID
const id = 'Z2lkOi8';
const input = {
    title: 'Segment name update',
    ...
};
sdk.Segments.Update(id, input);

Destroy Segment

// Destroy Segment by ID
const id = 'Z2lkOi8';
sdk.Segments.Delete(id);

Fetching Campaigns

// Fetch all Campaigns 
sdk.Campaigns.FetchAll().then((Campaigns) => {
  // Do something with the Campaigns
  console.log(Campaigns);
});

// Fetch all Campaigns with pagination ( page, limit )
sdk.Campaigns.Page(1)
            .Limit(20)
            .FetchAll()
            .then((Campaigns) => {
  // Do something with the Campaigns
  console.log(Campaigns);
});

// Fetch all Campaigns with search ( keyword )
sdk.Campaigns.Keyword('search-keyword')
            .FetchAll()
            .then((Campaigns) => {
  // Do something with the Campaigns
  console.log(Campaigns);
});

// Fetch all Campaigns with sort ( sort_by & sort_type )
sdk.Campaigns.SortBy('id')
            .SortType('DESC')
            .FetchAll()
            .then((Campaigns) => {
  // Do something with the Campaigns
  console.log(Campaigns);
});

// Fetch all Campaigns with Filter
const filter = {
        status: '1,2,3',
      };
sdk.Campaigns.Filter(filter)
            .FetchAll()
            .then((Campaigns) => {
  // Do something with the Campaigns
  console.log(Campaigns);
});

// Fetch a single Campaign by ID
const id = 'Z2lkOi8';

sdk.Campaigns.Fetch(id).then((Campaign) => {
  // Do something with the Campaign
  console.log(Campaign);
});

Store new Campaign

// Store new Campaigns 
const newCampaign = {
    title: 'Campaign name',
    ..
}

sdk.Campaigns.Create(newCampaign);

Update Campaign

// Update Campaigns by ID
const CampaignId = 'Z2lkOi8';
const input = {
    title: 'Campaign name update',
    ..
};
sdk.Campaigns.Update(CampaignId, input);

Report Campaign

// Report Campaigns by ID
const id = 'Z2lkOi8';
sdk.Reports
   .Campaign(id)
   .then((report) => {
      // Do something with the report
      console.log(report);
    });

Report Segment

const action = 'detail'; // 2 option : detail || detail_line
const dateOption = 'last30day'; // 6 option : yesterday || week || mtd || last7day || last30day || last90day
const id = id; // segment id 
sdk.Reports
   .Action(action)
   .DateOption(dateOption)
   .Segment(id)
   .then((report) => {
      // Do something with the report
      console.log(report);
    });

Report Dashboard

const action = 'common'; // 3 option : common || time || level
const dateOption = 'last30day'; // 6 option : yesterday || week || mtd || last7day || last30day || last90day
sdk.Reports
   .Action(action)
   .DateOption(dateOption)
   .Dashboard()
   .then((report) => {
      // Do something with the report
      console.log(report);
    });

Fetching Profiles

// Fetch all Profiles 
sdk.Profiles.FetchAll().then((Profiles) => {
  // Do something with the Profiles
  console.log(Profiles);
});

// Fetch all Profiles with pagination ( page, limit )
sdk.Profiles.Page(1)
            .Limit(20)
            .FetchAll()
            .then((Profiles) => {
  // Do something with the Profiles
  console.log(Profiles);
});

// Fetch all Profiles with search ( keyword )
sdk.Profiles.Keyword('search-keyword')
            .FetchAll()
            .then((Profiles) => {
  // Do something with the Profiles
  console.log(Profiles);
});

// Fetch all Profiles with sort ( sort_by & sort_type )
sdk.Profiles.SortBy('id')
            .SortType('DESC')
            .FetchAll()
            .then((Profiles) => {
  // Do something with the Profiles
  console.log(Profiles);
});

// Fetch a single Profile by ID
const id = 'Z2lkOi8';

sdk.Profiles.Fetch(id).then((Profile) => {
  // Do something with the Profile
  console.log(Profile);
});

Update Profile

// Update Profiles by ID
const ProfileId = 'Z2lkOi8';
const input = {
    title: 'Profile name update',
    ..
};
sdk.Profiles.Update(ProfileId, input);

Profile by Segment Setting

// Destroy Profiles by ID
const option = {
  customer_segment_id: 2021, // id of segment
  setting: { // segment setting
    include: [
      {
        field: "birth_month"
        logical: "AND"
        operator: "eq"
        value: 2
      }
    ],
    exclude: [
        field: "birth_month"
        logical: "AND"
        operator: "eq"
        value: 2
    ]
  }
};

sdk.Profiles
    .Segment(option)
    .then((profiles) => {
      // Do something with the Profile
      console.log(profiles);
    });

Config SMS

sdk.Configs
   .Sms()
   .then((config) => {
      // Do something with the config
      console.log(config);
    });

Config Email

sdk.Configs
   .Email()
   .then((config) => {
      // Do something with the config
      console.log(config);
    });

Config Zns ( Zalo )

sdk.Configs
   .Zns()
   .then((config) => {
      // Do something with the config
      console.log(config);
    });

Documentation

Contributing

For help on setting up the repo locally, building, testing, and contributing please see CONTRIBUTING.md.

Code of Conduct

All developers who wish to contribute through code or issues, take a look at the CODE_OF_CONDUCT.md.

License

MIT, see LICENSE.md for details.