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

omeda-api-client

v1.0.1

Published

Omeda API Client for NodeJS

Downloads

3

Readme

Omeda API Client for NodeJS

Installing

npm install omeda-api-client --save

Usage

Create an API client instance

const omedaApi = require('omeda-api-client')({
  brandKey: 'yourbrand', // your Omeda brand/db name
  clientKey: 'client_yourclient', // your Omeda client id
  appId: '1d381ff5-ba0b-47ce-8730-ce91b05f7b54', // your API app-id to access the brand
  inputId: 'XXXXXXX', // the API input-id to write data to the db
  useStaging: false, // default, switch to true to access the staging db
});

You can also create multiple instances of the API client to connect to different brand databases...

const omedaFactory = require('omeda-api-client');

const fooBrand = omedaFactory({ brandKey: 'foo' /* additional options */ });
const barBrand = omedaFactory({ brandKey: 'bar' /* additional options */ });

Making API calls

Once you have a client instance, you can begin making API calls. Each API "category" is organized into corresponding resources. For instance, "customer" related APIs can be accessed via the customer resource; brand APIs can be accessed via the brand resource, etc. For example, to lookup a customer by email address, you would execute the following call:

const omedaApi = require('omeda-api-client')(/* options */);
const customer = omedaApi.resources.customer;

customer.lookupByEmail('[email protected]')
  .then(data => console.info(data))
  .catch(err => console.info('An error was found!', err))
;

All API resource functions will return a Promise (specifically a bluebird promise) via the request-promise library.

You can also make any number of "generic" API calls that may not be covered by this library, or if you're just feeling fancy :) This is the equivelant to calling customer.lookupByEmail('[email protected]') from above:

const omedaApi = require('omeda-api-client')(/* options */);

omedaApi.request('brand', 'GET', '/customer/email/[email protected]/*').then(/* ... */);

Complete API Reference


The Customer Resource

Access the resource:

const omedaApi = require('omeda-api-client')(/* options */);
const customer = omedaApi.resources.customer;

customer.lookup(customerId, [returnMerged=true])

Performs a Comprehensive Customer Lookup. Will return the full details of the customer. By default, if the customer that was found was merged into another, it will return the merged version.

customer.lookup(1013321055).then().catch()

customer.lookupByEmail(email, [productId])

Performs a Customer Lookup By Email. Can optionally limit the result to a specified product ID.

customer.lookupByEmail('[email protected]').then().catch()

customer.lookupByEncryptedId(encryptedId, [returnMerged = true])

Performs a Customer Lookup by EncryptedCustomerId. By default, if the customer that was found was merged into another, it will return the merged version.

customer.lookupByEncryptedId('1773F6238056C8U').then().catch()

customer.lookupByExternalId(namespace, externalId)

Performs a Customer Lookup Service By External ID.

customer.lookupByExternalId('some-namespace', 'some-external-id').then().catch()

customer.lookupById(customerId, [returnMerged = true])

Performs a Customer Lookup by CustomerId. By default, if the customer that was found was merged into another, it will return the merged version.

customer.lookupById(1013321055).then().catch()

customer.save(payload)

Saves (creates/updates) a customer and/or order via the Save Customer and Order API.

customer.save({ payload }).then().catch()

The Brand Resource

Access the resource:

const omedaApi = require('omeda-api-client')(/* options */);
const brand = omedaApi.resources.brand;

brand.lookup()

Performs a Brand Comprehensive Lookup.

brand.lookup().then().catch()

Developing / Contributing

  • Clone this repository
  • Install dependencies using Yarn
    • cd omeda-api-client
    • yarn install

Running tests

  • Execute npm run test
  • To see code coverage, run npm run coverage

Contributing

  • Ensure that both the npm run lint and npm run test commands are successful before PRing.
  • Preferably, code coverage should remain unchanged (or become better).