Module: Pixela::Client::ChannelMethods

Included in:
Pixela::Client
Defined in:
lib/pixela/client/channel_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_channel(channel_id:, name:, type:, detail:) ⇒ Pixela::Response

Create a new channel settings for notification.

Examples:

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

Parameters:

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

Returns:

Raises:

See Also:



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pixela/client/channel_methods.rb', line 17

def create_channel(channel_id:, name:, type:, detail:)
  params = {
    id:     channel_id,
    name:   name,
    type:   type,
    detail: detail,
  }

  with_error_handling do
    connection.post("users/#{username}/channels", compact_hash(params)).body
  end
end

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

Create a new channel settings for slack notification.

Examples:

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

Parameters:

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

Returns:

Raises:

See Also:



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pixela/client/channel_methods.rb', line 46

def create_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
  create_channel(
    channel_id: channel_id,
    name: name,
    type: "slack",
    detail: {
      url:         url,
      userName:    user_name,
      channelName: channel_name,
    },
  )
end

#delete_channel(channel_id:) ⇒ Pixela::Response

Delete predefined channel settings.

Examples:

client.delete_channel(channel_id: "my-channel")

Parameters:

  • channel_id (String)

Returns:

Raises:

See Also:



143
144
145
146
147
# File 'lib/pixela/client/channel_methods.rb', line 143

def delete_channel(channel_id:)
  with_error_handling do
    connection.delete("users/#{username}/channels/#{channel_id}").body
  end
end

#get_channelsArray<Pixela::Response>

Get all predefined channels.

Examples:

client.get_channels

Returns:

Raises:

See Also:



69
70
71
72
73
# File 'lib/pixela/client/channel_methods.rb', line 69

def get_channels
  with_error_handling do
    connection.get("users/#{username}/channels").body.channels
  end
end

#update_channel(channel_id:, name:, type:, detail:) ⇒ Pixela::Response

Update predefined channel settings.

Examples:

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

Parameters:

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

Returns:

Raises:

See Also:



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/pixela/client/channel_methods.rb', line 90

def update_channel(channel_id:, name:, type:, detail:)
  params = {
    name:   name,
    type:   type,
    detail: detail,
  }

  with_error_handling do
    connection.put("users/#{username}/channels/#{channel_id}", compact_hash(params)).body
  end
end

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

Update predefined slack channel settings.

Examples:

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

Parameters:

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

Returns:

Raises:

See Also:



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/pixela/client/channel_methods.rb', line 118

def update_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
  update_channel(
    channel_id: channel_id,
    name: name,
    type: "slack",
    detail: {
      url:         url,
      userName:    user_name,
      channelName: channel_name,
    },
  )
end