Class: RSpreedly::Invoice
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#closed ⇒ Object
Returns the value of attribute closed.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#line_items ⇒ Object
Returns the value of attribute line_items.
-
#price ⇒ Object
Returns the value of attribute price.
-
#subscriber ⇒ Object
Returns the value of attribute subscriber.
-
#subscription_plan_id ⇒ Object
Returns the value of attribute subscription_plan_id.
-
#token ⇒ Object
Returns the value of attribute token.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Attributes inherited from Base
Instance Method Summary collapse
-
#create ⇒ Object
(also: #save)
Create an Invoice (more) POST /api/v4/[short site name]/invoices.xml.
- #create! ⇒ Object (also: #save!)
-
#pay(payment) ⇒ Object
Pay an Invoice (more) PUT /api/v4/[short site name]/invoices/[invoice token]/pay.xml.
- #pay!(payment) ⇒ Object
Methods inherited from Base
api_request, #api_request, #attributes=, do_request, #initialize, #to_xml
Constructor Details
This class inherits a constructor from RSpreedly::Base
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def amount @amount end |
#closed ⇒ Object
Returns the value of attribute closed.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def closed @closed end |
#created_at ⇒ Object
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def created_at @created_at end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def currency_code @currency_code end |
#line_items ⇒ Object
Returns the value of attribute line_items.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def line_items @line_items end |
#price ⇒ Object
Returns the value of attribute price.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def price @price end |
#subscriber ⇒ Object
Returns the value of attribute subscriber.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def subscriber @subscriber end |
#subscription_plan_id ⇒ Object
Returns the value of attribute subscription_plan_id.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def subscription_plan_id @subscription_plan_id end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def token @token end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/rspreedly/invoice.rb', line 5 def updated_at @updated_at end |
Instance Method Details
#create ⇒ Object Also known as: save
Create an Invoice (more) POST /api/v4/[short site name]/invoices.xml
18 19 20 21 22 23 24 |
# File 'lib/rspreedly/invoice.rb', line 18 def create begin create! rescue RSpreedly::Error::Base nil end end |
#create! ⇒ Object Also known as: save!
26 27 28 29 30 |
# File 'lib/rspreedly/invoice.rb', line 26 def create! result = api_request(:post, "/invoices.xml", :body => self.to_xml) self.attributes = result["invoice"] true end |
#pay(payment) ⇒ Object
Pay an Invoice (more) PUT /api/v4/[short site name]/invoices/[invoice token]/pay.xml
54 55 56 57 58 59 60 |
# File 'lib/rspreedly/invoice.rb', line 54 def pay(payment) begin pay!(payment) rescue RSpreedly::Error::Base nil end end |
#pay!(payment) ⇒ Object
62 63 64 65 66 |
# File 'lib/rspreedly/invoice.rb', line 62 def pay!(payment) result = api_request(:put, "/invoices/#{self.token}/pay.xml", :body => payment.to_xml(:outer => 'payment')) self.attributes = result["invoice"] true end |