Sha256: 2199bdfc593ca0cea6e8b8e0f82c743dffd1c75cf378539194aa1852e9b31cf8

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 Bytes

Contents

require 'lipseys/api'
require 'lipseys/items'
require 'lipseys/order'

module Lipseys
  class Client < Base

    include Lipseys::API

    attr_accessor :access_token

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

      authenticate!
    end

    def items
      @items ||= Lipseys::Items.new(self)
    end

    def order
      @order ||= Lipseys::Order.new(self)
    end

    private

    def authenticate!
      response = post_request(
        'authentication/login',
        { email: @options[:username], password: @options[:password] },
        content_type_header('application/json')
      )

      self.access_token = response[:token]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lipseys-6.0.0 lib/lipseys/client.rb