Class: Square::WebhookSubscriptionsApi
- Defined in:
- lib/square/api/webhook_subscriptions_api.rb
Overview
WebhookSubscriptionsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_webhook_subscription(body:) ⇒ CreateWebhookSubscriptionResponse Hash
Creates a webhook subscription.
-
#delete_webhook_subscription(subscription_id:) ⇒ DeleteWebhookSubscriptionResponse Hash
Deletes a webhook subscription.
-
#initialize(config, http_call_back: nil) ⇒ WebhookSubscriptionsApi
constructor
A new instance of WebhookSubscriptionsApi.
-
#list_webhook_event_types(api_version: nil) ⇒ ListWebhookEventTypesResponse Hash
Lists all webhook event types that can be subscribed to.
-
#list_webhook_subscriptions(cursor: nil, include_disabled: false, sort_order: nil, limit: nil) ⇒ ListWebhookSubscriptionsResponse Hash
Lists all webhook subscriptions owned by your application.
-
#retrieve_webhook_subscription(subscription_id:) ⇒ RetrieveWebhookSubscriptionResponse Hash
Retrieves a webhook subscription identified by its ID.
-
#test_webhook_subscription(subscription_id:, body:) ⇒ TestWebhookSubscriptionResponse Hash
Tests a webhook subscription by sending a test event to the notification URL.
-
#update_webhook_subscription(subscription_id:, body:) ⇒ UpdateWebhookSubscriptionResponse Hash
Updates a webhook subscription.
-
#update_webhook_subscription_signature_key(subscription_id:, body:) ⇒ UpdateWebhookSubscriptionSignatureKeyResponse Hash
Updates a webhook subscription by replacing the existing signature key with a new one.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters, #validate_parameters_types
Constructor Details
#initialize(config, http_call_back: nil) ⇒ WebhookSubscriptionsApi
Returns a new instance of WebhookSubscriptionsApi.
4 5 6 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#create_webhook_subscription(body:) ⇒ CreateWebhookSubscriptionResponse Hash
Creates a webhook subscription. object containing the fields to POST for the request. See the corresponding object definition for field details.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 104 def create_webhook_subscription(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # 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 |
#delete_webhook_subscription(subscription_id:) ⇒ DeleteWebhookSubscriptionResponse Hash
Deletes a webhook subscription. the [Subscription]($m/WebhookSubscription) to delete.
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 162 163 164 165 166 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 137 def delete_webhook_subscription(subscription_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions/{subscription_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => { 'value' => subscription_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.delete( _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_webhook_event_types(api_version: nil) ⇒ ListWebhookEventTypesResponse Hash
Lists all webhook event types that can be subscribed to. to list event types. Setting this field overrides the default version used by the application.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 13 def list_webhook_event_types(api_version: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/event-types' _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'api_version' => api_version ) _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_webhook_subscriptions(cursor: nil, include_disabled: false, sort_order: nil, limit: nil) ⇒ ListWebhookSubscriptionsResponse Hash
Lists all webhook subscriptions owned by your application. a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. For more information, see [Pagination](developer.squareup.com/docs/basics/api101/pagination) . Includes disabled [Subscription]($m/WebhookSubscription)s. By default, all enabled [Subscription]($m/WebhookSubscription)s are returned. by when the [Subscription]($m/WebhookSubscription) was created with the specified order. This field defaults to ASC. to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. The default value of 100 is also the maximum allowed value. If the provided value is greater than 100, it is ignored and the default value is used instead. Default: 100
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 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 62 def list_webhook_subscriptions(cursor: nil, include_disabled: false, sort_order: nil, limit: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions' _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'cursor' => cursor, 'include_disabled' => include_disabled, 'sort_order' => sort_order, '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 |
#retrieve_webhook_subscription(subscription_id:) ⇒ RetrieveWebhookSubscriptionResponse Hash
Retrieves a webhook subscription identified by its ID. the [Subscription]($m/WebhookSubscription) to retrieve.
172 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 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 172 def retrieve_webhook_subscription(subscription_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions/{subscription_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => { 'value' => subscription_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 |
#test_webhook_subscription(subscription_id:, body:) ⇒ TestWebhookSubscriptionResponse Hash
Tests a webhook subscription by sending a test event to the notification URL. the [Subscription]($m/WebhookSubscription) to test. containing the fields to POST for the request. See the corresponding object definition for field details.
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 294 def test_webhook_subscription(subscription_id:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions/{subscription_id}/test' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => { 'value' => subscription_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # 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 |
#update_webhook_subscription(subscription_id:, body:) ⇒ UpdateWebhookSubscriptionResponse Hash
Updates a webhook subscription. the [Subscription]($m/WebhookSubscription) to update. object containing the fields to POST for the request. See the corresponding object definition for field details.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 210 def update_webhook_subscription(subscription_id:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions/{subscription_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => { 'value' => subscription_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.put( _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 |
#update_webhook_subscription_signature_key(subscription_id:, body:) ⇒ UpdateWebhookSubscriptionSignatureKeyResponse Hash
Updates a webhook subscription by replacing the existing signature key with a new one. the [Subscription]($m/WebhookSubscription) to update. parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/square/api/webhook_subscriptions_api.rb', line 252 def update_webhook_subscription_signature_key(subscription_id:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/webhooks/subscriptions/{subscription_id}/signature-key' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => { 'value' => subscription_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # 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 |