Sha256: eec8f79cd65b90e4251d2db1a162ecb26eb427f9ca1df8bc23a56d66e56f09f0

Contents?: true

Size: 857 Bytes

Versions: 19

Compression:

Stored size: 857 Bytes

Contents

require 'credova/api'
require 'credova/application'
require 'credova/ffl'
require 'credova/retailer'

module Credova
  class Client < Base

    include Credova::API

    attr_accessor :access_token

    def initialize(options = {})
      requires!(options, :username, :password)
      @options = options

      authenticate!
    end

    def application
      @application ||= Credova::Application.new(self)
    end

    def ffl
      @ffl ||= Credova::FFL.new(self)
    end

    def retailer
      @retailer ||= Credova::Retailer.new(self)
    end

    private

    def authenticate!
      response = post_request(
        'token',
        ['username=', @options[:username], '&password=', @options[:password]].join,
        content_type_header('application/x-www-form-urlencoded')
      )

      self.access_token = response.fetch(:jwt)
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
credova-0.3.3 lib/credova/client.rb
credova-0.3.2 lib/credova/client.rb
credova-0.3.1 lib/credova/client.rb
credova-0.3.0 lib/credova/client.rb
credova-0.2.0 lib/credova/client.rb
credova-0.1.14 lib/credova/client.rb
credova-0.1.13 lib/credova/client.rb
credova-0.1.12 lib/credova/client.rb
credova-0.1.11 lib/credova/client.rb
credova-0.1.10 lib/credova/client.rb
credova-0.1.9 lib/credova/client.rb
credova-0.1.8 lib/credova/client.rb
credova-0.1.7 lib/credova/client.rb
credova-0.1.6 lib/credova/client.rb
credova-0.1.5 lib/credova/client.rb
credova-0.1.4 lib/credova/client.rb
credova-0.1.3 lib/credova/client.rb
credova-0.1.2 lib/credova/client.rb
credova-0.1.1 lib/credova/client.rb