Module: TicketMaster::Provider::Lighthouse
- Includes:
- Base
- Defined in:
- lib/provider/lighthouse.rb,
lib/provider/project.rb,
lib/provider/comment.rb,
lib/provider/ticket.rb
Overview
This is the Lighthouse Provider for ticketmaster
Defined Under Namespace
Classes: Comment, Project, Ticket
Constant Summary collapse
- PROJECT_API =
::Lighthouse::Project
- TICKET_API =
::Lighthouse::Ticket
Class Method Summary collapse
-
.new(auth = {}) ⇒ Object
This is for cases when you want to instantiate using TicketMaster::Provider::Lighthouse.new(auth).
Instance Method Summary collapse
-
#authorize(auth = {}) ⇒ Object
The authorize and initializer for this provider.
-
#project(*options) ⇒ Object
The project.
-
#projects(*options) ⇒ Object
The projects.
-
#ticket(*options) ⇒ Object
the ticket.
-
#tickets(*options) ⇒ Object
The tickets.
- #valid? ⇒ Boolean
Class Method Details
.new(auth = {}) ⇒ Object
This is for cases when you want to instantiate using TicketMaster::Provider::Lighthouse.new(auth)
9 10 11 |
# File 'lib/provider/lighthouse.rb', line 9 def self.new(auth = {}) TicketMaster.new(:lighthouse, auth) end |
Instance Method Details
#authorize(auth = {}) ⇒ Object
The authorize and initializer for this provider
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/provider/lighthouse.rb', line 14 def (auth = {}) @authentication ||= TicketMaster::Authenticator.new(auth) auth = @authentication if auth.account.nil? or (auth.token.nil? and (auth.username.nil? and auth.password.nil?)) raise "Please provide at least an account (subdomain) and token or username and password)" end ::Lighthouse::Base.format = :json ::Lighthouse.account = auth.account || auth.subdomain if auth.token ::Lighthouse.token = auth.token elsif auth.username && auth.password ::Lighthouse.authenticate(auth.username, auth.password) end end |
#project(*options) ⇒ Object
The project
49 50 51 52 |
# File 'lib/provider/lighthouse.rb', line 49 def project(*) super(*) end |
#projects(*options) ⇒ Object
The projects
We have to merge in the auth information because, due to the class-based authentication mechanism, if we don’t reset the authorize information for every request, it would end up using whatever the previous instantiated object’s account info is.
43 44 45 46 |
# File 'lib/provider/lighthouse.rb', line 43 def projects(*) super(*) end |
#ticket(*options) ⇒ Object
the ticket
71 72 73 74 |
# File 'lib/provider/lighthouse.rb', line 71 def ticket(*) super(*) end |
#tickets(*options) ⇒ Object
The tickets
Due to the nature of lighthouse, we must have the project_id to pull tickets. You can pass in the id through this format:
.tickets(22)
.tickets(:project_id => 22)
To conform to ticketmaster’s standard of returning all tickets on a call to this method without any parameters, if no parameters are passed, it will return all tickets for whatever the first project is.
65 66 67 68 |
# File 'lib/provider/lighthouse.rb', line 65 def tickets(*) super(*) end |
#valid? ⇒ Boolean
29 30 31 32 33 34 35 36 |
# File 'lib/provider/lighthouse.rb', line 29 def valid? begin PROJECT_API.find(:first) true rescue false end end |