Module: Flickrie::ApiMethods

Extended by:
Deprecatable
Includes:
Callable
Included in:
Flickrie, Instance
Defined in:
lib/flickrie/api_methods.rb

Instance Method Summary collapse

Methods included from Deprecatable

deprecated_alias

Methods included from Callable

#client, #upload_client

Instance Method Details

#add_media_to_set(set_id, media_id, params = {}) ⇒ nil Also known as: add_photo_to_set, add_video_to_set

Note:

This method requires authentication with "write" permissions.

Adds existing photo/video to a set with the given ID.

Parameters:

  • set_id (Fixnum, String)

Returns:

  • (nil)

Flickr API method:


875
876
877
# File 'lib/flickrie/api_methods.rb', line 875

def add_media_to_set(set_id, media_id, params = {})
  make_request(set_id, media_id, params)
end

#check_upload_tickets(tickets, params = {}) ⇒ Flickrie::Ticket

Fetches upload tickets with given IDs. Example:

photo = File.open("...")
ticket_id = Flickrie.upload(photo, async: 1)
sleep(10)

ticket = Flickrie.check_upload_tickets(ticket_id)
if ticket.complete?
  puts "Photo was uploaded, and its ID is #{ticket.photo_id}"
end

Parameters:

  • tickets (String)

    A space delimited string with ticket IDs

Returns:

Flickr API method:


861
862
863
864
865
866
# File 'lib/flickrie/api_methods.rb', line 861

def check_upload_tickets(tickets, params = {})
  ticket_ids = tickets.join(',') rescue tickets
  response = make_request(ticket_ids, params)
  response.body['uploader']['ticket'].
    map { |info| Ticket.new(info) }
end

#comment_media(media_id, comment, params = {}) ⇒ String Also known as: comment_photo, comment_video

Note:

This method requires authentication with "write" permissions.

Comment on a photo/video.

Returns:

  • (String)

    Comment's ID

Flickr API method:


736
737
738
739
# File 'lib/flickrie/api_methods.rb', line 736

def comment_media(media_id, comment, params = {})
  response = make_request(media_id, comment, params)
  response.body["comment"]["id"]
end

#create_set(params = {}) ⇒ Flickrie::Set

Note:

This method requires authentication with "write" permissions.

Creates a new set.

Returns:

Flickr API method:


887
888
889
890
# File 'lib/flickrie/api_methods.rb', line 887

def create_set(params = {})
  response = make_request(params)
  Set.new(response.body['photoset'], self)
end

#delete_media(media_id, params = {}) ⇒ nil Also known as: delete_photo, delete_video

Note:

This method requires authentication with "delete" permissions.

Deletes the photo/video with the given ID.

Returns:

  • (nil)

Flickr API method:


200
201
202
203
# File 'lib/flickrie/api_methods.rb', line 200

def delete_media(media_id, params = {})
  make_request(media_id, params)
  nil
end

#delete_media_comment(comment_id, params = {}) ⇒ nil Also known as: delete_photo_comment, delete_video_comment

Note:

This method requires authentication with "write" permissions.

Delete a comment.

Returns:

  • (nil)

Flickr API method:


749
750
751
752
# File 'lib/flickrie/api_methods.rb', line 749

def delete_media_comment(comment_id, params = {})
  make_request(comment_id, params)
  nil
end

#delete_set(set_id, params = {}) ⇒ nil

Note:

This method requires authentication with "write" permissions.

Deletes a set.

Parameters:

  • set_id (Fixnum, String)

Returns:

  • (nil)

Flickr API method:


899
900
901
902
# File 'lib/flickrie/api_methods.rb', line 899

def delete_set(set_id, params = {})
  make_request(set_id, params)
  nil
end

#edit_media_comment(comment_id, comment, params = {}) ⇒ nil Also known as: edit_photo_comment, edit_video_comment

Note:

This method requires authentication with "write" permissions.

Edit a specific comment.

Returns:

  • (nil)

Flickr API method:


762
763
764
765
# File 'lib/flickrie/api_methods.rb', line 762

def edit_media_comment(comment_id, comment, params = {})
  make_request(comment_id, comment, params)
  nil
end

#edit_set_media(set_id, params = {}) ⇒ nil Also known as: edit_set_photos, edit_set_videos

Note:

This method requires authentication with "write" permissions.

Edits photos/videos of a set with the given ID.

Parameters:

  • set_id (Fixnum, String)

Returns:

  • (nil)

Flickr API method:


923
924
925
926
# File 'lib/flickrie/api_methods.rb', line 923

def edit_set_media(set_id, params = {})
  make_request(set_id, params)
  nil
end

#edit_set_metadata(set_id, params = {}) ⇒ nil

Note:

This method requires authentication with "write" permissions.

Modifies metadata of a set.

Parameters:

  • set_id (Fixnum, String)

Returns:

  • (nil)

Flickr API method:


911
912
913
914
# File 'lib/flickrie/api_methods.rb', line 911

def (set_id, params = {})
  make_request(set_id, params)
  nil
end

#find_user_by_email(email, params = {}) ⇒ Flickrie::User

Fetches the Flickr user with the given email.

Returns:

Flickr API method:


57
58
59
60
# File 'lib/flickrie/api_methods.rb', line 57

def find_user_by_email(email, params = {})
  response = make_request(email, params)
  User.new(response.body['user'], self)
end

#find_user_by_username(username, params = {}) ⇒ Flickrie::User

Fetches the Flickr user with the given username.

Returns:

Flickr API method:


66
67
68
69
# File 'lib/flickrie/api_methods.rb', line 66

def find_user_by_username(username, params = {})
  response = make_request(username, params)
  User.new(response.body['user'], self)
end

#get_licenses(params = {}) ⇒ Array<Flickrie::License>

Fetches all available types of licenses.

Returns:

Flickr API method:


816
817
818
819
# File 'lib/flickrie/api_methods.rb', line 816

def get_licenses(params = {})
  response = make_request(params)
  License.from_hash(response.body['licenses']['license'])
end

#get_media_comments(media_id, params = {}) ⇒ Array<Flickrie::Comment> Also known as: get_photo_comments, get_video_comments

Get list of comments of a photo/video.

Returns:

Flickr API method:


773
774
775
776
# File 'lib/flickrie/api_methods.rb', line 773

def get_media_comments(media_id, params = {})
  response = make_request(media_id, params)
  response.body["comments"]["comment"].map { |hash| Flickrie::Comment.new(hash, self) }
end

#get_media_context(media_id, params = {}) ⇒ Flickrie::MediaContext Also known as: get_photo_context, get_video_context

Fetches context of the photo/video with the given ID. Example:

context = Flickrie.get_photo_context(37124234)
context.count    # => 23
context.previous # => #<Photo: id=2433240, ...>
context.next     # => #<Video: id=1282404, ...>

Returns:

Flickr API method:


277
278
279
280
# File 'lib/flickrie/api_methods.rb', line 277

def get_media_context(media_id, params = {})
  response = make_request(media_id, params)
  MediaContext.new(response.body, self)
end

#get_media_counts(params = {}) ⇒ Flickrie::MediaCount Also known as: get_photos_counts, get_videos_counts

Fetches numbers of photos and videos for given date ranges. Example:

require 'date'
dates = [DateTime.parse("3rd Jan 2011").to_time, DateTime.parse("11th Aug 2011").to_time]
counts = Flickrie.get_media_counts(taken_dates: dates.map(&:to_i).join(','))

count = counts.first
count.value            # => 24
count.date_range       # => 2011-01-03 01:00:00 +0100..2011-08-11 02:00:00 +0200
count.date_range.begin # => 2011-01-03 01:00:00 +0100
count.from             # => 2011-01-03 01:00:00 +0100

Returns:

Flickr API method:


298
299
300
301
# File 'lib/flickrie/api_methods.rb', line 298

def get_media_counts(params = {})
  response = make_request(params)
  MediaCount.new_collection(response.body['photocounts'])
end

#get_media_from_contacts(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches photos and videos from contacts of the user who authenticated.


213
214
215
216
# File 'lib/flickrie/api_methods.rb', line 213

def get_media_from_contacts(params = {})
  response = make_request(params)
  Media.new_collection(response.body['photos'], self)
end

#get_media_from_set(set_id, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Fetches photos and videos from a set with the given ID.


962
963
964
965
# File 'lib/flickrie/api_methods.rb', line 962

def get_media_from_set(set_id, params = {})
  response = make_request(set_id, {media: 'all'}.merge(params))
  Media.new_collection(response.body['photoset'], self)
end

#get_media_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches photos and videos from the Flickr user with the given NSID.


77
78
79
80
# File 'lib/flickrie/api_methods.rb', line 77

def get_media_from_user(nsid, params = {})
  response = make_request(nsid, params)
  Media.new_collection(response.body['photos'], self)
end

#get_media_info(media_id, params = {}) ⇒ Flickrie::Photo, Flickrie::Video Also known as: get_photo_info, get_video_info

Fetches info of the photo/video with the given ID.

Parameters:

  • media_id (String, Fixnum)

Returns:

Flickr API method:


370
371
372
373
# File 'lib/flickrie/api_methods.rb', line 370

def get_media_info(media_id, params = {})
  response = make_request(media_id, params)
  Media.new(response.body['photo'], self)
end

#get_media_not_in_set(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches photos and videos from the authenticated user that are not in any set.


384
385
386
387
# File 'lib/flickrie/api_methods.rb', line 384

def get_media_not_in_set(params = {})
  response = make_request({media: 'all'}.merge(params))
  Media.new_collection(response.body['photos'], self)
end

#get_media_of_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Fetches photos and videos containing a Flickr user with the given NSID.


107
108
109
110
# File 'lib/flickrie/api_methods.rb', line 107

def get_media_of_user(nsid, params = {})
  response = make_request(nsid, params)
  Media.new_collection(response.body['photos'], self)
end

#get_media_with_geo_data(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches geo-tagged photos and videos from the authenticated user.


519
520
521
522
# File 'lib/flickrie/api_methods.rb', line 519

def get_media_with_geo_data(params = {})
  response = make_request({media: 'all'}.merge(params))
  Media.new_collection(response.body['photos'], self)
end

#get_media_without_geo_data(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches photos and videos from the authenticated user that are not geo-tagged.


549
550
551
552
# File 'lib/flickrie/api_methods.rb', line 549

def get_media_without_geo_data(params = {})
  response = make_request({media: 'all'}.merge(params))
  Media.new_collection(response.body['photos'], self)
end

#get_methods(params = {}) ⇒ Array<String>

Fetches the list of all API methods.

Returns:

  • (Array<String>)

Flickr API method:


1044
1045
1046
1047
# File 'lib/flickrie/api_methods.rb', line 1044

def get_methods(params = {})
  response = make_request(params)
  response.body["methods"]["method"]
end

#get_photo_exif(photo_id, params = {}) ⇒ Flickrie::Photo

Fetches the exif for the photo with the given ID. Example:

photo = Flickrie.get_photo_exif(27234987)
photo.exif.get('Model') # => 'Canon PowerShot G12'

photo.exif.get('X-Resolution', data: 'raw')   # => '180'
photo.exif.get('X-Resolution', data: 'clean') # => '180 dpi'
photo.exif.get('X-Resolution')                   # => '180 dpi'

Parameters:

  • photo_id (String, Fixnum)

Returns:

Flickr API method:


317
318
319
320
# File 'lib/flickrie/api_methods.rb', line 317

def get_photo_exif(photo_id, params = {})
  response = make_request(photo_id, params)
  Photo.new(response.body['photo'], self)
end

#get_photo_favorites(photo_id, params = {}) ⇒ Flickrie::Photo

Fetches the list of users who favorited the photo with the given ID. Example:

photo = Flickrie.get_photo_favorites(24810948)
photo.favorites.first.username # => "John Smith"

Parameters:

  • photo_id (String, Fixnum)

Returns:

Flickr API method:


347
348
349
350
# File 'lib/flickrie/api_methods.rb', line 347

def get_photo_favorites(photo_id, params = {})
  response = make_request(photo_id, params)
  Photo.new(response.body['photo'], self)
end

#get_photo_permissions(photo_id, params = {}) ⇒ Flickrie::Photo

Note:

This method requires authentication with "read" permissions.

Gets permissions of a photo with the given ID.

Returns:

Flickr API method:


418
419
420
421
# File 'lib/flickrie/api_methods.rb', line 418

def get_photo_permissions(photo_id, params = {})
  response = make_request(photo_id, params)
  Photo.new(response.body['perms'], self)
end

#get_photo_sizes(photo_id, params = {}) ⇒ Flickrie::Photo

Fetches the sizes of the photo with the given ID. Example:

photo = Flickrie.get_photo_sizes(242348)
photo.medium!(500)
photo.size       # => "Medium 500"
photo.source_url # => "http://farm8.staticflickr.com/7090/7093101501_9337f28800.jpg"

Parameters:

  • photo_id (String, Fixnum)

Returns:

Flickr API method:


466
467
468
469
# File 'lib/flickrie/api_methods.rb', line 466

def get_photo_sizes(photo_id, params = {})
  response = make_request(photo_id, params)
  Photo.new(response.body['sizes'], self)
end

#get_photos_from_contacts(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches photos from contacts of the user who authenticated.


224
225
226
# File 'lib/flickrie/api_methods.rb', line 224

def get_photos_from_contacts(params = {})
  get_media_from_contacts(params).select { |media| media.is_a?(Photo) }
end

#get_photos_from_set(set_id, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Fetches photos from a set with the given ID.


971
972
973
# File 'lib/flickrie/api_methods.rb', line 971

def get_photos_from_set(set_id, params = {})
  get_media_from_set(set_id, {media: 'photos'}.merge(params))
end

#get_photos_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches photos from the Flickr user with the given NSID.


88
89
90
# File 'lib/flickrie/api_methods.rb', line 88

def get_photos_from_user(nsid, params = {})
  get_media_from_user(nsid, params).select { |media| media.is_a?(Photo) }
end

#get_photos_not_in_set(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches photos from the authenticated user that are not in any set.


396
397
398
# File 'lib/flickrie/api_methods.rb', line 396

def get_photos_not_in_set(params = {})
  get_media_not_in_set({media: "photos"}.merge(params))
end

#get_photos_of_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Fetches photos containing a Flickr user with the given NSID.


116
117
118
# File 'lib/flickrie/api_methods.rb', line 116

def get_photos_of_user(nsid, params = {})
  get_media_of_user(nsid, params).select { |media| media.is_a?(Photo) }
end

#get_photos_with_geo_data(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches geo-tagged photos from the authenticated user.


529
530
531
# File 'lib/flickrie/api_methods.rb', line 529

def get_photos_with_geo_data(params = {})
  get_media_with_geo_data({media: 'photos'}.merge(params))
end

#get_photos_without_geo_data(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches photos from the authenticated user that are not geo-tagged.


559
560
561
# File 'lib/flickrie/api_methods.rb', line 559

def get_photos_without_geo_data(params = {})
  get_media_with_geo_data({media: 'photos'}.merge(params))
end

#get_public_media_from_contacts(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Fetches public photos and videos from contacts of the user with the given NSID.


244
245
246
247
# File 'lib/flickrie/api_methods.rb', line 244

def get_public_media_from_contacts(nsid, params = {})
  response = make_request(nsid, params)
  Media.new_collection(response.body['photos'], self)
end

#get_public_media_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Fetches public photos and videos from the Flickr user with the given NSID.


134
135
136
137
# File 'lib/flickrie/api_methods.rb', line 134

def get_public_media_from_user(nsid, params = {})
  response = make_request(nsid, params)
  Media.new_collection(response.body['photos'], self)
end

#get_public_photos_from_contacts(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Fetches public photos from contacts of the user with the given NSID.


254
255
256
# File 'lib/flickrie/api_methods.rb', line 254

def get_public_photos_from_contacts(nsid, params = {})
  get_public_media_from_contacts(nsid, params).select { |media| media.is_a?(Photo) }
end

#get_public_photos_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Fetches public photos from the Flickr user with the given NSID.


143
144
145
# File 'lib/flickrie/api_methods.rb', line 143

def get_public_photos_from_user(nsid, params = {})
  get_public_media_from_user(nsid, params).select { |media| media.is_a?(Photo) }
end

#get_public_videos_from_contacts(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Fetches public videos from contacts of the user with the given NSID.


263
264
265
# File 'lib/flickrie/api_methods.rb', line 263

def get_public_videos_from_contacts(nsid, params = {})
  get_public_media_from_contacts(nsid, params).select { |media| media.is_a?(Video) }
end

#get_public_videos_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Fetches public videos from the Flickr user with the given NSID.


151
152
153
# File 'lib/flickrie/api_methods.rb', line 151

def get_public_videos_from_user(nsid, params = {})
  get_public_media_from_user(nsid, params).select { |media| media.is_a?(Video) }
end

#get_recent_media(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Fetches the latest photos and videos uploaded to Flickr.


437
438
439
440
# File 'lib/flickrie/api_methods.rb', line 437

def get_recent_media(params = {})
  response = make_request(params)
  Media.new_collection(response.body['photos'], self)
end

#get_recent_photos(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Fetches the latest photos uploaded to Flickr.


445
446
447
# File 'lib/flickrie/api_methods.rb', line 445

def get_recent_photos(params = {})
  get_recent_media(params).select { |media| media.is_a?(Photo) }
end

#get_recent_videos(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Fetches the latest videos uploaded to Flickr.


452
453
454
# File 'lib/flickrie/api_methods.rb', line 452

def get_recent_videos(params = {})
  get_recent_media(params).select { |media| media.is_a?(Video) }
end

#get_recently_commented_media_from_contacts(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Get list of photos/videos that have been recently commented by the contacts of the authenticated user.


787
788
789
790
# File 'lib/flickrie/api_methods.rb', line 787

def get_recently_commented_media_from_contacts(params = {})
  response = make_request(params)
  Media.new_collection(response.body["photos"], self)
end

#get_recently_commented_photos_from_contacts(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Get list of photos that have been recently commented by the contacts of the authenticated user.


798
799
800
# File 'lib/flickrie/api_methods.rb', line 798

def get_recently_commented_photos_from_contacts(params = {})
  get_recently_commented_media_from_contacts(params).select { |media| media.is_a?(Photo) }
end

#get_recently_commented_videos_from_contacts(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Get list of videos that have been recently commented by the contacts of the authenticated user.


808
809
810
# File 'lib/flickrie/api_methods.rb', line 808

def get_recently_commented_videos_from_contacts(params = {})
  get_recently_commented_media_from_contacts(params).select { |media| media.is_a?(Video) }
end

#get_recently_updated_media(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches photos and videos from the authenticated user that have recently been updated.


579
580
581
582
# File 'lib/flickrie/api_methods.rb', line 579

def get_recently_updated_media(params = {})
  response = make_request(params)
  Media.new_collection(response.body['photos'], self)
end

#get_recently_updated_photos(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches photos from the authenticated user that have recently been updated.


590
591
592
# File 'lib/flickrie/api_methods.rb', line 590

def get_recently_updated_photos(params = {})
  recently_updated_media(params).select { |media| media.is_a?(Photo) }
end

#get_recently_updated_videos(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches videos from the authenticated user that have recently been updated.


600
601
602
# File 'lib/flickrie/api_methods.rb', line 600

def get_recently_updated_videos(params = {})
  recently_updated_media(params).select { |media| media.is_a?(Video) }
end

#get_set_context(set_id, media_id, params = {}) ⇒ Flickrie::MediaContext

Returns next and previous photos/videos for a photo/video in a set

Returns:

Flickr API method:


934
935
936
937
# File 'lib/flickrie/api_methods.rb', line 934

def get_set_context(set_id, media_id, params = {})
  response = make_request(set_id, media_id, params)
  MediaContext.new(response.body, self)
end

#get_set_info(set_id, params = {}) ⇒ Flickrie::Set

Fetches information about the set with the given ID.

Returns:

Flickr API method:


943
944
945
946
# File 'lib/flickrie/api_methods.rb', line 943

def get_set_info(set_id, params = {})
  response = make_request(set_id, params)
  Set.new(response.body['photoset'], self)
end

#get_sets_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Set>

Fetches sets from a user with the given NSID.


952
953
954
955
# File 'lib/flickrie/api_methods.rb', line 952

def get_sets_from_user(nsid, params = {})
  response = make_request(nsid, params)
  Set.new_collection(response.body['photosets'], self)
end

#get_untagged_media(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches photos and videos from the authenticated user that have no tags.


490
491
492
493
# File 'lib/flickrie/api_methods.rb', line 490

def get_untagged_media(params = {})
  response = make_request({media: 'all'}.merge(params))
  Media.new_collection(response.body['photos'], self)
end

#get_untagged_photos(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Note:

This method requires authentication with "read" permissions.

Fetches photos from the authenticated user that have no tags.


500
501
502
# File 'lib/flickrie/api_methods.rb', line 500

def get_untagged_photos(params = {})
  get_untagged_media({media: 'photos'}.merge(params))
end

#get_untagged_videos(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches videos from the authenticated user that have no tags.


509
510
511
# File 'lib/flickrie/api_methods.rb', line 509

def get_untagged_videos(params = {})
  get_untagged_media({media: 'videos'}.merge(params))
end

#get_upload_status(params = {}) ⇒ Flickrie::User

Note:

This method requires authentication with "read" permissions.

Returns the upload status of the user who is currently authenticated.

Returns:

See Also:

Flickr API method:


172
173
174
175
# File 'lib/flickrie/api_methods.rb', line 172

def get_upload_status(params = {})
  response = make_request(params)
  User.new(response.body['user'], self)
end

#get_user_info(nsid, params = {}) ⇒ Flickrie::User

Fetches the Flickr user with the given NSID.

Returns:

Flickr API method:


160
161
162
163
# File 'lib/flickrie/api_methods.rb', line 160

def (nsid, params = {})
  response = make_request(nsid, params)
  User.new(response.body['person'], self)
end

#get_video_exif(video_id, params = {}) ⇒ Flickrie::Video

Fetches the exif for the video with the given ID. Example:

video = Flickrie.get_video_exif(27234987)
video.exif.get('Model') # => 'Canon PowerShot G12'

video.exif.get('X-Resolution', data: 'raw')   # => '180'
video.exif.get('X-Resolution', data: 'clean') # => '180 dpi'
video.exif.get('X-Resolution')                   # => '180 dpi'

Parameters:

  • video_id (String, Fixnum)

Returns:

Flickr API method:


333
334
335
336
# File 'lib/flickrie/api_methods.rb', line 333

def get_video_exif(video_id, params = {})
  response = make_request(video_id, params)
  Video.new(response.body['photo'], self)
end

#get_video_favorites(video_id, params = {}) ⇒ Flickrie::Video

Fetches the list of users who favorited the video with the given ID. Example:

video = Flickrie.get_video_favorites(24810948)
video.favorites.first.username # => "John Smith"

Parameters:

  • video_id (String, Fixnum)

Returns:

Flickr API method:


360
361
362
363
# File 'lib/flickrie/api_methods.rb', line 360

def get_video_favorites(video_id, params = {})
  response = make_request(video_id, params)
  Video.new(response.body['photo'], self)
end

#get_video_permissions(video_id, params = {}) ⇒ Flickrie::Video

Note:

This method requires authentication with "read" permissions.

Gets permissions of a video with the given ID.

Returns:

Flickr API method:


428
429
430
431
# File 'lib/flickrie/api_methods.rb', line 428

def get_video_permissions(video_id, params = {})
  response = make_request(video_id, params)
  Video.new(response.body['perms'], self)
end

#get_video_sizes(video_id, params = {}) ⇒ Flickrie::Video

Fetches the sizes of the video with the given ID. Example:

video = Flickrie.get_video_sizes(438492)
video.download_url # => "..."

Parameters:

  • video_id (String, Fixnum)

Returns:

Flickr API method:


478
479
480
481
# File 'lib/flickrie/api_methods.rb', line 478

def get_video_sizes(video_id, params = {})
  response = make_request(video_id, params)
  Video.new(response.body['sizes'], self)
end

#get_videos_from_contacts(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches videos from contacts of the user who authenticated.


234
235
236
# File 'lib/flickrie/api_methods.rb', line 234

def get_videos_from_contacts(params = {})
  get_media_from_contacts(params).select { |media| media.is_a?(Video) }
end

#get_videos_from_set(set_id, params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Fetches videos from a set with the given ID.


979
980
981
# File 'lib/flickrie/api_methods.rb', line 979

def get_videos_from_set(set_id, params = {})
  get_media_from_set(set_id, {media: 'videos'}.merge(params))
end

#get_videos_from_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches videos from the Flickr user with the given NSID.


98
99
100
# File 'lib/flickrie/api_methods.rb', line 98

def get_videos_from_user(nsid, params = {})
  get_media_from_user(nsid, params).select { |media| media.is_a?(Video) }
end

#get_videos_not_in_set(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches videos from the authenticated user that are not in any set.


407
408
409
# File 'lib/flickrie/api_methods.rb', line 407

def get_videos_not_in_set(params = {})
  get_media_not_in_set({media: "videos"}.merge(params))
end

#get_videos_of_user(nsid, params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Fetches videos containing a Flickr user with the given NSID.


124
125
126
# File 'lib/flickrie/api_methods.rb', line 124

def get_videos_of_user(nsid, params = {})
  get_media_of_user(nsid, params).select { |media| media.is_a?(Video) }
end

#get_videos_with_geo_data(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches geo-tagged videos from the authenticated user.


538
539
540
# File 'lib/flickrie/api_methods.rb', line 538

def get_videos_with_geo_data(params = {})
  get_media_with_geo_data({media: 'videos'}.merge(params))
end

#get_videos_without_geo_data(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Note:

This method requires authentication with "read" permissions.

Fetches videos from the authenticated user that are not geo-tagged.


568
569
570
# File 'lib/flickrie/api_methods.rb', line 568

def get_videos_without_geo_data(params = {})
  get_media_with_geo_data({media: 'videos'}.merge(params))
end

#order_sets(set_ids, params = {}) ⇒ nil

Note:

This method requires authentication with "write" permissions.

Sets the order of sets belonging to the authenticated user.

Parameters:

  • set_ids (String)

    A comma delimited list of set IDs

Returns:

  • (nil)

Flickr API method:


991
992
993
994
# File 'lib/flickrie/api_methods.rb', line 991

def order_sets(set_ids, params = {})
  make_request(set_ids, params)
  nil
end

#remove_media_from_set(set_id, media_ids, params = {}) ⇒ nil Also known as: remove_photos_from_set, remove_videos_from_set

Note:

This method requires authentication with "write" permissions.

Removes photos/videos from a set.

Parameters:

  • media_ids (String)

    A comma delimited list of photo/video IDs

Returns:

  • (nil)

Flickr API method:


1003
1004
1005
1006
# File 'lib/flickrie/api_methods.rb', line 1003

def remove_media_from_set(set_id, media_ids, params = {})
  make_request(set_id, media_ids, params)
  nil
end

#reorder_media_in_set(set_id, media_ids, params = {}) ⇒ nil Also known as: reorder_photos_in_set, reorder_videos_in_set

Note:

This method requires authentication with "write" permissions.

Reorders photos/videos inside a set.

Parameters:

  • media_ids (String)

    A comma delimited list of photo/video IDs

Returns:

  • (nil)

Flickr API method:


1017
1018
1019
1020
# File 'lib/flickrie/api_methods.rb', line 1017

def reorder_media_in_set(set_id, media_ids, params = {})
  make_request(set_id, media_ids, params)
  nil
end

#replace(media, media_id, params = {}) ⇒ String

Note:

This method requires authentication with "write" permissions.

For replacing photos and videos on Flickr. Example:

path = File.expand_path("photo.jpg")
photo_id = 42374 # ID of the photo to be replaced
id = Flickrie.replace(path, photo_id)

If the async: 1 option is passed, returns the ticket ID (see #check_upload_tickets).

Parameters:

  • media (File, String)

    A file or a path to the file you want to upload

  • media_id (String, Fixnum)

    The ID of the photo/video to be replaced

  • params (Hash) (defaults to: {})

    Options for replacing (see this page)

Returns:

  • (String)

    New photo's ID, or ticket's ID, if async: 1 is passed


44
45
46
47
48
49
50
51
# File 'lib/flickrie/api_methods.rb', line 44

def replace(media, media_id, params = {})
  response = make_request(media, media_id, params)
  if params[:async] == 1
    response.body['rsp']['ticketid']
  else
    response.body['rsp']['photoid']
  end
end

#rotate_media(media_id, degrees, params = {}) ⇒ nil Also known as: rotate_photo, rotate_video

Note:

This method requires authentication with "write" permissions.

Rotates a photo/video.

Returns:

  • (nil)

Flickr API method:


840
841
842
843
# File 'lib/flickrie/api_methods.rb', line 840

def rotate_media(media_id, degrees, params = {})
  make_request(media_id, degrees, params)
  nil
end

#search_media(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo, Flickrie::Video>

Fetches photos and videos matching a certain criteria.


626
627
628
629
# File 'lib/flickrie/api_methods.rb', line 626

def search_media(params = {})
  response = make_request({media: 'all'}.merge(params))
  Media.new_collection(response.body['photos'], self)
end

#search_photos(params = {}) ⇒ Flickrie::Collection<Flickrie::Photo>

Fetches photos matching a certain criteria.


634
635
636
# File 'lib/flickrie/api_methods.rb', line 634

def search_photos(params = {})
  search_media({media: 'photos'}.merge(params))
end

#search_videos(params = {}) ⇒ Flickrie::Collection<Flickrie::Video>

Fetches videos matching a certain criteria.


641
642
643
# File 'lib/flickrie/api_methods.rb', line 641

def search_videos(params = {})
  search_media({media: 'videos'}.merge(params))
end

#set_media_content_type(media_id, content_type, params = {}) ⇒ nil Also known as: set_photo_content_type, set_video_content_type

Note:

This method requires authentication with "write" permissions.

Sets the content type of a photo/video.

Parameters:

  • media_id (String, Fixnum)
  • content_type (String, Fixnum)

Returns:

  • (nil)

Flickr API method:


653
654
655
656
# File 'lib/flickrie/api_methods.rb', line 653

def set_media_content_type(media_id, content_type, params = {})
  make_request(media_id, content_type, params)
  nil
end

#set_media_dates(media_id, params = {}) ⇒ nil Also known as: set_photo_dates, set_video_dates

Note:

This method requires authentication with "write" permissions.

Sets dates for a photo/video.

Parameters:

  • media_id (String, Fixnum)

Returns:

  • (nil)

Flickr API method:


667
668
669
670
# File 'lib/flickrie/api_methods.rb', line 667

def set_media_dates(media_id, params = {})
  make_request(media_id, params)
  nil
end

#set_media_license(media_id, license_id, params = {}) ⇒ nil Also known as: set_photo_license, set_video_license

Note:

This method requires authentication with "write" permissions.

Sets the license of a photo/video.

Returns:

  • (nil)

Flickr API method:


827
828
829
830
# File 'lib/flickrie/api_methods.rb', line 827

def set_media_license(media_id, license_id, params = {})
  make_request(media_id, license_id, params)
  nil
end

#set_media_meta(media_id, params = {}) ⇒ nil Also known as: set_photo_meta, set_video_meta

Note:

This method requires authentication with "write" permissions.

Sets meta information for a photo/video.

Parameters:

  • media_id (String, Fixnum)

Returns:

  • (nil)

Flickr API method:


681
682
683
684
# File 'lib/flickrie/api_methods.rb', line 681

def set_media_meta(media_id, params = {})
  make_request(media_id, params)
  nil
end

#set_media_permissions(media_id, params = {}) ⇒ nil Also known as: set_photo_permissions, set_video_permissions

Note:

This method requires authentication with "write" permissions.

Sets permissions for a photo/video.

Parameters:

  • media_id (String, Fixnum)

Returns:

  • (nil)

Flickr API method:


695
696
697
698
# File 'lib/flickrie/api_methods.rb', line 695

def set_media_permissions(media_id, params = {})
  make_request(media_id, params)
  nil
end

#set_media_safety_level(media_id, params = {}) ⇒ nil Also known as: set_photo_safety_level, set_video_safety_level

Note:

This method requires authentication with "write" permissions.

Sets the safety level of a photo/video.

Parameters:

  • media_id (String, Fixnum)

Returns:

  • (nil)

Flickr API method:


709
710
711
712
# File 'lib/flickrie/api_methods.rb', line 709

def set_media_safety_level(media_id, params = {})
  make_request(media_id, params)
  nil
end

#set_media_tags(media_id, tags, params = {}) ⇒ nil Also known as: set_photo_tags, set_video_tags

Note:

This method requires authentication with "write" permissions.

Sets tags for a photo/video.

Parameters:

  • tags (String)

    A space-delimited string with tags

Returns:

  • (nil)

Flickr API method:


723
724
725
726
# File 'lib/flickrie/api_methods.rb', line 723

def set_media_tags(media_id, tags, params = {})
  make_request(media_id, tags, params)
  nil
end

#set_set_primary_media(set_id, media_id, params = {}) ⇒ nil Also known as: set_set_primary_photo, set_set_primary_video

Note:

This method requires authentication with "write" permissions.

Sets set's primary photo/video.

Returns:

  • (nil)

Flickr API method:


1030
1031
1032
1033
# File 'lib/flickrie/api_methods.rb', line 1030

def set_set_primary_media(set_id, media_id, params = {})
  make_request(set_id, media_id, params)
  nil
end

#tag_media(media_id, tags, params = {}) ⇒ nil Also known as: tag_photo, tag_video

Note:

This method requires authentication with "write" permissions.

Add tags to the photo/video with the given ID.

Parameters:

  • tags (String)

    A space delimited string with tags

Returns:

  • (nil)

Flickr API method:


184
185
186
187
# File 'lib/flickrie/api_methods.rb', line 184

def tag_media(media_id, tags, params = {})
  make_request(media_id, tags, params)
  nil
end

#test_login(params = {}) ⇒ Flickrie::User

Note:

This method requires authentication with "read" permissions.

Tests if the authentication was successful. If it was, it returns info of the user who just authenticated.

Returns:

Flickr API method:


1056
1057
1058
1059
# File 'lib/flickrie/api_methods.rb', line 1056

def (params = {})
  response = make_request(params)
  User.new(response.body['user'], self)
end

#untag_media(tag_id, params = {}) ⇒ nil Also known as: untag_photo, untag_video

Note:

This method requires authentication with "write" permissions.

Remove the tag with the given ID

Parameters:

  • tag_id (String)

Returns:

  • (nil)

Flickr API method:


612
613
614
615
# File 'lib/flickrie/api_methods.rb', line 612

def untag_media(tag_id, params = {})
  make_request(tag_id, params)
  nil
end

#upload(media, params = {}) ⇒ String

Note:

This method requires authentication with "write" permissions.

For uploading photos and videos to Flickr. Example:

path = File.expand_path("photo.jpg")
photo_id = Flickrie.upload(path, title: "Me and Jessica", description: "...")
photo = Flickrie.get_photo_info(photo_id)
photo.title # => "Me and Jessica"

If the async: 1 option is passed, returns the ticket ID (see #check_upload_tickets).

Parameters:

  • media (File, String)

    A file or a path to the file you want to upload

  • params (Hash) (defaults to: {})

    Options for uploading (see this page)

Returns:

  • (String)

    New photo's ID, or ticket's ID, if async: 1 is passed


21
22
23
24
25
26
27
28
# File 'lib/flickrie/api_methods.rb', line 21

def upload(media, params = {})
  response = make_request(media, params)
  if params[:async] == 1
    response.body['rsp']['ticketid']
  else
    response.body['rsp']['photoid']
  end
end