Class: Square::RefundsApi
- Defined in:
- lib/square/api/refunds_api.rb
Overview
RefundsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#get_payment_refund(refund_id:) ⇒ GetPaymentRefundResponse Hash
Retrieves a specific refund using the `refund_id`.
-
#initialize(config, http_call_back: nil) ⇒ RefundsApi
constructor
A new instance of RefundsApi.
-
#list_payment_refunds(begin_time: nil, end_time: nil, sort_order: nil, cursor: nil, location_id: nil, status: nil, source_type: nil, limit: nil) ⇒ ListPaymentRefundsResponse Hash
Retrieves a list of refunds for the account making the request.
-
#refund_payment(body:) ⇒ RefundPaymentResponse Hash
Refunds a payment.
Methods inherited from BaseApi
#execute_request, #validate_parameters
Constructor Details
#initialize(config, http_call_back: nil) ⇒ RefundsApi
Returns a new instance of RefundsApi.
4 5 6 |
# File 'lib/square/api/refunds_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#get_payment_refund(refund_id:) ⇒ GetPaymentRefundResponse Hash
Retrieves a specific refund using the `refund_id`. desired `PaymentRefund`.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/square/api/refunds_api.rb', line 132 def get_payment_refund(refund_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/refunds/{refund_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'refund_id' => { 'value' => refund_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#list_payment_refunds(begin_time: nil, end_time: nil, sort_order: nil, cursor: nil, location_id: nil, status: nil, source_type: nil, limit: nil) ⇒ ListPaymentRefundsResponse Hash
Retrieves a list of refunds for the account making the request. Results are eventually consistent, and new refunds or changes to refunds might take several seconds to appear. The maximum results per page is 100. beginning of the requested reporting period, in RFC 3339 format. Default: The current time minus one year. the requested reporting period, in RFC 3339 format. Default: The current time. are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest (default). a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. For more information, see [Pagination](developer.squareup.com/docs/basics/api101/pagination) . location supplied. By default, results are returned for all locations associated with the seller. the given status are returned. For a list of refund status values, see [PaymentRefund]($m/PaymentRefund). Default: If omitted, refunds are returned regardless of their status. with the given source type are returned. - `CARD` - List refunds only for payments where `CARD` was specified as the payment source. Default: If omitted, refunds are returned regardless of the source type. to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. If the supplied value is greater than 100, no more than 100 results are returned. Default: 100
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/square/api/refunds_api.rb', line 43 def list_payment_refunds(begin_time: nil, end_time: nil, sort_order: nil, cursor: nil, location_id: nil, status: nil, source_type: nil, limit: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/refunds' _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'begin_time' => begin_time, 'end_time' => end_time, 'sort_order' => sort_order, 'cursor' => cursor, 'location_id' => location_id, 'status' => status, 'source_type' => source_type, 'limit' => limit ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#refund_payment(body:) ⇒ RefundPaymentResponse Hash
Refunds a payment. You can refund the entire payment amount or a portion of it. You can use this endpoint to refund a card payment or record a refund of a cash or external payment. For more information, see [Refund Payment](developer.squareup.com/docs/payments-api/refund-payments) . containing the fields to POST for the request. See the corresponding object definition for field details.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/square/api/refunds_api.rb', line 99 def refund_payment(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/refunds' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |