class RailsRunSignUp::Model::Race
Attributes
access_token[RW]
access token for oauth
api_key[R]
api_secret[R]
city[R]
city of race
country_code[R]
country of race
description[R]
description
events[RW]
list of events of races
id[R]
race id
is_draft_race[R]
if is a draft race
is_registration_open[R]
(BOOL) if registration is open
last_date[R]
last date race took place
name[R]
name of race
next_date[R]
next date race takes place
state[R]
state of race
street[R]
street of race
url[R]
runsignup url for race
zip_code[R]
zip code of race
Public Instance Methods
add_event(event)
click to toggle source
# File lib/RailsRunSignUp/model/race.rb, line 74 def add_event event self.events = [] if self.events.nil? self.events << event end
get_events()
click to toggle source
Retrieve all events for a race
@author Khang Le
# File lib/RailsRunSignUp/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 RailsRunSignUp::RaceError, "RailsRunSignUp 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 = RailsRunSignUp::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 = RailsRunSignUp::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