class Cpaas::NotificationChannel

@private

Public Class Methods

create_channel(params) click to toggle source
# File lib/cpaas-sdk/resources/notification_channel.rb, line 7
def self.create_channel(params)
  options = {
    body: {
      notificationChannel: {
        channelData: {
          'x-webhookURL': params[:webhook_url]
        },
        channelType: 'webhooks',
        clientCorrelator: Cpaas.api.client_correlator
      }
    }
  }

  response = Cpaas.api.send_request("#{base_url}/channels", options, :post)

  process_response(response) do |res|
    channel = res.dig(:notification_channel)

    {
      channel_id: channel[:callback_url],
      webhook_url: channel[:channel_data][:x_webhook_url],
      channel_type: channel[:channel_type]
    }
  end
end

Private Class Methods

base_url() click to toggle source
# File lib/cpaas-sdk/resources/notification_channel.rb, line 35
def self.base_url
  "/cpaas/notificationchannel/v1/#{Cpaas.api.user_id}"
end