Class: Voltaria::Installments::Client
- Inherits:
-
Object
- Object
- Voltaria::Installments::Client
- Defined in:
- lib/voltaria/installments/client.rb
Instance Method Summary collapse
-
#add_installment(request_options: {}, **params) ⇒ Array[Voltaria::Types::InstallmentResponse]
Add new installments to a loan with its specific loan ID.
-
#create_payment_promise(request_options: {}, **params) ⇒ Voltaria::Types::PaymentPromiseResponse
Record a payment promise made by a client for one of their installments.
-
#delete_installment(request_options: {}, **params) ⇒ Hash[String, Object]
Delete an installment with its specific installment ID.
-
#edit_installment(request_options: {}, **params) ⇒ Voltaria::Types::InstallmentResponse
Update an installment's amount and expected repayment date with its specific installment ID.
-
#get_installment_by_id(request_options: {}, **params) ⇒ Voltaria::Types::InstallmentResponse
Retrieve detailed information for a specific installment using its installment ID.
- #initialize(client:) ⇒ void constructor
-
#list_installments(request_options: {}, **params) ⇒ Voltaria::Types::PaginatedResponseInstallmentResponseWithClientInfo
Retrieve a list of all loan installments under your partner account.
-
#list_payment_promises(request_options: {}, **params) ⇒ Voltaria::Types::PaginatedResponsePaymentPromiseResponse
Retrieve a list of payment promises recorded for installments under your partner account.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/voltaria/installments/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_installment(request_options: {}, **params) ⇒ Array[Voltaria::Types::InstallmentResponse]
Add new installments to a loan with its specific loan ID. This endpoint is available to select partners and will trigger the recalculation of the IRR and interest amounts for all installments of the loan.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/voltaria/installments/client.rb', line 76 def add_installment(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/installments", body: Voltaria::Installments::Types::InstallmentCreatePayload.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#create_payment_promise(request_options: {}, **params) ⇒ Voltaria::Types::PaymentPromiseResponse
Record a payment promise made by a client for one of their installments. The promised date must be today or in the future.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/voltaria/installments/client.rb', line 160 def create_payment_promise(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/installments/payment-promises", body: Voltaria::Installments::Types::PaymentPromiseCreatePayload.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Voltaria::Types::PaymentPromiseResponse.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_installment(request_options: {}, **params) ⇒ Hash[String, Object]
Delete an installment with its specific installment ID. This endpoint is available to select partners and will trigger the recalculation of the IRR and interest amounts for all installments of the loan.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/voltaria/installments/client.rb', line 271 def delete_installment(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "v2/installments/#{URI.encode_uri_component(params[:installment_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#edit_installment(request_options: {}, **params) ⇒ Voltaria::Types::InstallmentResponse
Update an installment's amount and expected repayment date with its specific installment ID. This endpoint is available to select partners and will trigger the recalculation of the IRR and interest amounts for all installments of the loan.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/voltaria/installments/client.rb', line 231 def edit_installment(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) request_data = Voltaria::Installments::Types::InstallmentEditPayload.new(params).to_h non_body_param_names = ["installment_id"] body = request_data.except(*non_body_param_names) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "v2/installments/#{URI.encode_uri_component(params[:installment_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Voltaria::Types::InstallmentResponse.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_installment_by_id(request_options: {}, **params) ⇒ Voltaria::Types::InstallmentResponse
Retrieve detailed information for a specific installment using its installment ID.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/voltaria/installments/client.rb', line 195 def get_installment_by_id(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/installments/#{URI.encode_uri_component(params[:installment_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Voltaria::Types::InstallmentResponse.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_installments(request_options: {}, **params) ⇒ Voltaria::Types::PaginatedResponseInstallmentResponseWithClientInfo
Retrieve a list of all loan installments under your partner account. Supports optional filtering by loan or client.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/voltaria/installments/client.rb', line 31 def list_installments(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[page page_size client_id loan_id order_by q] query_params = {} query_params["page"] = params[:page] if params.key?(:page) query_params["page_size"] = params[:page_size] if params.key?(:page_size) query_params["client_id"] = params[:client_id] if params.key?(:client_id) query_params["loan_id"] = params[:loan_id] if params.key?(:loan_id) query_params["order_by"] = params[:order_by] if params.key?(:order_by) query_params["q"] = params[:q] if params.key?(:q) params.except(*query_param_names) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/installments", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Voltaria::Types::PaginatedResponseInstallmentResponseWithClientInfo.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_payment_promises(request_options: {}, **params) ⇒ Voltaria::Types::PaginatedResponsePaymentPromiseResponse
Retrieve a list of payment promises recorded for installments under your partner account. Supports optional filtering by loan or client.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/voltaria/installments/client.rb', line 115 def list_payment_promises(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[page page_size order_by q loan_id client_id] query_params = {} query_params["page"] = params[:page] if params.key?(:page) query_params["page_size"] = params[:page_size] if params.key?(:page_size) query_params["order_by"] = params[:order_by] if params.key?(:order_by) query_params["q"] = params[:q] if params.key?(:q) query_params["loan_id"] = params[:loan_id] if params.key?(:loan_id) query_params["client_id"] = params[:client_id] if params.key?(:client_id) params.except(*query_param_names) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/installments/payment-promises", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Voltaria::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Voltaria::Types::PaginatedResponsePaymentPromiseResponse.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |