Sha256: a1c1ac304496e9da0ed1cb7bb9cfe2305f7df757524b48a1be033bc1ba3a87cd

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "myfinance/request"
require "myfinance/response"

module Myfinance
  class Client
    attr_reader :http

    def initialize(token, account_id = nil)
      @http = Http.new(token, account_id)
    end

    def authenticated?
      http.get("/accounts") { |response| response.code == 200 }
    rescue RequestError => e
      raise e unless [401, 403].include?(e.code)
      false
    end

    def entities
      Myfinance::Resources::Entity.new(http)
    end

    def payable_accounts
      Myfinance::Resources::PayableAccount.new(http)
    end

    def receivable_accounts
      Myfinance::Resources::ReceivableAccount.new(http)
    end

    def attachments
      Myfinance::Resources::Attachment.new(http)
    end

    def classification_centers
      Myfinance::Resources::ClassificationCenter.new(http)
    end

    def categories
      Myfinance::Resources::Category.new(http)
    end
    
    def accounts
      Myfinance::Resources::Account.new(http)
    end

    def deposit_accounts
      Myfinance::Resources::DepositAccount.new(http)
    end

    def people
      Myfinance::Resources::Person.new(http)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
myfinance-0.5.0 lib/myfinance/client.rb