31
31
require 'google/api_client/service_account'
32
32
require 'google/api_client/batch'
33
33
require 'google/api_client/gzip'
34
+ require 'google/api_client/charset'
34
35
require 'google/api_client/client_secrets'
35
36
require 'google/api_client/railtie' if defined? ( Rails )
36
37
@@ -75,6 +76,9 @@ class APIClient
75
76
# @option options [String] :ca_file
76
77
# Optional set of root certificates to use when validating SSL connections.
77
78
# By default, a bundled set of trusted roots will be used.
79
+ # @options options[Hash] :force_encoding
80
+ # Experimental option. True if response body should be force encoded into the charset
81
+ # specified in the Content-Type header. Mostly intended for compressed content.
78
82
# @options options[Hash] :faraday_options
79
83
# Pass through of options to set on the Faraday connection
80
84
def initialize ( options = { } )
@@ -119,6 +123,7 @@ def initialize(options={})
119
123
@discovered_apis = { }
120
124
ca_file = options [ :ca_file ] || File . expand_path ( '../../cacerts.pem' , __FILE__ )
121
125
self . connection = Faraday . new do |faraday |
126
+ faraday . response :charset if options [ :force_encoding ]
122
127
faraday . response :gzip
123
128
faraday . options . params_encoder = Faraday ::FlatParamsEncoder
124
129
faraday . ssl . ca_file = ca_file
@@ -265,10 +270,12 @@ def directory_uri
265
270
# @param [String, Symbol] api The API name.
266
271
# @param [String] version The desired version of the API.
267
272
# @param [Addressable::URI] uri The URI of the discovery document.
273
+ # @return [Google::APIClient::API] The service object.
268
274
def register_discovery_uri ( api , version , uri )
269
275
api = api . to_s
270
276
version = version || 'v1'
271
277
@discovery_uris [ "#{ api } :#{ version } " ] = uri
278
+ discovered_api ( api , version )
272
279
end
273
280
274
281
##
@@ -297,6 +304,7 @@ def discovery_uri(api, version=nil)
297
304
# @param [String] version The desired version of the API.
298
305
# @param [String, StringIO] discovery_document
299
306
# The contents of the discovery document.
307
+ # @return [Google::APIClient::API] The service object.
300
308
def register_discovery_document ( api , version , discovery_document )
301
309
api = api . to_s
302
310
version = version || 'v1'
@@ -311,6 +319,7 @@ def register_discovery_document(api, version, discovery_document)
311
319
end
312
320
@discovery_documents [ "#{ api } :#{ version } " ] =
313
321
MultiJson . load ( discovery_document )
322
+ discovered_api ( api , version )
314
323
end
315
324
316
325
##
0 commit comments