Sha256: 01d79ddaa2ad70dcbcdbb447b95599c02967369dddc339f14e5ab72709ba0af6

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

module TicketMaster::Provider
  # This is the Rally Provider for ticketmaster
  module Rally
    include TicketMaster::Provider::Base

    # This is for cases when you want to instantiate using TicketMaster::Provider::Rally.new(auth)
    def self.new(auth = {})
      TicketMaster.new(:rally, auth)
    end
    
    # Providers must define an authorize method. This is used to initialize and set authentication
    # parameters to access the API
    def authorize(auth = {})
      @authentication ||= TicketMaster::Authenticator.new(auth)
      auth = @authentication
      if ((auth.url.nil? || auth.url.empty?) and (auth.username.nil? || auth.username.empty?) and (auth.password.nil? || auth.password.empty?))
        raise "Please you should provide a Rally url, username and password"
      end
      TicketMaster::Provider::Rally.rally = RallyRestAPI.new(:username => auth.username, 
                                                             :password => auth.password,
                                                             :base_url => auth.url,
                                                             :logger => RALLY_LOGGER_PATH ? Logger.new(RALLY_LOGGER_PATH) : nil)
    end
    
    # declare needed overloaded methods here
    
    def valid?
      begin
        TicketMaster::Provider::Rally.rally.find_all(:project).first
        true
      rescue
        false
      end
    end

    def self.rally=(rally_instance)
      @rally = rally_instance
    end

    def self.rally
      @rally
    end

  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ticketmaster-rally-0.1.1 lib/provider/rally.rb
ticketmaster-rally-0.1.0 lib/provider/rally.rb