Class: Nova::API::Resource::Installment

Inherits:
Base show all
Defined in:
lib/nova/api/resource/installment.rb

Defined Under Namespace

Classes: WriteOffInstallment

Constant Summary collapse

ALLOWED_ATTRIBUTES =
%i[due_date gross_value number value]

Constants inherited from Base

Base::PRODUCTION_HOST, Base::SCHEME, Base::STAGING_HOST

Constants inherited from Utils::BaseStruct

Utils::BaseStruct::DATE_REGEX

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

authorization_header, base_url, configuration, do_get, do_get_search, perform_get

Methods inherited from Utils::BaseStruct

#allowed_attributes, generate_valid_value_for, initialize_empty_model_with_id, value_for_field

Class Method Details

.cancel_write_offs(id) ⇒ Object



54
55
56
57
58
# File 'lib/nova/api/resource/installment.rb', line 54

def self.cancel_write_offs(id)
  model = initialize_empty_model_with_id(self, id, due_date: Date.today.iso8601)

  model.cancel_write_offs
end

.endpointObject



44
45
46
# File 'lib/nova/api/resource/installment.rb', line 44

def self.endpoint
  '/api/installments'
end

.write_off(id, parameters) ⇒ Object



48
49
50
51
52
# File 'lib/nova/api/resource/installment.rb', line 48

def self.write_off(id, parameters)
  model = WriteOffInstallment.new(parameters.merge(id:))

  model.write_off
end

Instance Method Details

#cancel_write_offsObject



72
73
74
75
76
# File 'lib/nova/api/resource/installment.rb', line 72

def cancel_write_offs
  protect_operation_from_missing_value

  do_delete("#{endpoint}/cancel_write_offs")
end

#endpointObject



60
61
62
63
64
# File 'lib/nova/api/resource/installment.rb', line 60

def endpoint
  protect_operation_from_missing_value

  "/api/installments/#{id}"
end

#write_off(parameters) ⇒ Object



66
67
68
69
70
# File 'lib/nova/api/resource/installment.rb', line 66

def write_off(parameters)
  model = WriteOffInstallment.new(parameters.merge(id:))

  model.write_off
end