Class: RunApi::Core::Client
- Inherits:
-
Object
- Object
- RunApi::Core::Client
- 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
-
#account ⇒ Account
readonly
Account info and balance operations.
-
#files ⇒ Files
readonly
Persistent File lifecycle and temporary URL upload operations.
-
#pricing ⇒ Pricing
readonly
Live Price Schedule lookup and Price Quote operations.
-
#uploads ⇒ Uploads
readonly
Multipart Upload lifecycle operations.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the SDK-created HTTP client.
-
#initialize(api_key: nil, **options) ⇒ Client
constructor
A new instance of Client.
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, **) @api_key = Core::Auth.resolve_api_key(api_key) = Core::ClientOptions.new(api_key: @api_key, **) @owns_http_client = .http_client.nil? @http = .http_client || Core::HttpClient.new() @files = Files.new(@http) @account = Account.new(@http) @pricing = Pricing.new(@http) @uploads = Uploads.new(@http) end |
Instance Attribute Details
#account ⇒ Account (readonly)
Returns Account info and balance operations.
15 16 17 |
# File 'lib/runapi/core/client.rb', line 15 def account @account end |
#files ⇒ Files (readonly)
Returns Persistent File lifecycle and temporary URL upload operations.
13 14 15 |
# File 'lib/runapi/core/client.rb', line 13 def files @files end |
#pricing ⇒ Pricing (readonly)
Returns Live Price Schedule lookup and Price Quote operations.
17 18 19 |
# File 'lib/runapi/core/client.rb', line 17 def pricing @pricing end |
#uploads ⇒ Uploads (readonly)
Returns Multipart Upload lifecycle operations.
19 20 21 |
# File 'lib/runapi/core/client.rb', line 19 def uploads @uploads end |
Instance Method Details
#close ⇒ Object
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 |