Giter Site home page Giter Site logo

eychu / insales_api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from insales/insales_api

0.0 2.0 0.0 160 KB

Gem for accessing the InSales REST web services

Home Page: https://wiki.insales.ru/wiki/%D0%9A%D0%B0%D0%BA_%D0%B8%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D1%82%D1%8C%D1%81%D1%8F_%D1%81_InSales

Ruby 100.00%

insales_api's Introduction

InsalesApi gem

Build Status

Insales api client based on ActiveResource.

Rails application example is here.

Install

Add to Gemfile:

gem 'insales_api'

Initialize

class MyApp < InsalesApi::App
  self.api_key = 'api_key'
end

MyApp.configure_api('domain', 'password')

Use

order = InsaleApi::Order.find 123

# singleton resources
account = InsaleApi::Account.find

Handling Insales API request limit

There is a 500 requests per 5 minutes limit for Insales API. To handle this limitation gracefully, use InsalesApi.wait_retry method:

# prepare a handler for request limit case
notify_user = Proc.new do |wait_for, attempt, max_attempts, ex|
  puts "API limit reached. Waiting for #{wait_for} seconds. Attempt #{attempt}/#{max_attempts}"
end

# perform 10 attempts to get products
InsalesApi.wait_retry(10, notify_user) do |x|
  puts "Attempt ##{x}."
  products = InsalesApi::Products.all
end

If you don't need to cap the attempts number or you don't want to do any special processing, simply drop the arguments:

InsalesApi.wait_retry do
  products = InsalesApi::Products.all # will try to get products until the limit resets
end

insales_api's People

Contributors

beorc avatar bvladimir avatar ikrevedko avatar lavrovdv avatar nu-hin avatar printercu avatar vltsu avatar vzctl avatar zsand avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.