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

ordercloud-angular-sdk

v2.7.8

Published

Wrapper for OrderCloud-Javascript-SDK

Downloads

54

Readme

OrderCloud Angular 1.xx SDK

This Angular 1.xx SDK is a wrapper for the OrderCloud Javascript SDK which is auto-generated from our Swagger Spec

Getting Started

If you're new to ordercloud check out our documentation.

Additional SDK specific documentation can be found here

Installation

  1. Type the following into a terminal window:
bower install ordercloud-angular-sdk --save
  1. include the ordercloud-angular-sdk module as a dependency:
angular.module('YOUR_MODULE', ['ordercloud-angular-sdk'])

Configuration

The SDK exposes OrderCloudSDK.Config to configure settings required to run. It receives the following parameters:

  1. cookiePrefix // this determines what to prefix cookies as when saving them.
  2. apiUrl // ordercloud.io base api url followed by the api version number (currently v1)
  3. authurl // ordercloud.io base auth url

We recommend setting these in a run block like so:

angular.module('YOUR_MODULE', ['ordercloud-javascript-sdk'])
    .run(function(OrderCloudSDK){
        var cookiePrefix = 'COOKIE_PREFIX_EXAMPLE'; // this can be any string - in the starter app we use the appname
        var apiVersion = 'v1'; //there is currently only one version of the API
        var apiurl = 'https://api.ordercloud.io'
        var authurl = 'https://auth.ordercloud.io'

        OrderCloudSDK.Config(cookiePrefix, apiurl + '/' + apiVersion, authurl);
    })

Additional SDK Methods

In addition to the standard methods provided via the Javascript SDK, the following methods are added to allow you to interact with tokens (stored in cookies) for a user as well as an impersonated user.

OrderCloudSDK.GetToken();
OrderCloudSDK.SetToken(tokenToSet);
OrderCloudSDK.RemoveToken();

OrderCloudSDK.GetRefreshToken();
OrderCloudSDK.SetRefreshToken(tokenToSet);

OrderCloudSDK.GetImpersonationToken();
OrderCloudSDK.SetImpersonationToken(tokenToSet);
OrderCloudSDK.RemoveImpersonationToken();

Example

The following example will show you how to:

  1. log in as a user
  2. set the user's token in cookies
  3. make an API call to retrieve user's details

var username = 'user123';
var password = 'foobar'
var clientid = '7FC87166-D42A-4F2D-9587-159D98156314' //you can find your app's client id in the [dashboard](https://developer.ordercloud.io/dashboard/applications)
var scope = ['FullAccess']; //this is an array of roles (permissions) being requested. More info on roles [here](https://developer.ordercloud.io/documentation/platform-guides/authentication/security-profiles)


OrderCloudSDK.Auth.Login(username, password, clientid, scope)
    .then(function(response){
        var token = response['access_token'];
        OrderCloudSDK.SetToken(token); //this token is now stored in browser cookies and will be used on any subsequent API call
        OrderCloudSDK.Me.Get()
            .then(function(currentUser){
                console.log('This user's name is ' + currentUser.FirstName + ' ' + currentUser.LastName);
            })
    })

Additional Information

Be sure to check out our API documentation.

Additional SDK specific documentation can be found here