Class: RailsSignUp::Model::Race
- Defined in:
- lib/railsSignUp/model/race.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
access token for oauth.
-
#api_key ⇒ Object
readonly
api_key.
-
#api_secret ⇒ Object
readonly
api_secret.
-
#city ⇒ Object
readonly
city of race.
-
#country_code ⇒ Object
readonly
country of race.
-
#description ⇒ Object
readonly
description.
-
#events ⇒ Object
list of events of races.
-
#id ⇒ Object
readonly
race id.
-
#is_draft_race ⇒ Object
readonly
if is a draft race.
-
#is_registration_open ⇒ Object
readonly
(BOOL) if registration is open.
-
#last_date ⇒ Object
readonly
last date race took place.
-
#name ⇒ Object
readonly
name of race.
-
#next_date ⇒ Object
readonly
next date race takes place.
-
#state ⇒ Object
readonly
state of race.
-
#street ⇒ Object
readonly
street of race.
-
#url ⇒ Object
readonly
runsignup url for race.
-
#zip_code ⇒ Object
readonly
zip code of race.
Instance Method Summary collapse
- #add_event(event) ⇒ Object
-
#get_events ⇒ Object
Retrieve all events for a race.
Methods inherited from Record
Constructor Details
This class inherits a constructor from RailsSignUp::Record
Instance Attribute Details
#access_token ⇒ Object
access token for oauth
33 34 35 |
# File 'lib/railsSignUp/model/race.rb', line 33 def access_token @access_token end |
#api_key ⇒ Object (readonly)
api_key
35 36 37 |
# File 'lib/railsSignUp/model/race.rb', line 35 def api_key @api_key end |
#api_secret ⇒ Object (readonly)
api_secret
37 38 39 |
# File 'lib/railsSignUp/model/race.rb', line 37 def api_secret @api_secret end |
#city ⇒ Object (readonly)
city of race
23 24 25 |
# File 'lib/railsSignUp/model/race.rb', line 23 def city @city end |
#country_code ⇒ Object (readonly)
country of race
29 30 31 |
# File 'lib/railsSignUp/model/race.rb', line 29 def country_code @country_code end |
#description ⇒ Object (readonly)
description
9 10 11 |
# File 'lib/railsSignUp/model/race.rb', line 9 def description @description end |
#events ⇒ Object
list of events of races
31 32 33 |
# File 'lib/railsSignUp/model/race.rb', line 31 def events @events end |
#id ⇒ Object (readonly)
race id
5 6 7 |
# File 'lib/railsSignUp/model/race.rb', line 5 def id @id end |
#is_draft_race ⇒ Object (readonly)
if is a draft race
19 20 21 |
# File 'lib/railsSignUp/model/race.rb', line 19 def is_draft_race @is_draft_race end |
#is_registration_open ⇒ Object (readonly)
(BOOL) if registration is open
17 18 19 |
# File 'lib/railsSignUp/model/race.rb', line 17 def is_registration_open @is_registration_open end |
#last_date ⇒ Object (readonly)
last date race took place
15 16 17 |
# File 'lib/railsSignUp/model/race.rb', line 15 def last_date @last_date end |
#name ⇒ Object (readonly)
name of race
7 8 9 |
# File 'lib/railsSignUp/model/race.rb', line 7 def name @name end |
#next_date ⇒ Object (readonly)
next date race takes place
13 14 15 |
# File 'lib/railsSignUp/model/race.rb', line 13 def next_date @next_date end |
#state ⇒ Object (readonly)
state of race
25 26 27 |
# File 'lib/railsSignUp/model/race.rb', line 25 def state @state end |
#street ⇒ Object (readonly)
street of race
21 22 23 |
# File 'lib/railsSignUp/model/race.rb', line 21 def street @street end |
#url ⇒ Object (readonly)
runsignup url for race
11 12 13 |
# File 'lib/railsSignUp/model/race.rb', line 11 def url @url end |
#zip_code ⇒ Object (readonly)
zip code of race
27 28 29 |
# File 'lib/railsSignUp/model/race.rb', line 27 def zip_code @zip_code end |
Instance Method Details
#add_event(event) ⇒ Object
74 75 76 77 |
# File 'lib/railsSignUp/model/race.rb', line 74 def add_event event self.events = [] if self.events.nil? self.events << event end |
#get_events ⇒ Object
Retrieve all events for a race
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/railsSignUp/model/race.rb', line 42 def get_events response = self.access_token.get("/rest/race/#{self.id}/?format=json&race_id=#{self.id}&api_key=#{self.api_key}&api_secret=#{self.api_secret}") json_response = JSON.parse(response.body) raise RailsSignUp::RaceError, "RailsSignUp race.get Error: #{json_response['error']['error_code']} - #{json_response['error']['error_msg']}" unless json_response['error'].nil? json_response['race']['events'].each do |event| _event = RailsSignUp::Model::Event.new( :id => event['id'], :name => event['name'], :details => event['details'], :start_time => event['start_time'], :registration_opens => event['registration_opens'], :event_type => event['event_type'], :distance => event['distance'], :volunteer => event['volunteer'], :require_dob => event['require_dob'], :require_phone => event['require_phone'], :give_away => event['give_away'] ) event['registration_periods'].each do |period| _period = RailsSignUp::Model::RegistrationPeriod.new( :registration_opens => period['registration_opens'], :registration_closes => period['registration_closes'], :race_fee => period['race_fee'] ) _event.add_registration_period _period end self.add_event _event end end |