Class: Schematic::Webhooks::Client
- Inherits:
-
Object
- Object
- Schematic::Webhooks::Client
- Defined in:
- lib/schematic/webhooks/client.rb
Instance Method Summary collapse
- #count_webhook_events(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::CountWebhookEventsResponse
- #count_webhooks(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::CountWebhooksResponse
- #create_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::CreateWebhookResponse
- #delete_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::DeleteWebhookResponse
- #get_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::GetWebhookResponse
- #get_webhook_event(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::GetWebhookEventResponse
- #initialize(client:) ⇒ void constructor
- #list_webhook_events(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::ListWebhookEventsResponse
- #list_webhooks(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::ListWebhooksResponse
- #send_test_webhook_action(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::SendTestWebhookActionResponse
- #update_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::UpdateWebhookResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/webhooks/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#count_webhook_events(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::CountWebhookEventsResponse
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/schematic/webhooks/client.rb', line 124 def count_webhook_events(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["ids"] = params[:ids] if params.key?(:ids) query_params["q"] = params[:q] if params.key?(:q) query_params["webhook_id"] = params[:webhook_id] if params.key?(:webhook_id) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "webhook-events/count", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::CountWebhookEventsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#count_webhooks(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::CountWebhooksResponse
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/schematic/webhooks/client.rb', line 412 def count_webhooks(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["q"] = params[:q] if params.key?(:q) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "webhooks/count", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::CountWebhooksResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::CreateWebhookResponse
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/schematic/webhooks/client.rb', line 217 def create_webhook(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "webhooks", body: Schematic::Webhooks::Types::CreateWebhookRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::CreateWebhookResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::DeleteWebhookResponse
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/schematic/webhooks/client.rb', line 328 def delete_webhook(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "webhooks/#{URI.encode_uri_component(params[:webhook_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::DeleteWebhookResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::GetWebhookResponse
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/schematic/webhooks/client.rb', line 253 def get_webhook(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "webhooks/#{URI.encode_uri_component(params[:webhook_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::GetWebhookResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_webhook_event(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::GetWebhookEventResponse
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/schematic/webhooks/client.rb', line 79 def get_webhook_event(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "webhook-events/#{URI.encode_uri_component(params[:webhook_event_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::GetWebhookEventResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_webhook_events(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::ListWebhookEventsResponse
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 |
# File 'lib/schematic/webhooks/client.rb', line 36 def list_webhook_events(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["ids"] = params[:ids] if params.key?(:ids) query_params["q"] = params[:q] if params.key?(:q) query_params["webhook_id"] = params[:webhook_id] if params.key?(:webhook_id) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "webhook-events", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::ListWebhookEventsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_webhooks(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::ListWebhooksResponse
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 |
# File 'lib/schematic/webhooks/client.rb', line 173 def list_webhooks(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["q"] = params[:q] if params.key?(:q) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "webhooks", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::ListWebhooksResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#send_test_webhook_action(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::SendTestWebhookActionResponse
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/schematic/webhooks/client.rb', line 366 def send_test_webhook_action(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Webhooks::Types::TestWebhookRequestBody.new(params).to_h non_body_param_names = %w[webhook_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "webhooks/#{URI.encode_uri_component(params[:webhook_id].to_s)}/test", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::SendTestWebhookActionResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_webhook(request_options: {}, **params) ⇒ Schematic::Webhooks::Types::UpdateWebhookResponse
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/schematic/webhooks/client.rb', line 288 def update_webhook(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Webhooks::Types::UpdateWebhookRequestBody.new(params).to_h non_body_param_names = %w[webhook_id] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "webhooks/#{URI.encode_uri_component(params[:webhook_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Webhooks::Types::UpdateWebhookResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |