Skip to content

creads/partners-sdk-angular

Repository files navigation

Angular Partners API Build Status

A simple AngularJS module for Creads Partners API.

Installation

npm install @creads/partners-sdk-angular

If you're using node5, install with --ignore-scripts argument to avoid a BC bug on postinstall with opencollective required by webpack-cli.

Usage

Include the file in your application:

require('@creads/partners-sdk-angular');

Then add the module to your application:

var myapp = angular.module('myapp', ['partners.api']);

Configuration

Configure the API provider for your application:

myapp.config([
  'apiProvider',
  function(apiProvider) {

    // configure the api provider
    apiProvider
      .setEndpoint('ENDPOINT_URL')
    ;

  }
]);

(Optional) Configure the interceptor provider for your application:

myapp.config([
  'apiInterceptorProvider',
  function(apiInterceptorProvider) {

    // configure the interceptor provider
    apiInterceptorProvider

      // Optional
      .setOnRequest(function(config) {

        // Do what you want with the request config object

        return config;
      })

      // Optional
      // The error method provide $injector as first parameter
      .setOnRequestError(function($injector, rejection) {

        // Do what you want with the rejection

      })

    ;

  }
]);

for more information about interceptor see angular $http doc section interceptor

Building the distribution (/dist)

To build the distribution:

npm ci
npm run build

Running the tests

To run all the tests:

npm test