Sha256: c96e543d23b3a0062cf3475cb6540723b520cf3c5473df446a12084fa5e5d290

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

class Twitter::Client
  @@BLOCK_URIS = {
    :add => '/blocks/create',
    :remove => '/blocks/destroy',
  }

  # Provides access to the Twitter Block API.
  #
  # You can add and remove blocks to users using this method.
  #
  # <tt>action</tt> can be any of the following values:
  # * <tt>:add</tt> - to add a block, you would use this <tt>action</tt> value
  # * <tt>:remove</tt> - to remove a block use this.
  #
  # The <tt>value</tt> must be either the user screen name, integer unique user ID or Twitter::User
  # object representation.
  #
  # Examples:
  #  screen_name = 'dictionary'
  #  client.block(:add, 'dictionary')
  #  client.block(:remove, 'dictionary')
  #  id = 1260061
  #  client.block(:add, id)
  #  client.block(:remove, id)
  #  user = Twitter::User.find(id, client)
  #  client.block(:add, user)
  #  client.block(:remove, user)
  def block(action, value)
    raise ArgumentError, "Invalid friend action provided: #{action}" unless @@BLOCK_URIS.keys.member?(action)
    value = value.to_i unless value.is_a?(String)
    uri = "#{@@BLOCK_URIS[action]}/#{value}.json"
    response = http_connect {|conn| create_http_get_request(uri) }
    bless_model(Twitter::User.unmarshal(response.body))
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
cerberus-0.8.0 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7.9 lib/vendor/twitter/lib/twitter/client/blocks.rb
edavis10-cerberus-0.7.8 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7.8 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7.7 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7.6 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7.2 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7.5 lib/vendor/twitter/lib/twitter/client/blocks.rb
cerberus-0.7 lib/vendor/twitter/lib/twitter/client/blocks.rb