Class: Nova::API::Resource::Receivable
- Inherits:
-
Bill
show all
- Defined in:
- lib/nova/api/resource/receivable.rb
Constant Summary
collapse
- ALLOWED_ATTRIBUTES =
Nova::API::Resource::Bill::ALLOWED_ATTRIBUTES.dup << :gross_value
Constants inherited
from Base
Base::PRODUCTION_HOST, Base::SCHEME, Base::STAGING_HOST
Utils::BaseStruct::DATE_REGEX
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
base_url
#allowed_attributes
Class Method Details
.create(parameters) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/nova/api/resource/receivable.rb', line 17
def self.create(parameters)
model = new parameters
model.attributes.delete(:id)
model.save
end
|
.destroy(id) ⇒ Object
31
32
33
34
35
|
# File 'lib/nova/api/resource/receivable.rb', line 31
def self.destroy(id)
model = initialize_empty_model_with_id(self, id, date: Date.today.iso8601, first_due_date: Date.today.iso8601)
model.destroy
end
|
.endpoint ⇒ Object
9
10
11
|
# File 'lib/nova/api/resource/receivable.rb', line 9
def self.endpoint
'/api/receivables'
end
|
.list(parameters = {}) ⇒ Object
13
14
15
|
# File 'lib/nova/api/resource/receivable.rb', line 13
def self.list(parameters = {})
do_get_search(endpoint, parameters.to_h)
end
|
.update(id, parameters) ⇒ Object
25
26
27
28
29
|
# File 'lib/nova/api/resource/receivable.rb', line 25
def self.update(id, parameters)
model = new parameters.merge(id: id)
model.update
end
|
Instance Method Details
#destroy ⇒ Object
57
58
59
60
61
|
# File 'lib/nova/api/resource/receivable.rb', line 57
def destroy
protect_operation_from_missing_value
do_delete("#{endpoint}")
end
|
#endpoint ⇒ Object
37
38
39
40
41
|
# File 'lib/nova/api/resource/receivable.rb', line 37
def endpoint
protect_operation_from_missing_value
"/api/receivables/#{id}"
end
|
#save ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/nova/api/resource/receivable.rb', line 43
def save
if id.nil?
do_post(self.class.endpoint, allowed_attributes)
else
do_patch("#{endpoint}", allowed_attributes)
end
end
|
#update ⇒ Object
51
52
53
54
55
|
# File 'lib/nova/api/resource/receivable.rb', line 51
def update
protect_operation_from_missing_value
do_patch("#{endpoint}", allowed_attributes)
end
|