RailsRunSignUp 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/RailsRunSignUp/exceptions.rb +3 -0
- data/lib/RailsRunSignUp/model/user.rb +40 -0
- data/lib/RailsRunSignUp/races.rb +1 -1
- data/lib/RailsRunSignUp/session.rb +1 -1
- data/lib/RailsRunSignUp/users.rb +81 -0
- data/lib/RailsRunSignUp/version.rb +1 -1
- data/lib/RailsRunSignUp.rb +2 -0
- data/spec/RailsRunSignUp_spec.rb +9 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjQ5MWNlNzlmNDI2M2MyNjYzZDgzMWE1ZmU5YzA2Njc3YmQ5YWZiNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmI4YzY4NzczZTIyZTM0N2UzNzhmNjM3M2Q2MDlhYjFjNDQwMTdiMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmRhZTA3OGYzNWRkNzQxYTc2MjAyNjA0MzI3ZjgxOGZiOTFhMmQ3Nzg3NDFk
|
10
|
+
OTZkNGY3ZThhYTU0OWFhNGU5YmFmNDgyYzU3OTNlNjIxYTBkNWM5OWU3MTYw
|
11
|
+
ZmNjYjk0MTY4NWY3NWFiMzEyNjg4NjY1NjA1OWMyNzE0YzU4NGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTE4Yjc1NzEyN2EyZGM5YjliZDU1OGI1NmZhNzNmMzY4MGUyM2FjM2ViNTVj
|
14
|
+
ZTJiZGRjYWRjOTYyZTBiYTk4ZDljMWYyYTFmMjA4ODdjMDUxMWEyZjdjZDcw
|
15
|
+
NzhiZTM1OWNhNmYwODYwMmI4M2Y1MzMyNTI4NGY2OWNjMmUwYmQ=
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# @author Khang Le
|
2
|
+
|
3
|
+
module RailsRunSignUp
|
4
|
+
class Model
|
5
|
+
class User < RailsRunSignUp::Record
|
6
|
+
# user id
|
7
|
+
attr_reader :user_id
|
8
|
+
# users first name
|
9
|
+
attr_reader :first_name
|
10
|
+
# users last name
|
11
|
+
attr_reader :last_name
|
12
|
+
# users street address
|
13
|
+
attr_reader :street
|
14
|
+
# users city address
|
15
|
+
attr_reader :city
|
16
|
+
# users state address
|
17
|
+
attr_reader :state
|
18
|
+
# users zipcode address
|
19
|
+
attr_reader :zipcode
|
20
|
+
# users country code address
|
21
|
+
attr_reader :country_code
|
22
|
+
# users date of birth
|
23
|
+
attr_reader :dob
|
24
|
+
# users gender
|
25
|
+
attr_reader :gender
|
26
|
+
# users phone number
|
27
|
+
attr_reader :phone
|
28
|
+
# users profile image link
|
29
|
+
attr_reader :profile_image_url
|
30
|
+
# users registration id
|
31
|
+
attr_reader :registration_id
|
32
|
+
# users bib number
|
33
|
+
attr_reader :bib_num
|
34
|
+
# users chip number
|
35
|
+
attr_reader :chip_num
|
36
|
+
# users age at time of race
|
37
|
+
attr_reader :age
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/RailsRunSignUp/races.rb
CHANGED
@@ -27,7 +27,7 @@ module RailsRunSignUp
|
|
27
27
|
# param[name] search race by name
|
28
28
|
# see runsignup api documentation for extra parameters
|
29
29
|
def get_races opts = {}
|
30
|
-
response = @access_token.get("/
|
30
|
+
response = @access_token.get("/Rest/races/?format=json&#{opts.map{|k, v| "#{k}=#{v}"}.join('&')}")
|
31
31
|
json_response = JSON.parse(response.body)
|
32
32
|
|
33
33
|
raise RailsRunSignUp::RaceError, "RunSignUp races.get Error: #{json_response['error']['error_code']} - #{json_response['error']['error_msg']}" unless json_response['error'].nil?
|
@@ -16,7 +16,7 @@ module RailsRunSignUp
|
|
16
16
|
raise RailsRunSignUp::RailsRunSignUpError, "Missing parameter(access_token)" if access_token.nil? || access_token.length == 0
|
17
17
|
raise RailsRunSignUp::RailsRunSignUpError, "Missing parameter(access_token_secret)" if access_token_secret.nil? || access_token_secret.length == 0
|
18
18
|
|
19
|
-
@consumer = OAuth::Consumer.new(oauth_key, oauth_secret, :site => "https://runsignup.com", :request_token_path => "/oauth/requestToken.php",
|
19
|
+
@consumer = OAuth::Consumer.new(oauth_key, oauth_secret, :site => "https://runsignup.com", :http_method => :get, :scheme => :query_string, :request_token_path => "/oauth/requestToken.php",
|
20
20
|
:authorize_path => "/OAuth/Verify", :access_token_path => "/oauth/accessToken.php")
|
21
21
|
@access_token = OAuth::AccessToken.new(@consumer, access_token, access_token_secret)
|
22
22
|
@api_key = api_key
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# @author Khang Le
|
2
|
+
|
3
|
+
# @author Khang Le
|
4
|
+
|
5
|
+
module RailsRunSignUp
|
6
|
+
class Users
|
7
|
+
attr_accessor :users
|
8
|
+
|
9
|
+
def initialize session
|
10
|
+
raise RailsRunSignUp::SessionError, "Invalid session (session cannot be nil)" if session.nil?
|
11
|
+
|
12
|
+
@users = []
|
13
|
+
@access_token = session.access_token
|
14
|
+
@api_key = session.api_key
|
15
|
+
@api_secret = session.api_secret
|
16
|
+
end
|
17
|
+
|
18
|
+
# get users from runsignup events
|
19
|
+
#
|
20
|
+
# @author Khang Le
|
21
|
+
# @param race_id The race's id
|
22
|
+
# @param event_id The event's id
|
23
|
+
# @param results_per_page The amount of results to show per page
|
24
|
+
# @param page The page number to view participants on
|
25
|
+
# @param after_registration_id Get registrations after the given registration id
|
26
|
+
def get_participants opts = {}
|
27
|
+
response = @access_token.get("/Rest/race/#{opts[:race_id]}/participants/?format=json&#{opts.map{|k, v| "#{k}=#{v}"}.join('&')}")
|
28
|
+
json_response = JSON.parse(response.body).first #response is encased in an array?
|
29
|
+
|
30
|
+
raise RailsRunSignUp::ParticipantsError, "RunSignUp participants.get Error: #{json_response['error']['error_code']} - #{json_response['error']['error_msg']}" unless json_response['error'].nil?
|
31
|
+
|
32
|
+
parse_json json_response
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_json json_response, opts = {}
|
36
|
+
users = []
|
37
|
+
|
38
|
+
return if json_response['participants'].nil?
|
39
|
+
|
40
|
+
json_response['participants'].each do |participant|
|
41
|
+
_participant = RailsRunSignUp::Model::User.new(
|
42
|
+
:user_id => participant['user']['user_id'],
|
43
|
+
:first_name => participant['user']['first_name'],
|
44
|
+
:last_name => participant['user']['email'],
|
45
|
+
:street => participant['user']['address']['street'],
|
46
|
+
:city => participant['user']['address']['city'],
|
47
|
+
:state => participant['user']['address']['state'],
|
48
|
+
:zipcode => participant['user']['address']['zipcode'],
|
49
|
+
:country_code => participant['user']['address']['country_code'],
|
50
|
+
:dob => participant['user']['dob'],
|
51
|
+
:gender => participant['user']['gender'],
|
52
|
+
:phone => participant['user']['phone'],
|
53
|
+
:profile_image_url => participant['user']['profile_image_url'],
|
54
|
+
:registration_id => participant['registration_id'],
|
55
|
+
:bib_num => participant['bib_num'],
|
56
|
+
:chip_num => participant['chip_num'],
|
57
|
+
:age => participant['age'],
|
58
|
+
:registration_date => participant['registration_date'],
|
59
|
+
:last_modified => participant['last_modified'],
|
60
|
+
:imported => participant['imported'],
|
61
|
+
:processing_fee => participant['processing_fee'],
|
62
|
+
:processing_fee_paid_by_user => participant['processing_fee_paid_by_user'],
|
63
|
+
:processing_fee_paid_by_race => participant['processing_fee_paid_by_race'],
|
64
|
+
:partner_fee => participant['partner_fee'],
|
65
|
+
:affiliate_profit => participant['affiliate_profit'],
|
66
|
+
:extra_fees => participant['extra_fees'],
|
67
|
+
:amount_paid => participant['amount_paid'],
|
68
|
+
:usatf_discount_amount_in_cents => participant['usatf_discount_amount_in_cents'],
|
69
|
+
:usatf_discount_additional_field => participant['usatf_discount_additional_field'],
|
70
|
+
:giveaway => participant['giveaway']
|
71
|
+
)
|
72
|
+
self.add_user _participant
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_user user
|
77
|
+
self.users = [] if self.users.nil?
|
78
|
+
self.users << user
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/RailsRunSignUp.rb
CHANGED
@@ -5,7 +5,9 @@ require "RailsRunSignUp/record"
|
|
5
5
|
require "RailsRunSignUp/model/race"
|
6
6
|
require "RailsRunSignUp/model/event"
|
7
7
|
require "RailsRunSignUp/model/registration_period"
|
8
|
+
require "RailsRunSignUp/model/user"
|
8
9
|
require "RailsRunSignUp/races"
|
10
|
+
require "RailsRunSignUp/users"
|
9
11
|
|
10
12
|
module RailsRunSignUp
|
11
13
|
# Your code goes here...
|
data/spec/RailsRunSignUp_spec.rb
CHANGED
@@ -7,11 +7,12 @@ describe RailsRunSignUp do
|
|
7
7
|
|
8
8
|
it "should create oauth session" do
|
9
9
|
session.should_not be_nil
|
10
|
+
session.access_token.should_not be_nil
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should retrieve race list" do
|
13
14
|
rails_sign_up = RailsRunSignUp::Races.new(session)
|
14
|
-
races = rails_sign_up.get_races
|
15
|
+
races = rails_sign_up.get_races :only_parter_races => "T"
|
15
16
|
races.should_not be_nil
|
16
17
|
end
|
17
18
|
|
@@ -21,4 +22,11 @@ describe RailsRunSignUp do
|
|
21
22
|
races = rails_sign_up.get_races opts
|
22
23
|
races.should_not be_nil
|
23
24
|
end
|
25
|
+
|
26
|
+
it "should retrieve participants from race" do
|
27
|
+
rails_sign_up = RailsRunSignUp::Users.new(session)
|
28
|
+
opts = { :race_id => "3692", :event_id => "9693" }
|
29
|
+
users = rails_sign_up.get_participants opts
|
30
|
+
users.should_not be_nil
|
31
|
+
end
|
24
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RailsRunSignUp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Slone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,9 +56,11 @@ files:
|
|
56
56
|
- lib/RailsRunSignUp/model/event.rb
|
57
57
|
- lib/RailsRunSignUp/model/race.rb
|
58
58
|
- lib/RailsRunSignUp/model/registration_period.rb
|
59
|
+
- lib/RailsRunSignUp/model/user.rb
|
59
60
|
- lib/RailsRunSignUp/races.rb
|
60
61
|
- lib/RailsRunSignUp/record.rb
|
61
62
|
- lib/RailsRunSignUp/session.rb
|
63
|
+
- lib/RailsRunSignUp/users.rb
|
62
64
|
- lib/RailsRunSignUp/version.rb
|
63
65
|
- spec/RailsRunSignUp_helper.rb
|
64
66
|
- spec/RailsRunSignUp_spec.rb
|