moysklad 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eba3855e983122b5158c941697b4dc46309d9a7fa81bac691a90d4dbbed6238b
4
- data.tar.gz: 4edcfda4ffd7ff9156251a5f0f5e7d2de51c2c40c3b1fec1f5d84f77e407d9e5
3
+ metadata.gz: 3435d7c195bd20de53d97c82ac10d8269d94fc0e35a2e1aaf1330e5939ac28cb
4
+ data.tar.gz: d6067f848aa3a3568d996a9c9f02537035661fbfb67a5f7cf24193c6114490c6
5
5
  SHA512:
6
- metadata.gz: 4f19a54c763da441522e474ecd87bfbdfac9656af8e9c598132b7e8101d7dfc71a7d570386fbd78e4c188a1c4038f24c1f3c8c69878f9ab3181a9fd887ba7863
7
- data.tar.gz: 1531d71f523c7b0d51f07b1c7beed2be02dad3b1094e714e6917aa69b9c187fa4687b71b1a54e6639350725e84178f32305729a12c7d4a7994627c2499634e38
6
+ metadata.gz: 6847920c2dc4f7d99f9c45b77fe3d0e438cf606452e6cde86fe0c69846268d860ea23ffbcf759d9559acda614de7fa880921b54fcd839cc3cc96e36743118f21
7
+ data.tar.gz: 82d5e908c6888f8abc700f400d3041b23d08b1642e6deec87a5074acd6327855231de5aac8fd5bf59bdcd855af03e8d2c386bd30a68883000b2c174833270d10
@@ -2,6 +2,7 @@ require 'faraday'
2
2
  require 'faraday/detailed_logger'
3
3
  require 'faraday_curl'
4
4
  require 'faraday/gzip'
5
+ require 'faraday/encoding'
5
6
 
6
7
  require_relative 'client/errors'
7
8
 
@@ -14,6 +15,8 @@ class Moysklad::Client
14
15
  conn.response :detailed_logger, logger
15
16
  conn.request :curl, logger, :info
16
17
  end
18
+ conn.request :gzip
19
+ conn.response :encoding
17
20
 
18
21
  conn.options.timeout = ENV.fetch('MOYSKLAD_HTTP_TIMEOUT', 120)
19
22
  if Faraday::VERSION.split('.').first.to_i < 2
@@ -21,29 +24,25 @@ class Moysklad::Client
21
24
  else
22
25
  conn.request(:authorization, :basic, login, password)
23
26
  end
27
+
28
+ conn.adapter Faraday.default_adapter
24
29
  end
25
30
  end
26
31
 
27
32
  def download(path, filename)
28
- response = client.get path do |req|
29
- req.request :gzip
30
- end
33
+ response = client.get path
31
34
  File.open(filename, 'wb') { |fp| fp.write(response.body) }
32
35
  end
33
36
 
34
37
  def get path, params={}
35
38
  logger.debug "Client: GET #{path} #{params}"
36
- result = client.get path, params do |req|
37
- req.request :gzip
38
- end
39
- parse_response result
39
+ parse_response client.get path, params
40
40
  end
41
41
 
42
42
  def post path, data
43
43
  logger.debug "Client: POST #{path}"
44
44
  result = client.post do |req|
45
45
  req.url path
46
- req.request :gzip
47
46
  req.headers['Content-Type'] = 'application/json'
48
47
  req.headers['Accept'] = '*/*'
49
48
  req.body = data
@@ -54,7 +53,6 @@ class Moysklad::Client
54
53
  def put path, data
55
54
  logger.debug "Client: PUT #{path}"
56
55
  result = client.put do |req|
57
- req.request :gzip
58
56
  req.url path
59
57
  req.headers['Content-Type'] = 'application/json'
60
58
  req.headers['Accept'] = '*/*'
@@ -66,7 +64,6 @@ class Moysklad::Client
66
64
  def delete path
67
65
  logger.debug "Client: DELETE #{path}"
68
66
  result = client.delete do |req|
69
- req.request :gzip
70
67
  req.url path
71
68
  req.headers['Content-Type'] = 'application/json'
72
69
  req.headers['Accept'] = '*/*'
@@ -84,6 +81,7 @@ class Moysklad::Client
84
81
 
85
82
  def parse_response res
86
83
  body = res.body
84
+ body.force_encoding 'utf-8' if res.body.encoding.to_s == "ASCII-8BIT" && res.headers['content-type'].include?('charset=utf-8')
87
85
  Moysklad.logger.debug "Response [#{res.status}] with body #{body}"
88
86
 
89
87
  if res.status == 200
@@ -1,3 +1,3 @@
1
1
  module Moysklad
2
- VERSION = '0.4.5'
2
+ VERSION = '0.4.6'
3
3
  end
data/moysklad.gemspec CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency 'faraday'
24
24
  spec.add_runtime_dependency 'faraday-gzip'
25
+ spec.add_runtime_dependency 'faraday-encoding'
25
26
  spec.add_runtime_dependency 'virtus'
26
- # spec.add_runtime_dependency 'nokogiri-happymapper'
27
27
  spec.add_runtime_dependency 'activesupport', '>=3.0.0'
28
28
 
29
29
  spec.add_development_dependency "bundler"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moysklad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danil Pismenny
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday-encoding
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: virtus
43
57
  requirement: !ruby/object:Gem::Requirement