module Subledger::Store::Api::Categories

Public Instance Methods

attach_account_to_category(args) click to toggle source
# File lib/subledger/store/api/roles/categories.rb, line 5
def attach_account_to_category args
  category = args[:category]
  account  = args[:account]

  path = Path.for_entity( :anchor => category ) + '/attach'

  attach_post_hash = { 'account' => account.id }

  begin
    json_body = http.post do |req|
                  req.url    path
                  req.body = attach_post_hash
                end.body
  rescue Exception => e
    raise AttachError, "Cannot attach #{account}: #{e}"
  end

  account
end
collect_accounts_for_category(category) click to toggle source
# File lib/subledger/store/api/roles/categories.rb, line 45
def collect_accounts_for_category category
  raise CategoryError, 'category#accounts is not yet implemented'
end
detach_account_from_category(args) click to toggle source
# File lib/subledger/store/api/roles/categories.rb, line 25
def detach_account_from_category args
  category = args[:category]
  account  = args[:account]

  path = Path.for_entity( :anchor => category ) + '/detach'

  detach_post_hash = { 'account' => account.id }

  begin
    json_body = http.post do |req|
                  req.url    path
                  req.body = detach_post_hash
                end.body
  rescue Exception => e
    raise DetachError, "Cannot detach #{account}: #{e}"
  end

  account
end