Class: RpiUnion::Client
Constant Summary collapse
- API_BASE_URI =
'http://api.union.rpi.edu/query.php'
- GET_USER_TASK =
'GetUser'
- LIST_ALL_ORGANIZATIONS_TASK =
'ListAllOrganizations'
- GET_ORGANIZATION_TASK =
'GetOrganization'
- GET_USER_ORGS_TASK =
'GetUserOrgs'
Instance Method Summary collapse
-
#get_organization(id) ⇒ Hash
Get information about a club.
-
#get_user(options = {}) ⇒ Hash
Get the properties of a specific user.
-
#get_user_orgs(rin) ⇒ Object
Get the IDs of all the clubs of which the user is an officer.
-
#initialize(api_key) ⇒ Client
constructor
Initialize a new Client with the specified API key.
-
#list_all_organizations ⇒ Array
Get all of the Union clubs.
Constructor Details
#initialize(api_key) ⇒ Client
Initialize a new Client with the specified API key
17 18 19 |
# File 'lib/rpi_union.rb', line 17 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#get_organization(id) ⇒ Hash
Get information about a club
60 61 62 63 |
# File 'lib/rpi_union.rb', line 60 def get_organization(id) opts = { :query => { :id => id } } get_with_key_task(GET_ORGANIZATION_TASK, opts) end |
#get_user(options = {}) ⇒ Hash
Get the properties of a specific user.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rpi_union.rb', line 26 def get_user( = {}) opts = {} opts[:query] = {} if .key?(:rin) opts[:query][:rin] = [:rin] elsif .key?(:rcsid) opts[:query][:rcsid] = [:rcsid] elsif .key?(:id) opts[:query][:dbid] = [:id] else raise "You must pass one of the following as an option to get_user(): "+ "'rin', 'rcsid', or 'id'" end # Set middlename if it was pass in options if .key?(:middlename) opts[:query][:middlename] = [:middlename] end get_with_key_task(GET_USER_TASK, opts) end |
#get_user_orgs(rin) ⇒ Object
Get the IDs of all the clubs of which the user is an officer
68 69 70 71 |
# File 'lib/rpi_union.rb', line 68 def get_user_orgs(rin) opts = { :query => { :rin => rin } } get_with_key_task(GET_USER_ORGS_TASK, opts) end |
#list_all_organizations ⇒ Array
Get all of the Union clubs
52 53 54 |
# File 'lib/rpi_union.rb', line 52 def list_all_organizations get_with_key_task(LIST_ALL_ORGANIZATIONS_TASK) end |