mirror of
https://github.com/retailcrm/api-client-ruby.git
synced 2024-11-22 04:56:06 +03:00
79 lines
1.6 KiB
Markdown
79 lines
1.6 KiB
Markdown
[![Gem Version](https://badge.fury.io/rb/retailcrm.svg)](http://badge.fury.io/rb/retailcrm)
|
||
|
||
Ruby-клиент для retailCRM API
|
||
=============================
|
||
|
||
|
||
### Установка
|
||
|
||
```
|
||
gem install retailcrm
|
||
```
|
||
|
||
### Примеры использования
|
||
|
||
#### Получение информации о заказе
|
||
|
||
```ruby
|
||
require 'retailcrm'
|
||
|
||
api = Retailcrm.new('https://yourcrmname.retailcrm.ru', 'yourApiKeyHere')
|
||
|
||
response = api.orders_get(345, 'id').response
|
||
order = response[:order]
|
||
|
||
```
|
||
|
||
#### Создание заказа
|
||
|
||
```ruby
|
||
require 'retailcrm'
|
||
|
||
api = Retailcrm.new('https://yourcrmname.retailcrm.ru', 'yourApiKeyHere')
|
||
|
||
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
|
||
}
|
||
]
|
||
}
|
||
|
||
response = api.orders_create(order).response
|
||
order_id = response[:id]
|
||
|
||
```
|
||
|
||
#### Документация REST API
|
||
|
||
http://www.retailcrm.ru/docs/Разработчики/СправочникМетодовAPIV3
|
||
|
||
#### Документация API библиотеки
|
||
|
||
http://www.rubydoc.info/gems/retailcrm
|