Class: Square::TransactionsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/transactions_api.rb

Overview

TransactionsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#capture_transaction(location_id:, transaction_id:) ⇒ CaptureTransactionResponse Hash

Captures a transaction that was created with the [Charge](api-endpoint: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.

Parameters:

  • location_id (String)

    Required parameter: Example:

  • transaction_id (String)

    Required parameter: Example:

Returns:

  • (CaptureTransactionResponse Hash)

    response from the API call



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/square/api/transactions_api.rb', line 93

def capture_transaction(location_id:,
                        transaction_id:)
  warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/locations/{location_id}/transactions/{transaction_id}/capture',
                                 'default')
               .template_param(new_parameter(location_id, key: 'location_id')
                                .should_encode(true))
               .template_param(new_parameter(transaction_id, key: 'transaction_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
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.

Parameters:

  • location_id (String)

    Required parameter: The ID of the location to

  • begin_time (String) (defaults to: nil)

    Optional parameter: The beginning of the

  • end_time (String) (defaults to: nil)

    Optional parameter: The end of the requested

  • sort_order (SortOrder) (defaults to: nil)

    Optional parameter: The order in which

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

Returns:

  • (ListTransactionsResponse Hash)

    response from the API call



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/square/api/transactions_api.rb', line 32

def list_transactions(location_id:,
                      begin_time: nil,
                      end_time: nil,
                      sort_order: nil,
                      cursor: nil)
  warn 'Endpoint list_transactions in TransactionsApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/locations/{location_id}/transactions',
                                 'default')
               .template_param(new_parameter(location_id, key: 'location_id')
                                .should_encode(true))
               .query_param(new_parameter(begin_time, key: 'begin_time'))
               .query_param(new_parameter(end_time, key: 'end_time'))
               .query_param(new_parameter(sort_order, key: 'sort_order'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_transaction(location_id:, transaction_id:) ⇒ RetrieveTransactionResponse Hash

Retrieves details for a single transaction. transaction’s associated location. transaction to retrieve.

Parameters:

  • location_id (String)

    Required parameter: The ID of the

  • transaction_id (String)

    Required parameter: The ID of the

Returns:

  • (RetrieveTransactionResponse Hash)

    response from the API call



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/square/api/transactions_api.rb', line 63

def retrieve_transaction(location_id:,
                         transaction_id:)
  warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/locations/{location_id}/transactions/{transaction_id}',
                                 'default')
               .template_param(new_parameter(location_id, key: 'location_id')
                                .should_encode(true))
               .template_param(new_parameter(transaction_id, key: 'transaction_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#void_transaction(location_id:, transaction_id:) ⇒ VoidTransactionResponse Hash

Cancels a transaction that was created with the [Charge](api-endpoint: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.

Parameters:

  • location_id (String)

    Required parameter: Example:

  • transaction_id (String)

    Required parameter: Example:

Returns:

  • (VoidTransactionResponse Hash)

    response from the API call



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/square/api/transactions_api.rb', line 123

def void_transaction(location_id:,
                     transaction_id:)
  warn 'Endpoint void_transaction in TransactionsApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/locations/{location_id}/transactions/{transaction_id}/void',
                                 'default')
               .template_param(new_parameter(location_id, key: 'location_id')
                                .should_encode(true))
               .template_param(new_parameter(transaction_id, key: 'transaction_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end