Class: Wavix::CallWebhooks::Client
- Inherits:
-
Object
- Object
- Wavix::CallWebhooks::Client
- Defined in:
- lib/wavix/call_webhooks/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Wavix::Types::CallWebhook
Registers a callback URL for the
on-callorpost-callevent. -
#delete(request_options: {}, **params) ⇒ Wavix::Types::SuccessResponse
Removes the call webhook for the given event type.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **_params) ⇒ Array[Wavix::Types::CallWebhookListResponseItem]
Returns the configured call webhooks for the authenticated account.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/wavix/call_webhooks/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Wavix::Types::CallWebhook
Registers a callback URL for the on-call or post-call event. Wavix sends a POST callback to the URL when the
event occurs.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/wavix/call_webhooks/client.rb', line 58 def create(request_options: {}, **params) params = Wavix::Internal::Types::Utils.normalize_keys(params) request = Wavix::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v1/calls/webhooks", body: Wavix::CallWebhooks::Types::CallWebhooksCreateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Wavix::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Wavix::Types::CallWebhook.load(response.body) else error_class = Wavix::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ Wavix::Types::SuccessResponse
Removes the call webhook for the given event type. Wavix stops sending callbacks for that event.
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/wavix/call_webhooks/client.rb', line 93 def delete(request_options: {}, **params) params = Wavix::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["event_type"] = params[:event_type] if params.key?(:event_type) request = Wavix::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "v1/calls/webhooks", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Wavix::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Wavix::Types::SuccessResponse.load(response.body) else error_class = Wavix::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **_params) ⇒ Array[Wavix::Types::CallWebhookListResponseItem]
Returns the configured call webhooks for the authenticated account. Wavix sends POST callbacks for on-call and
post-call events.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wavix/call_webhooks/client.rb', line 25 def list(request_options: {}, **_params) request = Wavix::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v1/calls/webhooks", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Wavix::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Wavix::Types::CallWebhookListResponse.load(response.body) else error_class = Wavix::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |