Class: InvoiceItem
- Inherits:
-
Object
- Object
- InvoiceItem
- Includes:
- HTTParty
- Defined in:
- lib/fastbill/invoice_item.rb
Instance Attribute Summary collapse
-
#complete_gross ⇒ Object
Returns the value of attribute complete_gross.
-
#complete_net ⇒ Object
Returns the value of attribute complete_net.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#sort_order ⇒ Object
Returns the value of attribute sort_order.
-
#unit_price ⇒ Object
Returns the value of attribute unit_price.
-
#vat_percent ⇒ Object
Returns the value of attribute vat_percent.
-
#vat_value ⇒ Object
Returns the value of attribute vat_value.
Instance Method Summary collapse
- #delete! ⇒ Object
- #hydrate(body) ⇒ Object
-
#initialize(auth = nil) ⇒ InvoiceItem
constructor
A new instance of InvoiceItem.
- #to_xml ⇒ Object
Constructor Details
#initialize(auth = nil) ⇒ InvoiceItem
Returns a new instance of InvoiceItem.
7 8 9 |
# File 'lib/fastbill/invoice_item.rb', line 7 def initialize(auth = nil) @auth = auth end |
Instance Attribute Details
#complete_gross ⇒ Object
Returns the value of attribute complete_gross.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def complete_gross @complete_gross end |
#complete_net ⇒ Object
Returns the value of attribute complete_net.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def complete_net @complete_net end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def currency_code @currency_code end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def id @id end |
#quantity ⇒ Object
Returns the value of attribute quantity.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def quantity @quantity end |
#sort_order ⇒ Object
Returns the value of attribute sort_order.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def sort_order @sort_order end |
#unit_price ⇒ Object
Returns the value of attribute unit_price.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def unit_price @unit_price end |
#vat_percent ⇒ Object
Returns the value of attribute vat_percent.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def vat_percent @vat_percent end |
#vat_value ⇒ Object
Returns the value of attribute vat_value.
5 6 7 |
# File 'lib/fastbill/invoice_item.rb', line 5 def vat_value @vat_value end |
Instance Method Details
#delete! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fastbill/invoice_item.rb', line 10 def delete! = { :basic_auth => @auth, :headers => { "Content-Type" => "application/xml" }, :body => '<?xml version="1.0" encoding="utf-8"?><FBAPI><SERVICE>item.delete</SERVICE><DATA><INVOICE_ITEM_ID>' + @id + '</INVOICE_ITEM_ID></DATA></FBAPI>' } r = self.class.post('/api/0.1/api.php', ) body = Crack::XML.parse r.body if !body['FBAPI']["RESPONSE"]["STATUS"].nil? && body['FBAPI']["RESPONSE"]["STATUS"] == "success" true else false end end |
#hydrate(body) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastbill/invoice_item.rb', line 26 def hydrate(body) @id = body["INVOICE_ITEM_ID"] @article_number = body["ARTICLE_NUMBER"] @description = body["DESCRIPTION"] @quantity = body["QUANTITY"] @unit_price = body["UNIT_PRICE"] @vat_percent = body["VAT_PERCENT"] @vat_value = body["VAT_VALUE"] @complete_net = body["COMPLETE_NET"] @complete_gross = body["COMPLETE_GROSS"] @sort_order = body["SORT_ORDER"] end |
#to_xml ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fastbill/invoice_item.rb', line 38 def to_xml xml = "<ITEM>" unless @id.nil? xml = xml + "<INVOICE_ITEM_ID>#{@id}</INVOICE_ITEM_ID>" end unless @article_number.nil? xml = xml + "<ARTICLE_NUMBER>#{@article_number}</ARTICLE_NUMBER>" end unless @description.nil? xml = xml + "<DESCRIPTION>#{@description}</DESCRIPTION>" end unless @quantity.nil? xml = xml + "<QUANTITY>#{@quantity}</QUANTITY>" end unless @unit_price.nil? xml = xml + "<UNIT_PRICE>#{@unit_price}</UNIT_PRICE>" end unless @vat_percent.nil? xml = xml + "<VAT_PERCENT>#{@vat_percent}</VAT_PERCENT>" end unless @vat_value.nil? xml = xml + "<VAT_VALUE>#{@vat_value}</VAT_VALUE>" end unless @complete_net.nil? xml = xml + "<COMPLETE_NET>#{@complete_net}</COMPLETE_NET>" end unless @complete_gross.nil? xml = xml + "<COMPLETE_GROSS>#{@complete_gross}</COMPLETE_GROSS>" end unless @sort_order.nil? xml = xml + "<SORT_ORDER>#{@sort_order}</SORT_ORDER>" end xml = xml + "</ITEM>" end |