Sha256: e29891371f279d25d7df8a2ba4028c4882079464d044ae8aa3f78b65083b2e5e
Contents?: true
Size: 1.46 KB
Versions: 14
Compression:
Stored size: 1.46 KB
Contents
require 'pina/models/sales_item' require 'pina/models/sales_invoice' require 'pina/collections/sales_invoice' module Pina class SalesInvoice class << self def new(params = nil) Pina::Models::SalesInvoice.new(params) end def find(id) response = Pina::RestAdapter.get(:sales_invoices, id) return Pina::Models::SalesInvoice.new(attributes(response)) if response.ok? response end def all(page = nil) response = Pina::RestAdapter.get(:sales_invoices, page) return Pina::Collections::SalesInvoice.new(attributes(response)) if response.ok? response end def where(hash, page = nil) response = Pina::RestAdapter.get(:sales_invoices, hash) return Pina::Collections::SalesInvoice.new(attributes(response)) if response.ok? response end def create(sales_invoice) response = Pina::RestAdapter.post(:sales_invoices, sales_invoice) return Pina::Models::SalesInvoice.new(attributes(response)) if response.ok? response end def update(id, sales_invoice) response = Pina::RestAdapter.patch(:sales_invoices, id, sales_invoice) return Pina::Models::SalesInvoice.new(attributes(response)) if response.ok? response end private def attributes(response) response.to_hash.merge(response: response) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems