Class: GoogleDrive::ApiClientFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/google_drive/api_client_fetcher.rb

Defined Under Namespace

Classes: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorization) ⇒ ApiClientFetcher

Returns a new instance of ApiClientFetcher.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/google_drive/api_client_fetcher.rb', line 20

def initialize(authorization)
  @drive = Google::Apis::DriveV3::DriveService.new
  @drive.authorization = authorization

  # Make the timeout virtually infinite because some of the operations
  # (e.g., uploading a large file) can take very long.
  # This value is the maximal allowed timeout in seconds on JRuby.
  t = (2**31 - 1) / 1000
  @drive.client_options.open_timeout_sec = t
  @drive.client_options.read_timeout_sec = t
  @drive.client_options.send_timeout_sec = t
end

Instance Attribute Details

#driveObject (readonly)

Returns the value of attribute drive.



33
34
35
# File 'lib/google_drive/api_client_fetcher.rb', line 33

def drive
  @drive
end

Instance Method Details

#request_raw(method, url, data, extra_header, _auth) ⇒ Object



35
36
37
38
39
# File 'lib/google_drive/api_client_fetcher.rb', line 35

def request_raw(method, url, data, extra_header, _auth)
  options = @drive.request_options.merge(header: extra_header)
  body = @drive.http(method, url, body: data, options: options)
  Response.new('200', body)
end