Sha256: 3967cc9e31d7808424332f732eeff85a7d82cd6b7166810e3aa7e9f62566bfc3

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

require 'base64'
require 'faraday'

module Fintecture
  module Faraday
    module Authentication
      class Connection
        class << self

          def connection(url)
            ::Faraday.new(url: url) do |faraday|
              faraday.request :url_encoded
              faraday.adapter  ::Faraday.default_adapter
            end
          end

          def post(url:, req_body:)
            conn = connection(url)

            conn.post do |req|
              req.headers = req_headers
              req.body = req_body
            end
          end

          def req_headers
            client_token = Base64.strict_encode64("#{Fintecture.app_id}:#{Fintecture.app_secret}")

            {
                'Accept' => 'application/json',
                'User-Agent' => "Fintecture Ruby SDK v #{Fintecture::VERSION}",
                'Authorization' => "Basic #{client_token}",
                'Content-Type' => 'application/x-www-form-urlencoded',
            }
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fintecture-0.1.6 lib/fintecture/faraday/authentication/connection.rb
fintecture-0.1.5 lib/fintecture/faraday/authentication/connection.rb
fintecture-0.1.4 lib/fintecture/faraday/authentication/connection.rb
fintecture-0.1.3 lib/fintecture/faraday/authentication/connection.rb
fintecture-0.1.2 lib/fintecture/faraday/authentication/connection.rb
fintecture-0.1.1 lib/fintecture/faraday/authentication/connection.rb