Class: Square::Terminal::Refunds::Client
- Inherits:
-
Object
- Object
- Square::Terminal::Refunds::Client
- Defined in:
- lib/square/terminal/refunds/client.rb
Instance Method Summary collapse
-
#cancel(request_options: {}, **params) ⇒ Square::Types::CancelTerminalRefundResponse
Cancels an Interac Terminal refund request by refund request ID if the status of the request permits it.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateTerminalRefundResponse
Creates a request to refund an Interac payment completed on a Square Terminal.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetTerminalRefundResponse
Retrieves an Interac Terminal refund object by ID.
- #initialize(client:) ⇒ void constructor
-
#search(request_options: {}, **params) ⇒ Square::Types::SearchTerminalRefundsResponse
Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/square/terminal/refunds/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#cancel(request_options: {}, **params) ⇒ Square::Types::CancelTerminalRefundResponse
Cancels an Interac Terminal refund request by refund request ID if the status of the request permits it.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/square/terminal/refunds/client.rb', line 131 def cancel(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/terminals/refunds/#{params[:terminal_refund_id]}/cancel", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::CancelTerminalRefundResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create(request_options: {}, **params) ⇒ Square::Types::CreateTerminalRefundResponse
Creates a request to refund an Interac payment completed on a Square Terminal. Refunds for Interac payments on a Square Terminal are supported only for Interac debit cards in Canada. Other refunds for Terminal payments should use the Refunds API. For more information, see [Refunds API](api:Refunds).
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/square/terminal/refunds/client.rb', line 27 def create(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/terminals/refunds", body: Square::Terminal::Refunds::Types::CreateTerminalRefundRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::CreateTerminalRefundResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get(request_options: {}, **params) ⇒ Square::Types::GetTerminalRefundResponse
Retrieves an Interac Terminal refund object by ID. Terminal refund objects are available for 30 days.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/square/terminal/refunds/client.rb', line 97 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/terminals/refunds/#{params[:terminal_refund_id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::GetTerminalRefundResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#search(request_options: {}, **params) ⇒ Square::Types::SearchTerminalRefundsResponse
Retrieves a filtered list of Interac Terminal refund requests created by the seller making the request. Terminal refund requests are available for 30 days.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/square/terminal/refunds/client.rb', line 62 def search(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/terminals/refunds/search", body: Square::Terminal::Refunds::Types::SearchTerminalRefundsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::SearchTerminalRefundsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |