module Subledger::Store::Api::Post

Public Instance Methods

post(postable_journal_entry) click to toggle source
# File lib/subledger/store/api/roles/post.rb, line 5
def post postable_journal_entry
  path = Path.for_entity :anchor => postable_journal_entry

  begin
    json_body = http.post do |req|
                  req.url path

                  unless postable_journal_entry.post_delay.zero?
                    req.headers['X-Subledger-Post-Slowly'] = 'true'
                  end
                end.body
  rescue Exception => e
    raise PostError, "Cannot post #{postable_journal_entry}: #{e}"
  end

  new_or_initialize json_body, postable_journal_entry
end