Class: Pixela::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/pixela/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, channel_id:) ⇒ Channel

Returns a new instance of Channel.

Parameters:



13
14
15
16
# File 'lib/pixela/channel.rb', line 13

def initialize(client:, channel_id:)
  @client = client
  @channel_id = channel_id
end

Instance Attribute Details

#channel_idString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/pixela/channel.rb', line 9

def channel_id
  @channel_id
end

#clientPixela::Client (readonly)

Returns:



5
6
7
# File 'lib/pixela/channel.rb', line 5

def client
  @client
end

#idString (readonly)

Returns:

  • (String)


9
# File 'lib/pixela/channel.rb', line 9

attr_reader :channel_id

Instance Method Details

#create(name:, type:, detail:) ⇒ Pixela::Response

Create a new channel settings for notification.

Examples:

client.channel("my-channel").create(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})

Parameters:

  • name (String)
  • type (String)
  • detail (Hash)

Returns:

Raises:

See Also:



32
33
34
# File 'lib/pixela/channel.rb', line 32

def create(name:, type:, detail:)
  client.create_channel(channel_id: channel_id, name: name, type: type, detail: detail)
end

#create_with_slack(name:, url:, user_name:, channel_name:) ⇒ Pixela::Response

Create a new channel settings for slack notification.

Examples:

client.channel("my-channel").create_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")

Parameters:

  • name (String)
  • url (String)
  • user_name (String)
  • channel_name (String)

Returns:

Raises:

See Also:



51
52
53
# File 'lib/pixela/channel.rb', line 51

def create_with_slack(name:, url:, user_name:, channel_name:)
  client.create_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
end

#deletePixela::Response

Delete predefined channel settings.

Examples:

client.channel("my-channel").delete

Returns:

Raises:

See Also:



102
103
104
# File 'lib/pixela/channel.rb', line 102

def delete
  client.delete_channel(channel_id: channel_id)
end

#update(name:, type:, detail:) ⇒ Pixela::Response

Update predefined channel settings.

Examples:

client.channel("my-channel").update(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})

Parameters:

  • name (String)
  • type (String)
  • detail (Hash)

Returns:

Raises:

See Also:



69
70
71
# File 'lib/pixela/channel.rb', line 69

def update(name:, type:, detail:)
  client.update_channel(channel_id: channel_id, name: name, type: type, detail: detail)
end

#update_with_slack(name:, url:, user_name:, channel_name:) ⇒ Pixela::Response

Update predefined slack channel settings.

Examples:

client.channel("my-channel").update_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")

Parameters:

  • name (String)
  • url (String)
  • user_name (String)
  • channel_name (String)

Returns:

Raises:

See Also:



88
89
90
# File 'lib/pixela/channel.rb', line 88

def update_with_slack(name:, url:, user_name:, channel_name:)
  client.update_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
end