Allow options when executing batch requests (#48)
This commit is contained in:
parent
794c6a90f7
commit
aa7a254d23
|
@ -542,10 +542,9 @@ module Google
|
|||
#
|
||||
# @see Google::APIClient#generate_request
|
||||
def execute(*params)
|
||||
if params.last.kind_of?(Google::APIClient::Request) &&
|
||||
params.size == 1
|
||||
request = params.pop
|
||||
options = {}
|
||||
if params.first.kind_of?(Google::APIClient::Request)
|
||||
request = params.shift
|
||||
options = params.shift || {}
|
||||
else
|
||||
# This block of code allows us to accept multiple parameter passing
|
||||
# styles, and maintaining some backwards compatibility.
|
||||
|
|
|
@ -143,6 +143,21 @@ describe Google::APIClient do
|
|||
)
|
||||
end
|
||||
|
||||
it 'should accept options with batch/request style execute' do
|
||||
client.authorization.access_token = "abcdef"
|
||||
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
||||
request = client.generate_request(
|
||||
:api_method => @prediction.training.insert,
|
||||
:parameters => {'data' => '12345'}
|
||||
)
|
||||
client.execute(
|
||||
request,
|
||||
:authorization => new_auth,
|
||||
:connection => @connection
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
it 'should accept options in array style execute' do
|
||||
client.authorization.access_token = "abcdef"
|
||||
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
||||
|
|
Loading…
Reference in New Issue