Class: Zaig::Connection
- Inherits:
-
Flash::Integration::Connection
- Object
- Flash::Integration::Connection
- Zaig::Connection
- Defined in:
- lib/zaig/connection.rb
Overview
Class to instance a authenticated connection object.
Constant Summary collapse
- JWT_EXP_TIME =
DateTime.now.next_day(1).to_time.to_i.freeze
Instance Method Summary collapse
- #default_headers ⇒ Object
-
#initialize(request_class: Faraday, base_url: Zaig.configuration.base_url) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(request_class: Faraday, base_url: Zaig.configuration.base_url) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 13 14 |
# File 'lib/zaig/connection.rb', line 8 def initialize(request_class: Faraday, base_url: Zaig.configuration.base_url) @jwt_algorithm = Zaig.configuration.jwt_algorithm @jwt_secret = Zaig.configuration.jwt_secret @jwt_user = Zaig.configuration.jwt_user super(request_class: request_class, base_url: base_url) end |
Instance Method Details
#default_headers ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/zaig/connection.rb', line 16 def default_headers headers = { "Content-Type": "application/json", Accept: "application/json" } return headers if @jwt_secret.nil? || @jwt_secret&.empty? headers[:Authorization] = "Bearer #{access_token}" headers end |