Class: Square::Webhooks::EventTypes::Client
- Inherits:
-
Object
- Object
- Square::Webhooks::EventTypes::Client
- Defined in:
- lib/square/webhooks/event_types/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListWebhookEventTypesResponse
Lists all webhook event types that can be subscribed to.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/square/webhooks/event_types/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#list(request_options: {}, **params) ⇒ Square::Types::ListWebhookEventTypesResponse
Lists all webhook event types that can be subscribed to.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/square/webhooks/event_types/client.rb', line 26 def list(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[api_version] query_params = {} query_params["api_version"] = params[:api_version] if params.key?(:api_version) params.except(*query_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/webhooks/event-types", query: query_params, 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::ListWebhookEventTypesResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |