Class: GoogleClient::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/google_client/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, version, retries = 0) ⇒ Builder

Returns a new instance of Builder.



8
9
10
11
12
13
# File 'lib/google_client/builder.rb', line 8

def initialize(api, version, retries = 0)
  @client = GoogleClient.client
  @auth = GoogleClient.authorization.dup
  @service = @client.discovered_api(api, version) #
  @client.retries = retries
end

Instance Attribute Details

#serviceObject (readonly)

require ‘signet/errors’



6
7
8
# File 'lib/google_client/builder.rb', line 6

def service
  @service
end

Instance Method Details

#execute(credential, method, parameters = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/google_client/builder.rb', line 15

def execute(credential, method, parameters = {})
  preflight(credential)
  @client.execute(
      authorization: @auth,
      api_method: method,
      parameters: parameters,
  )
end

#execute_batch(credential, batch) ⇒ Object



24
25
26
27
28
# File 'lib/google_client/builder.rb', line 24

def execute_batch(credential, batch)
  # preflight(credential)
  @auth.update_token!(credential)
  @client.execute(batch, authorization: @auth)
end