Skip to content

Commit

Permalink
Allow use of Twitter::Place instead of place_id
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Nov 28, 2013
1 parent 4d05393 commit c2b31dd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/twitter/rest/api/tweets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ def destroy_status(*args)
# @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
# @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
# @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
# @option options [String] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
# @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
# @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def update(status, options={})
object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", options.merge(:status => status))
hash = options.dup
hash[:place_id] = hash.delete(:place).id unless hash[:place].nil?
object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", hash.merge(:status => status))
rescue Twitter::Error::Forbidden => error
handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
end
Expand Down Expand Up @@ -184,14 +187,18 @@ def retweet!(*args)
# @param status [String] The text of your status update, up to 140 characters.
# @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :possibly_sensitive Set to true for content which may not be suitable for every audience.
# @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
# @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
# @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
# @option options [String] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
# @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
# @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def update_with_media(status, media, options={})
object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status))
hash = options.dup
hash[:place_id] = hash.delete(:place).id unless hash[:place].nil?
object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", hash.merge('media[]' => media, 'status' => status))
rescue Twitter::Error::Forbidden => error
handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
end
Expand Down

0 comments on commit c2b31dd

Please sign in to comment.