3scale-api 1.1.0 → 1.2.0

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: e802565c57ee82f45f6684a5764b0bd438e9171e746f8128e4691b1fbd974a5d
4
- data.tar.gz: d979da1bce6a4f1f969e0bf8a1d9bc5ba661648b485acaaf1ce51f39f91723ac
3
+ metadata.gz: ea3ac51993c3762a0a40625807148fdba4dbf390aa032bc97183f660220bf410
4
+ data.tar.gz: 3f5c198b2fbe44894007990f4f7e6d926400c4f89597acf9533a281c2fb77cd7
5
5
  SHA512:
6
- metadata.gz: 65ae26fc85839d07a9df0fa0da510c8b259af601a5b163f843c9c0096a23e28198b639adcfa33ffdfbf8ee2baf40b5e2c817a47bbef2148d94c5997581d65366
7
- data.tar.gz: 702fb4b87d60a01954d8c6c0ae668ec75e6df24b0bdac3d646883b7231654a9fdd80f79af621d79725bbfd43c089b1f5f2601f8da70c9b96c4116b0addeb1ffd
6
+ metadata.gz: a5e4aff97c1716b24cdd5ba27385cf2babe88183dcc4894fcad0ca0df3e03df150e77fb80ff01485cca4bea47c4f6bade61a8c31aebdac8bd312aede6799af29
7
+ data.tar.gz: 2b86b756c210e5cc8270279d9f8ae258624ae6656594864d63d082b492b91b76e4c62a822ae6654243ba4585565acf6055906327303f71ec6e915b6603f22a16
@@ -68,16 +68,22 @@ module ThreeScale
68
68
 
69
69
  class NotFoundError < ResponseError; end
70
70
 
71
+ class UnknownFormatError < StandardError; end
72
+
71
73
  def forbidden!(response)
72
- raise ForbiddenError.new(response)
74
+ raise ForbiddenError.new(response, format_response(response))
73
75
  end
74
76
 
75
77
  def notfound!(response)
76
- raise NotFoundError.new(response)
78
+ raise NotFoundError.new(response, format_response(response))
77
79
  end
78
80
 
79
81
  def unexpected!(response)
80
- raise UnexpectedResponseError.new(response, response.inspect)
82
+ raise UnexpectedResponseError.new(response, format_response(response))
83
+ end
84
+
85
+ def unknownformat!
86
+ raise UnknownFormatError, "unknown format #{format}"
81
87
  end
82
88
 
83
89
  def serialize(body)
@@ -91,7 +97,7 @@ module ThreeScale
91
97
  def parser
92
98
  case format
93
99
  when :json then JSONParser
94
- else "unknown format #{format}"
100
+ else unknownformat!
95
101
  end
96
102
  end
97
103
 
@@ -108,6 +114,16 @@ module ThreeScale
108
114
  path
109
115
  end
110
116
 
117
+ def format_response(response)
118
+ body = response.body if text_based?(response)
119
+ "#{response.inspect} body=#{body}"
120
+ end
121
+
122
+ def text_based?(response)
123
+ response.content_type =~ /^text/ ||
124
+ response.content_type =~ /^application/ && !['application/octet-stream', 'application/pdf'].include?(response.content_type)
125
+ end
126
+
111
127
  module JSONParser
112
128
  module_function
113
129
 
@@ -1,5 +1,5 @@
1
1
  module ThreeScale
2
2
  module API
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 3scale-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Cichra
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-04-17 00:00:00.000000000 Z
12
+ date: 2020-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -101,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.7.6
104
+ rubygems_version: 3.1.2
106
105
  signing_key:
107
106
  specification_version: 4
108
107
  summary: API Client for 3scale APIs