Class: IronBank::Client
- Inherits:
-
Object
- Object
- IronBank::Client
- Defined in:
- lib/iron_bank/client.rb
Overview
Handle the credentials to Zuora and establish a connection when making an authenticated request, reusing the same session cookie for future requests.
Defined Under Namespace
Classes: Error, InvalidHostname
Instance Method Summary collapse
- #connection ⇒ Object
- #describe(object_name) ⇒ Object
-
#initialize(domain:, client_id:, client_secret:, auth_type: "token") ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
Constructor Details
#initialize(domain:, client_id:, client_secret:, auth_type: "token") ⇒ Client
Returns a new instance of Client.
26 27 28 29 30 31 |
# File 'lib/iron_bank/client.rb', line 26 def initialize(domain:, client_id:, client_secret:, auth_type: "token") @domain = domain @client_id = client_id @client_secret = client_secret @auth_type = auth_type end |
Instance Method Details
#connection ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/iron_bank/client.rb', line 37 def connection validate_domain reset_connection if auth.expired? config = IronBank.configuration @connection ||= Faraday.new(faraday_config) do |conn| config.middlewares.each { |klass, | conn.use(klass, ) } conn.request :json conn.request :retry, config. conn.use FaradayMiddleware::Response::RaiseError conn.use FaradayMiddleware::Response::RenewAuth, auth conn.response :json, content_type: /\bjson$/ conn.adapter Faraday.default_adapter end end |
#describe(object_name) ⇒ Object
56 57 58 |
# File 'lib/iron_bank/client.rb', line 56 def describe(object_name) IronBank::Describe::Object.from_connection(connection, object_name) end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/iron_bank/client.rb', line 33 def inspect %(#<IronBank::Client:0x#{(object_id << 1).to_s(16)} domain="#{domain}">) end |