Class: Smile::Smug

Inherits:
Base
  • Object
show all
Defined in:
lib/smile/smug.rb

Constant Summary

Constant Summary

Constants included from Common

Common::BASE, Common::BASE_SECURE, Common::UPLOAD, Common::VERSION

Instance Attribute Summary

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

clear_config!, configure, #initialize, #method_missing

Methods included from Common

#base_web_method_call, #default_params, #logger, #logger_on?, #secure_web_method_call, #session, #upper_hash_to_lower_hash, #web_method_call

Constructor Details

This class inherits a constructor from Smile::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Smile::Base

Instance Method Details

#albums(options = nil) ⇒ Array<Smile::Album>

Retrieves a list of albums for a given user. If you are logged in it will return your albums.

information is returned about the album password here to access private information.

Parameters:

  • options (optional, Hash) (defaults to: nil)

    The magic options hash all ruby devs love

Options Hash (options):

  • :nick_name (optional, String)

    If no nick name is supplied then...

  • :heavy (optional, true or false) — default: 'true'

    This will control how much

  • :site_password (optional, String)

    If you have not logged in then you can provide the

Returns:

See Also:

  • For more information about heavy ( true and false ) responces


59
60
61
62
63
64
65
66
# File 'lib/smile/smug.rb', line 59

def albums( options=nil )
  json = web_method_call( 
    { :method => 'smugmug.albums.get', :heavy => 1 },
    options
  )      

  Smile::Album.from_json( json )
end

#auth(email, pass) ⇒ Smile::SmugMug.new

Login to SmugMug using a specific user account.

Parameters:

  • email (String)

    The username ( Nickname ) for the SmugMug account

  • password (String)

    The password for the SmugMug account

Returns:

  • (Smile::SmugMug.new)

    An Smug object that has been authenticated



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/smile/smug.rb', line 16

def auth( email, pass )
	json = secure_web_method_call( { 
			:method       => 'smugmug.login.withPassword',
			:EmailAddress => email,
			:Password     => pass
		}
	)

	self.session.id = json["login"]["session"]["id"]
	json
end

#auth_anonymouslySmile::SmugMug.new

Login to SmugMug using an anonymously account This will allow you to execute many functions, but no user specific functions

Returns:

  • (Smile::SmugMug.new)

    An Smug object that has been authenticated



32
33
34
35
36
37
# File 'lib/smile/smug.rb', line 32

def auth_anonymously
  json = secure_web_method_call( { :method => 'smugmug.login.anonymously' } )

  self.session.id = json["login"]["session"]["id"]
  json
end

#logoutObject

Close the session



40
41
42
# File 'lib/smile/smug.rb', line 40

def logout
  web_method_call( { :method => 'smugmug.logout' } )
end