lib/backchat-client.rb
##
# Deletes a specific well defined channel from a Backchat stream
#
# ==== Parameters
# *channel*: channel URI to delete
# *stream_slug* (optional): stream where the channel should be deleted (optional as it can be defined
#              using the api_key)
#
# ==== Return
# * *boolean* true if the stream was successfully updated, false in case of failure
#
Deletes a specific well defined channel from a Backchat stream
Parameters
channel*: channel URI to delete
stream_slug* (optional): stream where the channel should be deleted (optional as it can be defined
using the api_key)

Return
*boolean* true if the stream was successfully updated, false in case of failure
Deletes a specific well defined channel from a Backchat stream Parameters channel * : channel URI to delete stream_slug * ( optional ) : stream where the channel should be deleted ( optional as it can be defined using the api_key ) Return * boolean * true if the stream was successfully updated false in case of failure
def delete_channel_from_stream(channel, stream_slug = nil)
      st = find_stream(stream_slug) or raise BackchatClient::Error::NotFoundError.new("stream does not exist")
      if st.is_a?(Array)
        st = st.pop
      end
      channel = Addressable::URI.parse(channel).normalize.to_s
      logger.debug "delete_channel_from_stream: delete channel #{channel} with initial filters #{st['channel_filters']}"
      st["channel_filters"].delete_if{|c|
        begin
          Addressable::URI.parse(c["expanded"]["canonical_uri"]).normalize.to_s.eql?(channel)
        rescue Exception => ex
          logger.warn("Error processing the channel: #{ex.to_s}")
          false
        end
      }
      st["channel_filters"].map! { |channel|
        channel[:channel] = Addressable::URI.parse(channel["expanded"]["canonical_uri"]).normalize.to_s
        channel[:q] = channel["expanded"]["params"]["q"]
        channel[:recorded] = true
        channel.delete_if{|k| ![:channel, :q, :recorded].include?(k)}
      }
      logger.debug "delete_channel_from_stream: updated filters #{st['channel_filters']}"
      stream.update(st["slug"], st)
    end
def delete_channel_from_stream ( channel , stream_slug = nil ) st = find_stream ( stream_slug ) or raise BackchatClient :: Error :: NotFoundError . new ( "stream does not exist" ) if st . is_a? ( Array ) st = st . pop end channel = Addressable :: URI . parse ( channel ) . normalize . to_s logger . debug "delete_channel_from_stream: delete channel #{channel} with initial filters #{st['channel_filters']}" st [ "channel_filters" ] . delete_if { | c | begin Addressable :: URI . parse ( c [ "expanded" ] [ "canonical_uri" ] ) . normalize . to_s . eql? ( channel ) rescue Exception => ex logger . warn ( "Error processing the channel: #{ex.to_s}" ) false end } st [ "channel_filters" ] . map! { | channel | channel [ :channel ] = Addressable :: URI . parse ( channel [ "expanded" ] [ "canonical_uri" ] ) . normalize . to_s channel [ :q ] = channel [ "expanded" ] [ "params" ] [ "q" ] channel [ :recorded ] = true channel . delete_if { | k | ! [ :channel , :q , :recorded ] . include? ( k ) } } logger . debug "delete_channel_from_stream: updated filters #{st['channel_filters']}" stream . update ( st [ "slug" ] , st ) end
Deletes a specific well defined channel from a Backchat stream
 Parameters
channel*: channel URI to delete
stream_slug* (optional): stream where the channel should be deleted (optional as it can be defined
using the api_key)
Deletes a specific well defined channel from a Backchat stream Parameters channel * : channel URI to delete stream_slug * ( optional ) : stream where the channel should be deleted ( optional as it can be defined using the api_key )
channel
<not_specific>
stream_slug
<not_specific>