Class: Octobat::PurchaseItem
Instance Attribute Summary
#api_key, #parent_obj
Class Method Summary
collapse
Instance Method Summary
collapse
list, set_parent_resource
#delete
#save, #serialize_metadata, #serialize_params
included
Methods inherited from APIResource
class_name, #refresh, retrieve
#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Octobat::OctobatObject
Class Method Details
.set_parent_resource(filters) ⇒ Object
46
47
48
|
# File 'lib/octobat/purchase_item.rb', line 46
def self.set_parent_resource(filters)
@parent_resource = filters.select{|k, v| [:self_billing_invoice].include?(k)}
end
|
.url ⇒ Object
40
41
42
43
44
|
# File 'lib/octobat/purchase_item.rb', line 40
def self.url
if @parent_resource.include?(:self_billing_invoice)
"#{SelfBillingInvoice.url}/#{CGI.escape(@parent_resource[:self_billing_invoice])}/purchase_items"
end
end
|
Instance Method Details
#parentize_url ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/octobat/purchase_item.rb', line 23
def parentize_url
if parent_obj.include?(:self_billing_invoice)
"#{SelfBillingInvoice.url}/#{CGI.escape(parent_obj[:self_billing_invoice])}/purchase_items/#{CGI.escape(id)}"
else
url
end
end
|
#relative_save_url ⇒ Object
33
34
35
36
37
|
# File 'lib/octobat/purchase_item.rb', line 33
def relative_save_url
if self[:self_billing_invoice]
"#{SelfBillingInvoice.url}/#{CGI.escape(self[:self_billing_invoice])}/purchase_items"
end
end
|
#save_url ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/octobat/purchase_item.rb', line 14
def save_url
if self[:id] == nil && self.class.respond_to?(:create)
self.relative_save_url
else
url
end
end
|
#url ⇒ Object
9
10
11
|
# File 'lib/octobat/purchase_item.rb', line 9
def url
!parent_obj.nil? ? parentize_url : super
end
|