Giter Site home page Giter Site logo

insales / insales_api Goto Github PK

View Code? Open in Web Editor NEW
6.0 27.0 9.0 115 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 = 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

insales_api's People

Contributors

akachalova avatar bbagno avatar beorc avatar bogus34 avatar bvladimir avatar eychu avatar golov avatar hbda avatar ievgrafov avatar ikrevedko avatar ilyachizhanov avatar lavrovdv avatar nu-hin avatar ohmycto avatar printercu avatar v-sh avatar vasfed avatar vltsu avatar vzctl avatar zsand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

insales_api's Issues

Failed. Response code = 401. Response message = Unauthorized

Из консоли (rails c) всё работает, а вот из контроллера выдаёт ошибку. Я же правильно понял что из любого контроллера можно делать вызов типа product = InsalesApi::Product.find (id) -?

Описание

В описании написано - products = InsalesApi::Products.all
точно Products, а не Product - ?

Как правильно создать заказ (Order)?

Подскажите, как правильно создать новый заказ через API?

Например, такой заспрос:

    order = InsalesApi::Order.create! payment_title: "Наличным курьеру",
                                      payment_description: "Наличными курьеру",
                                      delivery_description: "Самовывоз (На пункте выдачи)",

                                      client: {
                                          email: "[email protected]",
                                          name: "TEST",
                                          phone: "+79001234567"
                                      },
                                      order_lines_attributes: [{
                                                                   product_id: product_id,
                                                                   quantity: 1
                                                               }]

Возвращает ошибку: NameError (undefined local variable or method `order_lines' for #<InsalesApi::Order:0x00007f0a3537a758>)

Если вместо :order_lines_attributes использовать order_lines, то возникает другая ошибка: NoMethodError (undefined method `order_lines_attributes' for #<InsalesApi::Client:0x00007f0a35659b40>)

Загрузка архива с темой

Целесообразно реализовать возможность загрузки темы в виде архива.
Публикация темы целиком полезна при передачи в тестирование/продакшн изменений. Можно сказать, это "чистая установка".

Такая возможность позволит реализовать, например, версионирование темы.
В случае, если код темы хранится в git, возможность программной загрузки архива с темой позволит автоматически теггировать ревизию. Это, в свою очередь, позволит быстро "задеплоить" нужную версию.

Если загрузка темы архивом будет реализована в бекенде, сообщество самостоятельно, если это потребуется, реализует поддержку этой возможности в api-обертке.

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.