Sha256: c224176d274139cc1f1b721c077a6acd421cf146f6a351777e43a8588de38777
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
module SantanderChile module ApiClient class Client class Connection def initialize(client:, host:) @client = client @host = host end attr_accessor :client, :host def post(path, body:, headers: {}, login: false) response = faraday(login: login).post(path, body, headers) do |request| if !login request.headers = { "access-token" => @client.token.tokenJWT }.merge(headers) end end end def faraday(login) Faraday.new(url: host) do |config| config.request :url_encoded if login config.request :oauth2, client.token.access_token, token_type: :bearer if client.token # TODO check token timeout config.request :json if !login config.response :raise_error config.response :json, content_type: "application/json" client.config.faraday.call(config) config.adapter Faraday.default_adapter end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
santander_chile-api_client-1.0.0 | lib/santander_chile/api_client/client/connection.rb |
santander_chile-api_client-0.0.2 | lib/santander_chile/api_client/client/connection.rb |