retailcrm-api 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.markdown +20 -3
- data/lib/retailcrm-api/api_request.rb +8 -4
- data/lib/retailcrm-api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2712dc46e40f6b40a8b1e575fb265e6b916f032fa030a633bf7ec465fdcc55ed
|
4
|
+
data.tar.gz: d5b8cbf0ebd40ee9fe2590351eb697aa2016b21cdb7f6220333f278e9d6d0bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a59a99080cfd637d0416e4c0185cca4e74c042df59486b01bcfa4fcbb8489361c9da4ba3a27f9b3b99debe0f225f459634212105927c8346d0da407ac304b77
|
7
|
+
data.tar.gz: c097801cf4d5c919fd5f760751f9cbc70183ba356a5c0ffc995e2f6eebf3328679aa17c926f87ed66f58f0cf0817d32a03b2bc29ee7f3629c322ff61d296ec04
|
data/README.markdown
CHANGED
@@ -83,7 +83,7 @@ RetailcrmApi::Request.customers.retrieve.body
|
|
83
83
|
### [Создание клиента](https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-customers-create)
|
84
84
|
```ruby
|
85
85
|
body = {
|
86
|
-
site: 'deppa',
|
86
|
+
site: 'deppa-ru',
|
87
87
|
customer: {
|
88
88
|
externalId: 1,
|
89
89
|
firstName: 'Павел',
|
@@ -96,7 +96,7 @@ RetailcrmApi::Request.customers.create(body: body).body
|
|
96
96
|
### [Пакетная загрузка клиентов](https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-customers-upload)
|
97
97
|
```ruby
|
98
98
|
body = {
|
99
|
-
site: 'deppa',
|
99
|
+
site: 'deppa-ru',
|
100
100
|
customers: [
|
101
101
|
{
|
102
102
|
externalId: 3,
|
@@ -114,8 +114,25 @@ RetailcrmApi::Request.customers.create(body: body, suffix: "upload").body
|
|
114
114
|
```
|
115
115
|
|
116
116
|
## Корпоративные клиенты
|
117
|
-
|
117
|
+
### [Получение списка корпоративных клиентов, удовлетворяющих заданному фильтру](https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-customers-corporate)
|
118
118
|
```ruby
|
119
119
|
RetailcrmApi::Request.customers_corporate.retrieve.body
|
120
120
|
# => {:success=>true, :pagination=>{:limit=>20, :totalCount=>0, :currentPage=>1, :totalPageCount=>0}, :customersCorporate=>[]}
|
121
|
+
```
|
122
|
+
|
123
|
+
### [Пакетная загрузка корпоративных клиентов](https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-customers-corporate-upload)
|
124
|
+
```ruby
|
125
|
+
body = {
|
126
|
+
site: 'deppa-ru"',
|
127
|
+
customersCorporate: [
|
128
|
+
{
|
129
|
+
externalId: 3,
|
130
|
+
nickName: 'test1'
|
131
|
+
},
|
132
|
+
{
|
133
|
+
externalId: 4,
|
134
|
+
nickName: 'test2'
|
135
|
+
}
|
136
|
+
]
|
137
|
+
}
|
121
138
|
```
|
@@ -9,9 +9,10 @@ module RetailcrmApi
|
|
9
9
|
validate_api_key
|
10
10
|
begin
|
11
11
|
response = self.rest_client(suffix).post do |request|
|
12
|
-
configure_request(request: request, params: params, headers: headers, body:
|
12
|
+
configure_request(request: request, params: params, headers: headers, body: body)
|
13
13
|
end
|
14
|
-
parse_response(response)
|
14
|
+
#parse_response(response)
|
15
|
+
response
|
15
16
|
rescue => e
|
16
17
|
handle_error(e)
|
17
18
|
end
|
@@ -96,11 +97,14 @@ module RetailcrmApi
|
|
96
97
|
def configure_request(request: nil, params: nil, headers: nil, body: nil)
|
97
98
|
if request
|
98
99
|
request.params.merge!(params) if params
|
99
|
-
request.headers['Content-Type'] = 'application/
|
100
|
+
request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
100
101
|
request.headers['X-API-KEY'] = "#{self.api_key}"
|
101
102
|
request.headers['User-Agent'] = "RetailCrmApi/#{RetailcrmApi::VERSION} Ruby gem"
|
102
103
|
request.headers.merge!(headers) if headers
|
103
|
-
|
104
|
+
if body
|
105
|
+
body.each { |k, v| body[k] = MultiJson.dump(v) }
|
106
|
+
request.body = URI.encode_www_form(body)
|
107
|
+
end
|
104
108
|
request.options.timeout = self.timeout
|
105
109
|
request.options.open_timeout = self.open_timeout
|
106
110
|
end
|