Class: Nova::API::Resource::FinancialAccount
- Inherits:
-
Base
show all
- Defined in:
- lib/nova/api/resource/financial_account.rb
Defined Under Namespace
Modules: REASON
Constant Summary
collapse
- ALLOWED_ATTRIBUTES =
%i[financial_account_id 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(parameters) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/nova/api/resource/financial_account.rb', line 48
def self.create(parameters)
model = new parameters
model.attributes.delete(:id)
model.save
end
|
.destroy(id) ⇒ Object
62
63
64
65
66
|
# File 'lib/nova/api/resource/financial_account.rb', line 62
def self.destroy(id)
model = initialize_empty_model_with_id(self, id)
model.destroy
end
|
.endpoint ⇒ Object
28
29
30
|
# File 'lib/nova/api/resource/financial_account.rb', line 28
def self.endpoint
'/api/financial_accounts'
end
|
.income_accounts ⇒ Object
36
37
38
|
# File 'lib/nova/api/resource/financial_account.rb', line 36
def self.income_accounts
do_get_search("#{endpoint}/income_accounts", nil)
end
|
.list ⇒ Object
32
33
34
|
# File 'lib/nova/api/resource/financial_account.rb', line 32
def self.list
do_get_search(endpoint, nil)
end
|
.payable_accounts ⇒ Object
40
41
42
|
# File 'lib/nova/api/resource/financial_account.rb', line 40
def self.payable_accounts
do_get_search("#{endpoint}/payable_accounts", nil)
end
|
.receivable_accounts ⇒ Object
44
45
46
|
# File 'lib/nova/api/resource/financial_account.rb', line 44
def self.receivable_accounts
do_get_search("#{endpoint}/receivable_accounts", nil)
end
|
.update(id, parameters) ⇒ Object
56
57
58
59
60
|
# File 'lib/nova/api/resource/financial_account.rb', line 56
def self.update(id, parameters)
model = new parameters.merge(id: id)
model.update
end
|
Instance Method Details
#destroy ⇒ Object
88
89
90
91
92
|
# File 'lib/nova/api/resource/financial_account.rb', line 88
def destroy
protect_operation_from_missing_value
do_delete("#{endpoint}")
end
|
#endpoint ⇒ Object
68
69
70
71
72
|
# File 'lib/nova/api/resource/financial_account.rb', line 68
def endpoint
protect_operation_from_missing_value
"/api/financial_accounts/#{id}"
end
|
#save ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/nova/api/resource/financial_account.rb', line 74
def save
if id.nil?
do_post(self.class.endpoint, allowed_attributes)
else
do_patch("#{endpoint}", allowed_attributes)
end
end
|
#update ⇒ Object
82
83
84
85
86
|
# File 'lib/nova/api/resource/financial_account.rb', line 82
def update
protect_operation_from_missing_value
do_patch("#{endpoint}", allowed_attributes)
end
|