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 (Files, Uploads, account, pricing) 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.



21
22
23
24
25
26
27
28
29
30
# File 'lib/runapi/core/client.rb', line 21

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)
  @owns_http_client = client_options.http_client.nil?
  @http = client_options.http_client || Core::HttpClient.new(client_options)
  @files = Files.new(@http)
  @account = Account.new(@http)
  @pricing = Pricing.new(@http)
  @uploads = Uploads.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 Persistent File lifecycle and temporary URL upload operations.

Returns:

  • (Files)

    Persistent File lifecycle and temporary URL upload operations.



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

def files
  @files
end

#pricingPricing (readonly)

Returns Live Price Schedule lookup and Price Quote operations.

Returns:

  • (Pricing)

    Live Price Schedule lookup and Price Quote operations.



17
18
19
# File 'lib/runapi/core/client.rb', line 17

def pricing
  @pricing
end

#uploadsUploads (readonly)

Returns Multipart Upload lifecycle operations.

Returns:

  • (Uploads)

    Multipart Upload lifecycle operations.



19
20
21
# File 'lib/runapi/core/client.rb', line 19

def uploads
  @uploads
end

Instance Method Details

#closeObject

Closes the SDK-created HTTP client. Injected clients remain caller-owned.



33
34
35
# File 'lib/runapi/core/client.rb', line 33

def close
  @http.close if @owns_http_client
end