api-client-ruby/README.md

79 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2015-04-13 03:19:04 +03:00
[![Gem Version](https://badge.fury.io/rb/retailcrm.svg)](http://badge.fury.io/rb/retailcrm)
2015-04-13 03:14:25 +03:00
Ruby-клиент для retailCRM API
=============================
### Установка
```
gem install retailcrm
```
### Примеры использования
#### Получение информации о заказе
```ruby
require 'retailcrm'
2015-04-13 18:07:40 +03:00
api = Retailcrm.new('https://yourcrmname.retailcrm.ru', 'yourApiKeyHere')
2015-04-13 03:14:25 +03:00
2015-04-13 18:07:40 +03:00
response = api.orders_get(345, 'id').response
2015-04-13 03:14:25 +03:00
order = response[:order]
```
#### Создание заказа
```ruby
require 'retailcrm'
2015-04-27 14:24:24 +03:00
api = Retailcrm.new('https://yourcrmname.retailcrm.ru', 'yourApiKeyHere')
2015-04-13 03:14:25 +03:00
order = {
:externalId => 171,
:number => '171',
:email => 'test@example.com',
:createdAt => '2014-10-28 19:31:10',
:discountPercent => 10,
:firstName => 'Jack',
:lastName => 'Daniels',
:customer => {
:externalId => 8768,
:firstName => 'Jack',
:lastName => 'Daniels',
:phones => [{ :number => '+79000000000' }],
},
:delivery => {
:code => 'courier',
:cost => 500,
:address => {:text => '300000, Russia, Moscow, Tverskaya st., 56'}
},
:items => [
{
:productId => 170,
:initialPrice => 500,
:quantity => 2
},
{
:productId => 175,
:initialPrice => 1300,
:quantity => 1
}
]
}
2015-04-13 18:07:40 +03:00
response = api.orders_create(order).response
2015-04-13 03:14:25 +03:00
order_id = response[:id]
```
2015-04-13 18:07:40 +03:00
#### Документация REST API
2015-04-13 03:14:25 +03:00
http://www.retailcrm.ru/docs/Разработчики/СправочникМетодовAPIV3
2015-04-13 18:07:40 +03:00
#### Документация API библиотеки
2015-04-27 14:24:24 +03:00
http://www.rubydoc.info/gems/retailcrm