0.02
Low commit activity in last 3 years
There's a lot of open issues
No release in over a year
Gem for accessing the InSales REST web services
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 10.3
~> 3.12

Runtime

 Project Readme

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 = InsalesApi::Order.find 123

# singleton resources
account = InsalesApi::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