Class: Payabli::ChargeBacks::Client
- Inherits:
-
Object
- Object
- Payabli::ChargeBacks::Client
- Defined in:
- lib/payabli/charge_backs/client.rb
Instance Method Summary collapse
-
#add_response(request_options: {}, **params) ⇒ Payabli::ChargeBacks::Types::AddResponseResponse
Add a response to a chargeback or ACH return.
-
#get_chargeback(request_options: {}, **params) ⇒ Payabli::ChargeBacks::Types::ChargebackQueryRecords
Retrieves a chargeback record and its details.
-
#get_chargeback_attachment(request_options: {}, **params) ⇒ String
Retrieves a chargeback attachment file by its file name.
- #initialize(client:) ⇒ void constructor
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/charge_backs/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_response(request_options: {}, **params) ⇒ Payabli::ChargeBacks::Types::AddResponseResponse
Add a response to a chargeback or ACH return.
26 27 28 29 30 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 |
# File 'lib/payabli/charge_backs/client.rb', line 26 def add_response(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::ChargeBacks::Types::ResponseChargeBack.new(params).to_h non_body_param_names = %w[Id idempotencyKey] body = request_data.except(*non_body_param_names) headers = {} headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key] request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "ChargeBacks/response/#{URI.encode_uri_component(params[:id].to_s)}", headers: headers, body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::ChargeBacks::Types::AddResponseResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_chargeback(request_options: {}, **params) ⇒ Payabli::ChargeBacks::Types::ChargebackQueryRecords
Retrieves a chargeback record and its details.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/payabli/charge_backs/client.rb', line 69 def get_chargeback(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "ChargeBacks/read/#{URI.encode_uri_component(params[:id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::ChargeBacks::Types::ChargebackQueryRecords.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_chargeback_attachment(request_options: {}, **params) ⇒ String
Retrieves a chargeback attachment file by its file name.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/payabli/charge_backs/client.rb', line 104 def (request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "ChargeBacks/getChargebackAttachments/#{URI.encode_uri_component(params[:id].to_s)}/#{URI.encode_uri_component(params[:file_name].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |