Class: Economic::JournalVoucherRepo

Inherits:
BaseRepo
  • Object
show all
Defined in:
lib/economic/journal_voucher_repo.rb

Constant Summary

Constants inherited from BaseRepo

BaseRepo::URL

Class Method Summary collapse

Methods inherited from BaseRepo

all, destroy, endpoint_url, filter, find, id_to_url_formatted_id, send, send_request, updated_after

Class Method Details

.endpoint_nameObject

Raises:

  • (StandardError)


9
10
11
# File 'lib/economic/journal_voucher_repo.rb', line 9

def self.endpoint_name
  raise StandardError, "only save is available on this repository"
end

.save(voucher) ⇒ Object



3
4
5
6
7
# File 'lib/economic/journal_voucher_repo.rb', line 3

def self.save(voucher)
  response = send_request(method: :post, url: URI.escape(Economic::JournalRepo.endpoint_url + "/" + voucher.journal.journalNumber.to_s + "/vouchers"), payload: voucher.to_h.to_json)

  Voucher.new(JSON.parse(response.body).first)
end