Class: RunApi::Core::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/runapi/core/client.rb

Overview

Base class for every RunAPI client. Resolves the API key, builds the shared HTTP client, and exposes the Universal Resources (file upload, account) that are available on any client regardless of which model gem was required.

Provider clients inherit from this and build their model resources from the protected http reader.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, **options) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
# File 'lib/runapi/core/client.rb', line 17

def initialize(api_key: nil, **options)
  @api_key = Core::Auth.resolve_api_key(api_key)
  client_options = Core::ClientOptions.new(api_key: @api_key, **options)
  @http = client_options.http_client || Core::HttpClient.new(client_options)
  @files = Files.new(@http)
  @account = Account.new(@http)
end

Instance Attribute Details

#accountAccount (readonly)

Returns Account info and balance operations.

Returns:

  • (Account)

    Account info and balance operations.



15
16
17
# File 'lib/runapi/core/client.rb', line 15

def 
  @account
end

#filesFiles (readonly)

Returns Temporary file upload operations.

Returns:

  • (Files)

    Temporary file upload operations.



13
14
15
# File 'lib/runapi/core/client.rb', line 13

def files
  @files
end