Class: TortoiseLabs::Invoice
- Inherits:
-
Object
- Object
- TortoiseLabs::Invoice
- Defined in:
- lib/tortoiselabs/billing.rb
Instance Attribute Summary collapse
-
#creation_ts ⇒ Object
readonly
Returns the value of attribute creation_ts.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#payment_ts ⇒ Object
readonly
Returns the value of attribute payment_ts.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
- .add_credit(amount) ⇒ Object
- .get(id) ⇒ Object
-
.list ⇒ Object
Class Methods.
Instance Method Summary collapse
-
#initialize(ihash) ⇒ Invoice
constructor
A new instance of Invoice.
-
#to_s ⇒ Object
Instance methods.
Constructor Details
#initialize(ihash) ⇒ Invoice
Returns a new instance of Invoice.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/tortoiselabs/billing.rb', line 5 def initialize(ihash) @creation_ts, @total = ihash["creation_ts"], ihash["total"] @payment_ts, @user = ihash["payment_ts"], ihash["user"] @id = ihash["invoice"] @items = Array.new ihash["items"].each do |itemhash| obj = Item.new(itemhash) @items << obj end end |
Instance Attribute Details
#creation_ts ⇒ Object (readonly)
Returns the value of attribute creation_ts.
3 4 5 |
# File 'lib/tortoiselabs/billing.rb', line 3 def creation_ts @creation_ts end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/tortoiselabs/billing.rb', line 3 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
3 4 5 |
# File 'lib/tortoiselabs/billing.rb', line 3 def items @items end |
#payment_ts ⇒ Object (readonly)
Returns the value of attribute payment_ts.
3 4 5 |
# File 'lib/tortoiselabs/billing.rb', line 3 def payment_ts @payment_ts end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
3 4 5 |
# File 'lib/tortoiselabs/billing.rb', line 3 def total @total end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/tortoiselabs/billing.rb', line 3 def user @user end |
Class Method Details
.add_credit(amount) ⇒ Object
35 36 37 38 39 |
# File 'lib/tortoiselabs/billing.rb', line 35 def self.add_credit(amount) response = TortoiseLabs::Client.post("/invoice/svccredit", {:creditamt => amount}) return response.request.last_uri.to_s end |
.get(id) ⇒ Object
41 42 43 44 |
# File 'lib/tortoiselabs/billing.rb', line 41 def self.get(id) result = TortoiseLabs::Client.get("/invoice/#{id}") self.new(JSON.parse(result)["invoice"]) end |
.list ⇒ Object
Class Methods
25 26 27 28 29 30 31 32 33 |
# File 'lib/tortoiselabs/billing.rb', line 25 def self.list result = TortoiseLabs::Client.get("/invoice/list") invoices = Array.new JSON.parse(result)["invoices"].each do |invoice| obj = self.new(invoice) invoices << obj end invoices end |
Instance Method Details
#to_s ⇒ Object
Instance methods
19 20 21 |
# File 'lib/tortoiselabs/billing.rb', line 19 def to_s "Invoice ##{@id}" end |