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::Types::AddResponseResponse
Add a response to a chargeback or ACH return.
-
#get_chargeback(request_options: {}, **params) ⇒ Payabli::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::Types::AddResponseResponse
Add a response to a chargeback or ACH return.
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/payabli/charge_backs/client.rb', line 32 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] headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers) 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::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::Types::ChargebackQueryRecords
Retrieves a chargeback record and its details.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/payabli/charge_backs/client.rb', line 79 def get_chargeback(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "ChargeBacks/read/#{URI.encode_uri_component(params[:id].to_s)}", headers: headers, 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::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.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/payabli/charge_backs/client.rb', line 122 def (request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) 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)}", headers: headers, 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 |