Class: Square::TransactionsApi
- Defined in:
- lib/square/api/transactions_api.rb
Overview
TransactionsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#capture_transaction(location_id:, transaction_id:) ⇒ CaptureTransactionResponse Hash
Captures a transaction that was created with the [Charge]($e/Transactions/Charge) endpoint with a ‘delay_capture` value of `true`.
-
#initialize(config, http_call_back: nil) ⇒ TransactionsApi
constructor
A new instance of TransactionsApi.
-
#list_transactions(location_id:, begin_time: nil, end_time: nil, sort_order: nil, cursor: nil) ⇒ ListTransactionsResponse Hash
Lists transactions for a particular location.
-
#retrieve_transaction(location_id:, transaction_id:) ⇒ RetrieveTransactionResponse Hash
Retrieves details for a single transaction.
-
#void_transaction(location_id:, transaction_id:) ⇒ VoidTransactionResponse Hash
Cancels a transaction that was created with the [Charge]($e/Transactions/Charge) endpoint with a ‘delay_capture` value of `true`.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters
Constructor Details
#initialize(config, http_call_back: nil) ⇒ TransactionsApi
Returns a new instance of TransactionsApi.
4 5 6 |
# File 'lib/square/api/transactions_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#capture_transaction(location_id:, transaction_id:) ⇒ CaptureTransactionResponse Hash
Captures a transaction that was created with the [Charge]($e/Transactions/Charge) endpoint with a ‘delay_capture` value of `true`. See [Delayed capture transactions](developer.squareup.com/docs/payments/transactions/ov erview#delayed-capture) for more information.
129 130 131 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/transactions_api.rb', line 129 def capture_transaction(location_id:, transaction_id:) warn 'Endpoint capture_transaction in TransactionsApi is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true }, 'transaction_id' => { 'value' => transaction_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _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_transactions(location_id:, begin_time: nil, end_time: nil, sort_order: nil, cursor: nil) ⇒ ListTransactionsResponse Hash
Lists transactions for a particular location. Transactions include payment information from sales and exchanges and refund information from returns and exchanges. Max results per [page](developer.squareup.com/docs/working-with-apis/pagination): 50 list transactions for. requested reporting period, in RFC 3339 format. See [Date ranges](developer.squareup.com/docs/build-basics/working-with-date s) for details on date inclusivity/exclusivity. Default value: The current time minus one year. reporting period, in RFC 3339 format. See [Date ranges](developer.squareup.com/docs/build-basics/working-with-date s) for details on date inclusivity/exclusivity. Default value: The current time. results are listed in the response (‘ASC` for oldest first, `DESC` for newest first). Default value: `DESC` a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Paginating results](developer.squareup.com/docs/working-with-apis/pagination) for more information.
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/square/api/transactions_api.rb', line 36 def list_transactions(location_id:, begin_time: nil, end_time: nil, sort_order: nil, cursor: nil) warn 'Endpoint list_transactions in TransactionsApi is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/transactions' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'begin_time' => begin_time, 'end_time' => end_time, 'sort_order' => sort_order, 'cursor' => cursor ) _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 |
#retrieve_transaction(location_id:, transaction_id:) ⇒ RetrieveTransactionResponse Hash
Retrieves details for a single transaction. transaction’s associated location. transaction to retrieve.
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 113 114 115 116 117 |
# File 'lib/square/api/transactions_api.rb', line 85 def retrieve_transaction(location_id:, transaction_id:) warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true }, 'transaction_id' => { 'value' => transaction_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 |
#void_transaction(location_id:, transaction_id:) ⇒ VoidTransactionResponse Hash
Cancels a transaction that was created with the [Charge]($e/Transactions/Charge) endpoint with a ‘delay_capture` value of `true`. See [Delayed capture transactions](developer.squareup.com/docs/payments/transactions/ov erview#delayed-capture) for more information.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/square/api/transactions_api.rb', line 173 def void_transaction(location_id:, transaction_id:) warn 'Endpoint void_transaction in TransactionsApi is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true }, 'transaction_id' => { 'value' => transaction_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _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 |