Class: Nova::API::Resource::Payable
- Inherits:
-
Bill
show all
- Defined in:
- lib/nova/api/resource/payable.rb
Constant Summary
Constants inherited
from Bill
Bill::ALLOWED_ATTRIBUTES
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
13
14
15
16
17
18
19
|
# File 'lib/nova/api/resource/payable.rb', line 13
def self.create(parameters)
model = new parameters
model.attributes.delete(:id)
model.save
end
|
.destroy(id) ⇒ Object
27
28
29
30
31
|
# File 'lib/nova/api/resource/payable.rb', line 27
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
5
6
7
|
# File 'lib/nova/api/resource/payable.rb', line 5
def self.endpoint
'/api/payables'
end
|
.list(parameters = {}) ⇒ Object
9
10
11
|
# File 'lib/nova/api/resource/payable.rb', line 9
def self.list(parameters = {})
do_get_search(endpoint, parameters.to_h)
end
|
.update(id, parameters) ⇒ Object
21
22
23
24
25
|
# File 'lib/nova/api/resource/payable.rb', line 21
def self.update(id, parameters)
model = new parameters.merge(id: id)
model.update
end
|
Instance Method Details
#destroy ⇒ Object
53
54
55
56
57
|
# File 'lib/nova/api/resource/payable.rb', line 53
def destroy
protect_operation_from_missing_value
do_delete("#{endpoint}")
end
|
#endpoint ⇒ Object
33
34
35
36
37
|
# File 'lib/nova/api/resource/payable.rb', line 33
def endpoint
protect_operation_from_missing_value
"/api/payables/#{id}"
end
|
#save ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/nova/api/resource/payable.rb', line 39
def save
if id.nil?
do_post(self.class.endpoint, allowed_attributes)
else
do_patch("#{endpoint}", allowed_attributes)
end
end
|
#update ⇒ Object
47
48
49
50
51
|
# File 'lib/nova/api/resource/payable.rb', line 47
def update
protect_operation_from_missing_value
do_patch("#{endpoint}", allowed_attributes)
end
|