Class: Nova::API::Resource::ApportionmentValue
- Inherits:
-
Base
show all
- Defined in:
- lib/nova/api/resource/apportionment_value.rb
Constant Summary
collapse
- ALLOWED_ATTRIBUTES =
%i[name]
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(apportionment_id, parameters) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 17
def self.create(apportionment_id, parameters)
model = new parameters.merge(apportionment_id: apportionment_id)
model.attributes.delete(:id)
model.save
end
|
.destroy(apportionment_id, id) ⇒ Object
31
32
33
34
35
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 31
def self.destroy(apportionment_id, id)
model = initialize_empty_model_with_id(self, id, apportionment_id: apportionment_id)
model.destroy
end
|
.endpoint(apportionment_id) ⇒ Object
13
14
15
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 13
def self.endpoint(apportionment_id)
"/api/apportionments/#{apportionment_id}/apportionment_values"
end
|
.reactivate(apportionment_id, id) ⇒ Object
37
38
39
40
41
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 37
def self.reactivate(apportionment_id, id)
model = initialize_empty_model_with_id(self, id, apportionment_id: apportionment_id)
model.reactivate
end
|
.update(apportionment_id, id, parameters) ⇒ Object
25
26
27
28
29
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 25
def self.update(apportionment_id, id, parameters)
model = new parameters.merge(id: id, apportionment_id: apportionment_id)
model.update
end
|
Instance Method Details
#destroy ⇒ Object
61
62
63
64
65
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 61
def destroy
protect_operation_from_missing_value
do_delete("#{endpoint}")
end
|
#endpoint ⇒ Object
43
44
45
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 43
def endpoint
"/api/apportionments/#{apportionment_id}/apportionment_values/#{id}"
end
|
#reactivate ⇒ Object
67
68
69
70
71
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 67
def reactivate
protect_operation_from_missing_value
do_patch("#{endpoint}/reactivate", {})
end
|
#save ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 47
def save
if id.nil?
do_post(self.class.endpoint(apportionment_id), allowed_attributes)
else
do_patch("#{endpoint}", allowed_attributes)
end
end
|
#update ⇒ Object
55
56
57
58
59
|
# File 'lib/nova/api/resource/apportionment_value.rb', line 55
def update
protect_operation_from_missing_value
do_patch("#{endpoint}", allowed_attributes)
end
|