Class: Smirk::Client
- Inherits:
-
Object
- Object
- Smirk::Client
- Defined in:
- lib/smirk/client.rb
Constant Summary collapse
- API_KEY =
"26Kw6kit9TBk2yFcYEwv2wWajATGYs1F"
- HOST =
"api.smugmug.com/services/api/json/1.2.2/"
Instance Method Summary collapse
- #albums(heavy = false) ⇒ Object
- #categories ⇒ Object
- #find_album(id, key) ⇒ Object
- #find_image(id, key) ⇒ Object
- #find_image_exif(id, key) ⇒ Object
-
#initialize(user, password) ⇒ Client
constructor
A new instance of Client.
- #logout ⇒ Object
Constructor Details
#initialize(user, password) ⇒ Client
Returns a new instance of Client.
8 9 10 11 |
# File 'lib/smirk/client.rb', line 8 def initialize(user, password) params = { :method => "smugmug.login.withPassword", :APIKey => API_KEY, :EmailAddress => user, :Password => password } @@session_id = get(params, true)['Login']['Session']['id'] end |
Instance Method Details
#albums(heavy = false) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/smirk/client.rb', line 18 def albums(heavy = false) params = default_params.merge!({:method => "smugmug.albums.get", :Heavy => heavy}) json = get(params)["Albums"] json.inject([]) do |albums, a| albums << Smirk::Album.new(upper_hash_to_lower_hash(a)) end end |
#categories ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/smirk/client.rb', line 26 def categories params = default_params.merge!(:method => "smugmug.categories.get") json = get(params)["Categories"] json.inject([]) do |categories, c| categories << Smirk::Category.new(upper_hash_to_lower_hash(c)) end end |
#find_album(id, key) ⇒ Object
34 35 36 37 38 |
# File 'lib/smirk/client.rb', line 34 def find_album(id, key) params = default_params.merge!({:method => "smugmug.albums.getInfo", :AlbumID => id, :AlbumKey => key}) a = get(params)["Album"] Smirk::Album.new(upper_hash_to_lower_hash(a)) end |
#find_image(id, key) ⇒ Object
40 41 42 43 44 |
# File 'lib/smirk/client.rb', line 40 def find_image(id, key) params = default_params.merge!({:method => "smugmug.images.getInfo", :ImageID => id, :ImageKey => key}) i = get(params)["Image"] Smirk::Image.new(upper_hash_to_lower_hash(i)) end |
#find_image_exif(id, key) ⇒ Object
46 47 48 49 50 |
# File 'lib/smirk/client.rb', line 46 def find_image_exif(id, key) params = default_params.merge!({:method => "smugmug.images.getEXIF", :ImageID => id, :ImageKey => key}) i = get(params)["Image"] Smirk::Image.new(upper_hash_to_lower_hash(i)) end |
#logout ⇒ Object
13 14 15 16 |
# File 'lib/smirk/client.rb', line 13 def logout params = default_params.merge!(:method => "smugmug.logout") get(params) end |