Class: Voltaria::Repayments::Client
- Inherits:
-
Object
- Object
- Voltaria::Repayments::Client
- Defined in:
- lib/voltaria/repayments/client.rb
Instance Method Summary collapse
-
#create_bulk_repayments(request_options: {}, **params) ⇒ Voltaria::Types::BulkRepaymentTaskResponse
Initiate processing of up to 10000 repayment logs.
-
#create_repayment(request_options: {}, **params) ⇒ Voltaria::Types::RepaymentResponse
Create a new repayment log for an installment.
-
#get_bulk_repayment_status(request_options: {}, **params) ⇒ Voltaria::Types::BulkRepaymentTaskStatus
Check the progress and results of a bulk repayment processing task.
- #initialize(client:) ⇒ void constructor
-
#list_repayment_logs(request_options: {}, **params) ⇒ Voltaria::Types::PaginatedResponseRepaymentResponseWithClientInfo
Retrieve all repayments made under your partner account.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/voltaria/repayments/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_bulk_repayments(request_options: {}, **params) ⇒ Voltaria::Types::BulkRepaymentTaskResponse
Initiate processing of up to 10000 repayment logs. Returns task_id for tracking progress.
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/repayments/client.rb', line 125 def create_bulk_repayments(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/repayments/bulk", body: Voltaria::Repayments::Types::BulkRepaymentCreatePayload.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::BulkRepaymentTaskResponse.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_repayment(request_options: {}, **params) ⇒ Voltaria::Types::RepaymentResponse
Create a new repayment log for an installment. Requires the installment ID, loan ID or loan correlation ID.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/voltaria/repayments/client.rb', line 79 def create_repayment(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) request_data = Voltaria::Repayments::Types::RepaymentCreatePayload.new(params).to_h non_body_param_names = %w[installment_id loan_id correlation_id] body = request_data.except(*non_body_param_names) query_param_names = %i[installment_id loan_id correlation_id] query_params = {} query_params["installment_id"] = params[:installment_id] if params.key?(:installment_id) query_params["loan_id"] = params[:loan_id] if params.key?(:loan_id) query_params["correlation_id"] = params[:correlation_id] if params.key?(:correlation_id) params.except(*query_param_names) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/repayments", query: query_params, 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::RepaymentResponse.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_bulk_repayment_status(request_options: {}, **params) ⇒ Voltaria::Types::BulkRepaymentTaskStatus
Check the progress and results of a bulk repayment processing task.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/voltaria/repayments/client.rb', line 160 def get_bulk_repayment_status(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/repayments/bulk/#{URI.encode_uri_component(params[:task_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::BulkRepaymentTaskStatus.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_repayment_logs(request_options: {}, **params) ⇒ Voltaria::Types::PaginatedResponseRepaymentResponseWithClientInfo
Retrieve all repayments made under your partner account. Supports filtering by client, loan, or installments.
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 63 |
# File 'lib/voltaria/repayments/client.rb', line 31 def list_repayment_logs(request_options: {}, **params) params = Voltaria::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[client_id loan_id installment_id page page_size order_by q] query_params = {} 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["installment_id"] = params[:installment_id] if params.key?(:installment_id) 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) params.except(*query_param_names) request = Voltaria::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/repayments", 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::PaginatedResponseRepaymentResponseWithClientInfo.load(response.body) else error_class = Voltaria::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |