Module: Twitter::API::DirectMessages

### Home Classes Methods

### In Files

- lib/twitter/api/direct_messages.rb

### Methods

- #d
- #direct_message
- #direct_message_create
- #direct_message_destroy
- #direct_messages
- #direct_messages_received
- #direct_messages_sent
- #m

### Included Modules

- Twitter::API::Utils

### Class/Module Index

Quicksearch

- Twitter
- Twitter::API
- Twitter::API::Arguments
- Twitter::API::DirectMessages
- Twitter::API::Favorites
- Twitter::API::FriendsAndFollowers
- Twitter::API::Help
- Twitter::API::Lists
- Twitter::API::PlacesAndGeo
- Twitter::API::SavedSearches
- Twitter::API::Search
- Twitter::API::SpamReporting
- Twitter::API::SuggestedUsers
- Twitter::API::Timelines
- Twitter::API::Trends
- Twitter::API::Tweets
- Twitter::API::Undocumented
- Twitter::API::Users
- Twitter::API::Utils
- Twitter::Action
- Twitter::Action::Favorite
- Twitter::Action::Follow
- Twitter::Action::ListMemberAdded
- Twitter::Action::Mention
- Twitter::Action::Reply
- Twitter::Action::Retweet
- Twitter::Action::Status
- Twitter::Action::Tweet
- Twitter::ActionFactory
- Twitter::Base
- Twitter::BasicUser
- Twitter::Client
- Twitter::Configurable
- Twitter::Configuration
- Twitter::Creatable
- Twitter::Cursor
- Twitter::Default
- Twitter::DirectMessage
- Twitter::Entity
- Twitter::Entity::Hashtag
- Twitter::Entity::Url
- Twitter::Entity::UserMention
- Twitter::Error
- Twitter::Error::AlreadyFavorited
- Twitter::Error::AlreadyRetweeted
- Twitter::Error::BadGateway
- Twitter::Error::BadRequest
- Twitter::Error::ClientError
- Twitter::Error::ConfigurationError
- Twitter::Error::DecodeError
- Twitter::Error::EnhanceYourCalm
- Twitter::Error::Forbidden
- Twitter::Error::GatewayTimeout
- Twitter::Error::IdentityMapKeyError
- Twitter::Error::InternalServerError
- Twitter::Error::NotAcceptable
- Twitter::Error::NotFound
- Twitter::Error::RateLimited
- Twitter::Error::ServerError
- Twitter::Error::ServiceUnavailable
- Twitter::Error::TooManyRequests
- Twitter::Error::Unauthorized
- Twitter::Error::UnprocessableEntity
- Twitter::Exceptable
- Twitter::Factory
- Twitter::Geo
- Twitter::Geo::Point
- Twitter::Geo::Polygon
- Twitter::GeoFactory
- Twitter::Identity
- Twitter::IdentityMap
- Twitter::Language
- Twitter::List
- Twitter::Media
- Twitter::Media::Photo
- Twitter::MediaFactory
- Twitter::Metadata
- Twitter::OEmbed
- Twitter::Place
- Twitter::ProfileBanner
- Twitter::RateLimit
- Twitter::Relationship
- Twitter::Request
- Twitter::Request::MultipartWithFile
- Twitter::Response
- Twitter::Response::ParseJson
- Twitter::Response::RaiseError
- Twitter::SavedSearch
- Twitter::SearchResults
- Twitter::Settings
- Twitter::Size
- Twitter::SourceUser
- Twitter::Status
- Twitter::Suggestion
- Twitter::TargetUser
- Twitter::Trend
- Twitter::Tweet
- Twitter::User
- Twitter::Version
- Enumerable
- Kernel

No matching classes.

# Twitter::API::DirectMessages

### Public Instance Methods

d(user, text, options={}) click to toggle source
Alias for: direct_message_create
direct_message(id, options={}) click to toggle source

Returns a direct message

@see dev.twitter.com/docs/api/1.1/get/direct_messages/show @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::DirectMessage] The requested messages. @param id [Integer] A Tweet IDs. @param options [Hash] A customizable set of options. @example Return the direct message with the id 1825786345

    Twitter.direct_message(1825786345)

    # File lib/twitter/api/direct_messages.rb, line 61
    def direct_message(id, options={})
      options[:id] = id
      object_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/show.json", options)
    end

direct_message_create(user, text, options={}) click to toggle source

Sends a new direct message to the specified user from the authenticating user

@see dev.twitter.com/docs/api/1.1/post/direct_messages/new @rate_limited No @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::DirectMessage] The sent message. @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. @param text [String] The text of your direct message, up to 140 characters. @param options [Hash] A customizable set of options. @example Send a direct message to @sferik from the authenticating user

    Twitter.direct_message_create('sferik', "I'm sending you this message via @gem!")
    Twitter.direct_message_create(7505382, "I'm sending you this message via @gem!")  # Same as above

    # File lib/twitter/api/direct_messages.rb, line 138
    def direct_message_create(user, text, options={})
      merge_user!(options, user)
      options[:text] = text
      object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/new.json", options)
    end

Also aliased as: d, m
direct_message_destroy(*args) click to toggle source

Destroys direct messages

@see dev.twitter.com/docs/api/1.1/post/direct_messages/destroy @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. @rate_limited No @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::DirectMessage>] Deleted direct message. @overload direct_message_destroy(*ids)

    @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
    @example Destroys the direct message with the ID 1825785544
      Twitter.direct_message_destroy(1825785544)

@overload direct_message_destroy(*ids, options)

    @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
    @param options [Hash] A customizable set of options.

    # File lib/twitter/api/direct_messages.rb, line 121
    def direct_message_destroy(*args)
      threaded_object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/destroy.json", args)
    end

direct_messages(*args) click to toggle source

@note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::DirectMessage>] The requested messages. @overload direct_messages(options={})

    Returns the 20 most recent direct messages sent to the authenticating user

    @see https://dev.twitter.com/docs/api/1.1/get/direct_messages
    @param options [Hash] A customizable set of options.
    @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
    @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
    @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
    @option options [Integer] :page Specifies the page of results to retrieve.
    @example Return the 20 most recent direct messages sent to the authenticating user
      Twitter.direct_messages

@overload direct_messages(*ids)

    Returns direct messages

    @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show
    @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
    @example Return the direct message with the id 1825786345
      Twitter.direct_messages(1825786345)

@overload direct_messages(*ids, options)

    Returns direct messages

    @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show
    @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
    @param options [Hash] A customizable set of options.

    # File lib/twitter/api/direct_messages.rb, line 95
    def direct_messages(*args)
      arguments = Twitter::API::Arguments.new(args)
      if arguments.empty?
        direct_messages_received(arguments.options)
      else
        arguments.flatten.threaded_map do |id|
          direct_message(id, arguments.options)
        end
      end
    end

direct_messages_received(options={}) click to toggle source

Returns the 20 most recent direct messages sent to the authenticating user

@see dev.twitter.com/docs/api/1.1/get/direct_messages @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::DirectMessage>] Direct messages sent to the authenticating user. @param options [Hash] A customizable set of options. @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200. @option options [Integer] :page Specifies the page of results to retrieve. @example Return the 20 most recent direct messages sent to the authenticating user

    Twitter.direct_messages_received

    # File lib/twitter/api/direct_messages.rb, line 26
    def direct_messages_received(options={})
      objects_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages.json", options)
    end

direct_messages_sent(options={}) click to toggle source

Returns the 20 most recent direct messages sent by the authenticating user

@see dev.twitter.com/docs/api/1.1/get/direct_messages/sent @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::DirectMessage>] Direct messages sent by the authenticating user. @param options [Hash] A customizable set of options. @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200. @option options [Integer] :page Specifies the page of results to retrieve. @example Return the 20 most recent direct messages sent by the authenticating user

    Twitter.direct_messages_sent

    # File lib/twitter/api/direct_messages.rb, line 45
    def direct_messages_sent(options={})
      objects_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/sent.json", options)
    end

m(user, text, options={}) click to toggle source
Alias for: direct_message_create

[Validate]

Generated with the Darkfish Rdoc Generator 2.