api-client-ruby/README.md

77 lines
1.5 KiB
Markdown
Raw Normal View History

2020-02-19 13:50:59 +03:00
[![Gem](https://img.shields.io/gem/v/retailcrm?color=red&style=flat-square)](https://rubygems.org/gems/retailcrm)
[![RDoc](https://img.shields.io/badge/RDoc-reference-red.svg?style=flat-square)](http://www.rubydoc.info/gems/retailcrm)
2015-04-13 03:19:04 +03:00
2016-03-08 01:23:25 +03:00
retailCRM API ruby client
=========================
2015-04-13 03:14:25 +03:00
2016-03-08 01:23:25 +03:00
### Install
2015-04-13 03:14:25 +03:00
```
gem install retailcrm
```
2016-03-08 01:23:25 +03:00
### Examples
2015-04-13 03:14:25 +03:00
2016-03-08 01:23:25 +03:00
#### Get order
2015-04-13 03:14:25 +03:00
```ruby
require 'retailcrm'
2016-03-14 23:07:43 +03:00
api = Retailcrm.new('https://yourcrmname.retailcrm.pro', '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]
```
2016-03-08 01:23:25 +03:00
#### Create order
2015-04-13 03:14:25 +03:00
```ruby
require 'retailcrm'
2016-03-14 23:07:43 +03:00
api = Retailcrm.new('https://yourcrmname.retailcrm.pro', '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]
```
2020-02-19 13:50:59 +03:00
### Documentation
2015-04-13 03:14:25 +03:00
2020-02-19 13:50:59 +03:00
* [English](https://help.retailcrm.pro/Developers)
* [Russian](https://help.retailcrm.ru/Developers)