Sha256: db295a0a27cf6018eb63207ef792aeeba40fdf45658b4817956074054e6a935b

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

module Smile
  class Smug < Smile::Base
 
    def auth( email, pass )
     params = default_params.merge(
        :method => 'smugmug.login.withPassword',
        :EmailAddress => email,
        :Password => pass
      )

      xml = RestClient.post( BASE, params )
      result = Hash.from_xml( xml )["rsp"]["login"]
      self.session_id = result["session"]["id"]
      result
    rescue NoMethodError => e
      nil
    end

    def auth_anonymously
      params = default_params.merge(
        :method => 'smugmug.login.anonymously'
      )

      xml = RestClient.post( BASE, params )
      result = Hash.from_xml( xml )["rsp"]["login"]
      self.session_id = result["session"]["id"]
      result
    rescue NoMethodError => e
      nil
    end

    def logout
      params = default_params.merge(
        :method => 'smugmug.logout'
      )

      RestClient.post( BASE, params )
    end

=begin
*  SessionID - string.
* NickName - string (optional).
* Heavy - boolean (optional).
* SitePassword - string (optional).

=end
    def albums( options=nil )
      params = default_params.merge( 
        :method => 'smugmug.albums.get',
        :heavy => 1
      )

      params = params.merge( options ) if( options )
      xml = RestClient.post BASE, params
      Smile::Album.from_xml( xml, session_id )
    rescue
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
cajun-smile-0.1.1 lib/smile/smug.rb
smile-0.1.1 lib/smile/smug.rb