lib/caren/store/invoice.rb in caren-api-0.5.0 vs lib/caren/store/invoice.rb in caren-api-0.5.1
- old
+ new
@@ -1,9 +1,10 @@
class Caren::Store::Invoice < Caren::Base
def self.keys
[:id, # Integer (Caren id)
+ :person_id, # Integer (Caren person id)
:reference, # String
:requires_account, # Boolean
:requires_payment, # Boolean
:access_token, # String
:invoice_url, # String
@@ -27,10 +28,14 @@
def self.find id, session
from_xml session.get(self.resource_url(id))
end
+ def self.all_with_filter filter, session
+ from_xml session.get(self.filter_url(filter))
+ end
+
def self.all session
from_xml session.get(self.resource_url)
end
def create session
@@ -53,10 +58,11 @@
# make sure we have the correct address nodes here
billing_address.purpose = 'billing' if billing_address
shipping_address.purpose = 'shipping' if shipping_address
{
+ :person_id => self.person_id,
:reference => self.reference,
:requires_account => self.requires_account,
:requires_payment => self.requires_payment,
:customer_email => self.customer_email,
:paid => self.paid,
@@ -93,9 +99,13 @@
:invoices
end
def self.node_root
:invoice
+ end
+
+ def self.filter_url filter
+ "#{self.resource_url}?filter=#{filter}"
end
def self.email_url id
"#{self.resource_url(id)}/email"
end