0.0.7 • Published 8 years ago

yandex.delivery.js v0.0.7

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

Yandex.Delivery API JS module

A simple Yandex.Delivery API JS module

Purpose

It helpes with data preparation before request and saves several hours of time. Basically, it takes the object with params you are going to send to API, sorts all the properties in an alphabetical order and calculates hash in a way, that is described in API documentation. Then just sends the request to specified endpoint.

Installation

Just run npm install --save yandex.delivery.js. Currently module is only on npm, but you can use it outside of browserify or webpack, through global window.Yad.

Configuration

var API = new Yad({
  client_id: <your_client_id>,
  sender_id: <your_sender_id>,
  api_version: <api_version> // without it, the 'last' will be used,
  methods: {
    <all_the_methods_keys>
  }
});

Use

  var data = {
    term: 'Мос',
    type: 'locality'
  };

  //API.request( endpoint, data, success, error, key );
  // the last param key can overwrite method key specified earlier
  // endpoint is the name of the method specified in API docs
  API.request('autocomplete', data, 
    function( res ){
      console.log( res );
    }, 
    function( err ){
      console.log( err );
    }
  );

Docs

http://docs.yandexdelivery.apiary.io/

#Todo

  • add some console data based in env config
  • write tests
0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago