api_consumer 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +5 -13
  2. data/lib/api_consumer.rb +5 -3
  3. metadata +15 -15
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzRjZjU5NGY2OWVhYTdjYmY2YTkxYTZhMDJmNzg4Y2VlOGY0ODhmMA==
5
- data.tar.gz: !binary |-
6
- MjhlZjlhMjY5MmMxYmE2MzZmMjZlYzkxMTQ0ZjM3MDBmZDI4YzYwOQ==
2
+ SHA1:
3
+ metadata.gz: 02e65e6e4d1a158769681cfd63bec5568a7282ad
4
+ data.tar.gz: f720770230dc93dbcef09ff513e9df81f9021e71
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YmRjZmIwMzg1NzFkNWVkNzdiNTIwZGFlZjkxOWY0ZGY4M2RiY2RhNWY0N2Zm
10
- NTlmNmExYWJmNmFiZjY0Njg5M2JiYWY0YzAyNzJmZGFmODExM2FlMGIyNmZm
11
- MzMxZjM1ODFiMGNlMzAwZWViOTViYjc3N2Y1YzBjOTk5NzAwMTI=
12
- data.tar.gz: !binary |-
13
- ODdhZWNlMTBmNDk5ZmRmNzM4YjhjODVhOWExN2ExNzZiODA3MzMxMGI3NmRm
14
- YjRiM2IxNzA5M2Y0YzdkZGQ2NDU2ZTM1YjcyYTNjNDVkNjNkMDdkOWUxOTkz
15
- ZDc0NGQ1OGQ3ZThhMmQ2ZGZlZWYwOWQxZDdiMzg4MTViZmY5ZjM=
6
+ metadata.gz: c7e8cc636cffcfe1a3197d1151b58bd1dacf587d9ca55c2eea7b00a9e366cb9b7899029875d5456058b7d18edd435609e782f38a83ab1e583fe9d2332c71782d
7
+ data.tar.gz: 97589332e75a6817c3b94ffdd6d997341ddc7e03aa8efa8f73cea5f9894a56c74ca88bbcb0b7735dd4472738934477c3416ee8e2b2ddd0f88895b521fcc22d74
@@ -99,7 +99,7 @@ class APIConsumer
99
99
  opts[:headers].each { |k,v| req[k] = v }
100
100
  settings[:headers].each { |k,v| req[k] = v } if settings[:headers]
101
101
  req.basic_auth settings[:api_user], settings[:api_password] if settings[:api_user] && settings[:api_password]
102
- req["connection"] = 'keep-alive'
102
+ req["connection"] = 'keep-alive' if settings[:keep_alive]
103
103
  req.body = opts[:body] if opts[:body]
104
104
 
105
105
  response = nil
@@ -109,7 +109,9 @@ class APIConsumer
109
109
  response = conn.request(req)
110
110
  if( settings[:type] == "json")
111
111
  results = JSON.parse(response.body)
112
- if ![200, 201].include?(response.code.to_i)
112
+ good_codes = [200, 201, 202]
113
+ good_codes += settings[:accept_codes].map(&:to_i) if settings[:accept_codes]
114
+ if !good_codes.include?(response.code.to_i)
113
115
  results = error_code(response.code, opts[:errors], results)
114
116
  end
115
117
  results = blk.call(results) if blk
@@ -136,7 +138,7 @@ class APIConsumer
136
138
  log.error exception.message
137
139
  log.error exception.backtrace
138
140
  if( settings[:type] == "json")
139
- return error_code(response ? response.code : "NO CODE" , opts[:errors])
141
+ return error_code(response ? response.code : "NO CODE" , opts[:errors], response.body)
140
142
  end
141
143
  end
142
144
  data = response.body
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_consumer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Reister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uber_cache
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nori
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.6'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakeweb
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.3'
83
83
  description: Easy to use API consumer - Setup your API connection in a yaml file,
@@ -98,17 +98,17 @@ require_paths:
98
98
  - lib
99
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ! '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.2.2
111
+ rubygems_version: 2.6.10
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Consume all the APIs