openapply 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d215ce3e5704b8f304e92d62662e7c2cb43caa5de24c4048e08c40d69021be1
4
- data.tar.gz: 8fc1fffd0992271dbbf8830135d7bfb21d16c37bf716560555b262e51d82496c
3
+ metadata.gz: 5478208e639f6d809fc7d16db8d4484d06e28c92350a0d744af4f2f377813369
4
+ data.tar.gz: 03c9e34ee1fda5e164d845bc9331fc1e466ae2618f03e5aceb6e962a1ddf4e23
5
5
  SHA512:
6
- metadata.gz: 3d83905b01dd0f99615be384bc96dc463cfb7c73043bc3f4435ebdbeee56005b391744e2127cd9b18158bd0738c45e719c8471703c8ea7312249f4762be642b4
7
- data.tar.gz: 655011c0694be255269277ec02bc3aff80828eedf48bb637545240671a763a70cd8721aa2f55cc516e013a2d159f0d21ff3c59968131e9fbd234a8dc863cd3e7
6
+ metadata.gz: 65c27f0485036ab3cc2e944fc1d5ccd321b29b54939b96d78cab82d911bc069697990f0bbb6ffe327821166cf492ba859e171aecd09e239025ea021df7e7cefa
7
+ data.tar.gz: d901982b841b137fdf5a8dfe252440f94b6c1083e83da092b82c4879e650057d56182c033ece970e5af93b9bae39a99d7914d3c7004c9765c47d2cfce1746d93
@@ -0,0 +1,3 @@
1
+ component_depth: 2
2
+ languages:
3
+ - ruby
data/.gitignore CHANGED
@@ -8,9 +8,6 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
 
11
- /examples/demo/*.csv
12
- /examples/demo/*.xlsx
13
-
14
11
  # rspec failure tracking
15
12
  .rspec_status
16
13
  .coveralls.yml
@@ -1,5 +1,10 @@
1
1
  ### Openapply CHANGE LOG
2
2
 
3
+ * **v0.3.1** - compatible with 0.3.x - 2018-02-XX
4
+ - add error / exception when ENV doesn't load properly
5
+ - remove unused gems (scp and ssh)
6
+ - add example / demo usage code
7
+
3
8
  * **v0.3.0** - compatible with 0.3.x - 2018-01-31
4
9
  - NOT compatible with 0.2.x
5
10
  - migrate to new documentation style
data/Gemfile CHANGED
@@ -2,15 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- # # https://github.com/straydogstudio/axlsx_rails/issues/77
6
- # gem 'axlsx', git: 'https://github.com/randym/axlsx.git',
7
- # ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
8
-
9
- # https://github.com/randym/axlsx/issues/501
10
- # https://github.com/straydogstudio/axlsx_rails/issues/77
11
- # gem 'axlsx', "2.1.0.pre", git: 'https://github.com/randym/axlsx', branch: 'master'
12
- # gem 'axlsx', git: 'https://github.com/randym/axlsx', branch: 'master'
13
- # gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
14
-
15
5
  # Specify your gem's dependencies in openapply.gemspec
16
6
  gemspec
@@ -1,11 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapply (0.3.0)
4
+ openapply (0.3.1)
5
5
  httparty (~> 0.15)
6
6
  json (~> 2.1)
7
- net-scp (~> 1.2)
8
- net-ssh (~> 4.2)
9
7
 
10
8
  GEM
11
9
  remote: https://rubygems.org/
@@ -25,9 +23,6 @@ GEM
25
23
  json (2.1.0)
26
24
  method_source (0.9.0)
27
25
  multi_xml (0.6.0)
28
- net-scp (1.2.1)
29
- net-ssh (>= 2.6.5)
30
- net-ssh (4.2.0)
31
26
  pry (0.11.3)
32
27
  coderay (~> 1.1.0)
33
28
  method_source (~> 0.9.0)
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- [![Build Status](https://travis-ci.org/btihen/openapply.svg?branch=master)](https://travis-ci.org/btihen/openapply) [![Dependency Status](https://beta.gemnasium.com/badges/github.com/btihen/openapply.svg)](https://beta.gemnasium.com/projects/github.com/btihen/openapply) [![Known Vulnerabilities](https://snyk.io/test/github/btihen/openapply/badge.svg?targetFile=Gemfile.lock)](https://snyk.io/test/github/btihen/openapply?targetFile=Gemfile.lock) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b2062680fd14704bd321baef8dbddce)](https://www.codacy.com/app/btihen/openapply?utm_source=github.com&utm_medium=referral&utm_content=btihen/openapply&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/7b2062680fd14704bd321baef8dbddce)](https://www.codacy.com/app/btihen/openapply?utm_source=github.com&utm_medium=referral&utm_content=btihen/openapply&utm_campaign=Badge_Coverage) [![Code Quality](https://bettercodehub.com/edge/badge/btihen/shop?branch=master)](https://bettercodehub.com/) [![Coverage Status](https://coveralls.io/repos/github/btihen/openapply/badge.svg?branch=master)](https://coveralls.io/github/btihen/openapply?branch=master)
2
-
3
-
1
+ [![Build Status](https://travis-ci.org/btihen/openapply.svg?branch=master)](https://travis-ci.org/btihen/openapply) [![Known Vulnerabilities](https://snyk.io/test/github/btihen/openapply/badge.svg?targetFile=Gemfile.lock)](https://snyk.io/test/github/btihen/openapply?targetFile=Gemfile.lock) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b2062680fd14704bd321baef8dbddce)](https://www.codacy.com/app/btihen/openapply?utm_source=github.com&utm_medium=referral&utm_content=btihen/openapply&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/7b2062680fd14704bd321baef8dbddce)](https://www.codacy.com/app/btihen/openapply?utm_source=github.com&utm_medium=referral&utm_content=btihen/openapply&utm_campaign=Badge_Coverage) [![Code Quality](https://bettercodehub.com/edge/badge/btihen/shop?branch=master)](https://bettercodehub.com/)
4
2
 
5
3
 
6
4
  # Openapply
@@ -38,11 +36,6 @@ Or install it yourself as:
38
36
  * http://www.rubydoc.info/gems/openapply
39
37
 
40
38
 
41
- #### Examples Code
42
-
43
- see /examples in repo -- https://github.com/btihen/openapply/tree/master/examples/demo
44
-
45
-
46
39
  ### Configuration
47
40
 
48
41
  * Setup / Config the following ENV-VARS (example code uses **.rbenv-vars**):
@@ -80,13 +73,14 @@ Associates the above settings with HTTParty
80
73
  #### USAGE SUMMARY
81
74
 
82
75
  ```ruby
76
+ require 'openapply'
83
77
  # instantiate
84
- @oa = OpenApply::Client.new
78
+ @oa = Openapply::Client.new
85
79
 
86
80
  # see settings
87
81
  @oa.api_url
88
82
  @oa.api_key
89
- @oa.base_path
83
+ @oa.api_path
90
84
  @oa.api_timeout
91
85
  @oa.api_records
92
86
 
@@ -0,0 +1,31 @@
1
+ require 'openapply'
2
+
3
+ # SET ENV VARIABLES - NEEDED VARIABLES:
4
+ # OA_TIMEOUT=5
5
+ # OA_RECORD_COUNT=50
6
+ # OA_API_PATH=/api/v1/students/
7
+ # OA_BASE_URI=demo.openapply.com
8
+ # OA_AUTH_TOKEN=(this only works for an hour after setup)
9
+
10
+ # instantiate openapply connection
11
+ @oa = Openapply::Client.new
12
+
13
+ # see settings
14
+ @oa.api_url
15
+ @oa.api_key
16
+ @oa.api_path
17
+ @oa.api_timeout
18
+ @oa.api_records
19
+
20
+ # get summary info of applied kids
21
+ params = {status: 'applied'}
22
+ summaries = @oa.many_students_summaries( params )
23
+
24
+ # get details of of many kids - after kid 95 (only get 50 records at a time)
25
+ params = {since_id: 95, count: 50}
26
+ kid_ids = @oa.many_students_ids( params )
27
+ details = @oa.many_students_details_by_ids( kid_ids )
28
+
29
+ # get all student records that have been updated in the last week
30
+ params = {since_date: "#{Date.today-7}"}
31
+ updates = @oa.many_ids_updated_time( params )
@@ -4,50 +4,45 @@ require "openapply/put"
4
4
  require 'httparty'
5
5
 
6
6
  module Openapply
7
-
8
- # OpenApply CLIENT is a service to manage admissions -
9
- # this gem allows access to OpenApply API calls via HTTParty
10
- #
11
7
  class Client
12
8
 
13
- # PUT api calls
14
- include Put
15
- # GET api calls
16
- include Get
17
- # Library for API calls to OpenApply
18
- include HTTParty
19
-
20
- # Defines OpenApply domain name from ENV-VARS
21
- API_URL = (ENV['OA_BASE_URI'] || 'demo.openapply.com')
9
+ include HTTParty # Library for API calls
10
+ include Openapply::Put # PUT api calls
11
+ include Openapply::GetOneStudent # GET api calls
12
+ include Openapply::GetManyStudents # GET api calls
22
13
 
23
- # Defines the OpenApply path from ENV-VARS - default is 5 seconds
24
- API_TIMEOUT = (ENV['OA_TIMEOUT'].to_i || 5)
14
+ API_URL = ENV['OA_BASE_URI']
15
+ API_TIMEOUT = ENV['OA_TIMEOUT'].to_i || 5
25
16
 
26
17
  base_uri API_URL
27
18
  default_timeout API_TIMEOUT
28
19
 
29
- # Makes OpenApply domain name visible:
20
+ # attr_reader :api_url, :api_key
21
+
22
+ def initialize
23
+ api_url = ENV['OA_BASE_URI']
24
+ api_key = ENV['OA_AUTH_TOKEN']
25
+
26
+ raise ArgumentError, 'OA_BASE_URI is missing' if api_url.nil? or api_url.empty?
27
+ raise ArgumentError, 'OA_AUTH_TOKEN is missing' if api_key.nil? or api_key.empty?
28
+ end
29
+
30
30
  def api_url
31
- API_URL
31
+ ENV['OA_BASE_URI']
32
32
  end
33
33
 
34
- # make OpenApply timeout visible
35
34
  def api_timeout
36
- API_TIMEOUT
35
+ ENV['OA_TIMEOUT'].to_i
37
36
  end
38
37
 
39
- # Defines & makes visible OpenApply secret access key with ENV-VARS
40
38
  def api_key
41
- ENV['OA_AUTH_TOKEN'] || 'demo_site_api_key'
39
+ ENV['OA_AUTH_TOKEN']
42
40
  end
43
41
 
44
- # Defines and makes visib le the OpenApply path with ENV-VARS
45
42
  def api_path
46
- ENV['OA_API_PATH'] || "/api/v1/students/"
43
+ ENV['OA_API_PATH'] || "/api/v1/students/"
47
44
  end
48
45
 
49
- # Defines and makes visible the maximum records OpenApply should return
50
- # (code default is 50 - OA default is 10 - doc says 100)
51
46
  def api_records
52
47
  ENV['OA_RECORD_COUNT'] || '50'
53
48
  end
@@ -56,19 +51,16 @@ module Openapply
56
51
  # @param url [String] - this is the url to do the call
57
52
  # @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
58
53
  def oa_api_call(url, options={})
59
- # https://stackoverflow.com/questions/26251422/handling-netreadtimeout-error-in-httparty
54
+ # add exception if ENV are not set
60
55
  max_retries = 3
61
56
  times_retried = 0
62
57
  begin
63
58
  self.class.get(url, options)
64
- # rescue Net::ReadTimeout, Net::OpenTimeout => error
65
59
  rescue Net::ReadTimeout, Net::OpenTimeout
66
60
  if times_retried < max_retries
67
61
  times_retried += 1
68
- # puts "TIMEOUT RETRY: #{times_retried} of #{max_retries} - USING: #{url.inspect}"
69
62
  retry
70
63
  else
71
- # puts "TIME-OUT URI FAILED: #{url.inspect}"
72
64
  { error: "no response (timeout) from URL: #{url}" }
73
65
  end
74
66
  end
@@ -78,23 +70,19 @@ module Openapply
78
70
  # @param url [String] - this is the url to do the call
79
71
  # @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
80
72
  def oa_answer(url, options={})
81
- # puts
82
- # puts "GIVEN URL: #{ url.inspect }"
83
73
  return { error: 'no url given' } if url.nil? or url.to_s.eql? ""
84
74
  return { error: 'bad url - has space' } if url.include? " "
85
75
  return { error: 'bad api_path' } unless url.include? "#{api_path}"
86
76
  return { error: 'bad auth_token' } unless url.include? "auth_token=#{api_key}"
87
77
 
88
- # api_answer = nil
89
78
  api_answer = oa_api_call(url, options)
90
79
 
91
- return api_answer unless api_answer.respond_to? "response" # and not api_answer[:error].nil?
92
- # return { error: 'no response' } unless api_answer.respond_to? "response"
80
+ return api_answer unless api_answer.respond_to? "response"
93
81
  return { error: 'no response' } if api_answer.response.nil?
94
82
  return { error: 'no response' } if api_answer.response.to_s.eql? ""
95
83
  return JSON.parse(api_answer.response.body, symbolize_names: true)
96
84
  end
97
85
 
98
- end
86
+ end
99
87
 
100
88
  end
@@ -1,125 +1,118 @@
1
- module Get
1
+ module Openapply
2
+ module GetManyStudents
2
3
 
3
- # @note Get all student details matching the criteria in params
4
- # @param params[:status] - (String or Array of Strings) - list the status wanted
5
- # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
6
- # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
7
- # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
8
- # @param options[:get_payments] (Boolean) - get student payments
9
- def many_students_details( params, options={} )
10
- ids = many_students_ids( params )
11
- return {error: "need an array of ids"} unless ids[:ids]
12
- return many_students_details_by_ids( ids[:ids], options )
13
- end
4
+ # @note Get all student details matching the criteria in params
5
+ # @param params[:status] - (String or Array of Strings) - list the status wanted
6
+ # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
7
+ # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
8
+ # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
9
+ # @param options[:get_payments] (Boolean) - get student payments
10
+ def many_students_details( params, options={} )
11
+ ids = many_students_ids( params )
12
+ return {error: "need an array of ids"} unless ids[:ids]
13
+ return many_students_details_by_ids( ids[:ids], options )
14
+ end
14
15
 
15
- # @note Get all student details matching the criteria in params
16
- # @param ids - (Array of Integers) - list ids wanted to lookup
17
- # @param options[:get_payments] (Boolean) - get student payments
18
- def many_students_details_by_ids( ids, options={} )
19
- return {error: 'no ids provided'} if ids.nil? or ids.empty?
20
- students = []
21
- guardians = []
22
- ids = [ids] unless ids.is_a? Array
23
- ids.each do |id|
24
- response = one_student_details_by_id( id, options )
25
- # pp response
26
- students << response[:student]
27
- guardians << response[:guardians]
16
+ # @note Get all student details matching the criteria in params
17
+ # @param ids - (Array of Integers) - list ids wanted to lookup
18
+ # @param options[:get_payments] (Boolean) - get student payments
19
+ def many_students_details_by_ids( ids, options={} )
20
+ return {error: 'no ids provided'} if ids.nil? or ids.empty?
21
+ students = []
22
+ guardians = []
23
+ ids = [ids] unless ids.is_a? Array
24
+ ids.each do |id|
25
+ response = one_student_details_by_id( id, options )
26
+ # pp response
27
+ students << response[:student]
28
+ guardians << response[:guardians]
29
+ end
30
+ return { students: students,
31
+ guardians: guardians,
32
+ }
28
33
  end
29
- return {
30
- students: students,
31
- guardians: guardians,
32
- }
33
- end
34
34
 
35
- # @note Get all student ids matching the criteria in params
36
- # @param params[:status] - (String or Array of Strings) - list the status wanted
37
- # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
38
- # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
39
- # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
40
- def many_students_ids( params )
41
- response = many_students_summaries( params )
42
- ids = response[:students].map{ |kid| kid[:id] }
43
- { ids: ids }
44
- end
35
+ # @note Get all student ids matching the criteria in params
36
+ # @param params[:status] - (String or Array of Strings) - list the status wanted
37
+ # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
38
+ # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
39
+ # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
40
+ def many_students_ids( params )
41
+ response = many_students_summaries( params )
42
+ ids = response[:students].map{ |kid| kid[:id] }
43
+ { ids: ids }
44
+ end
45
45
 
46
- # @note Get all student ids & guardian ids with associated last updated timestamp (matching the criteria in params)
47
- # @param params[:status] - (String or Array of Strings) - list the status wanted
48
- # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
49
- # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
50
- # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
51
- def many_ids_updated_time( params )
52
- response = many_students_summaries( params )
53
- kids = response[:students].map{ |kid| {kid[:id] => kid[:updated_at]} }
54
- rents = response[:guardians].map{ |rent| {rent[:id] => rent[:updated_at]} }
55
- { ids_updated_at:
56
- {
57
- students: kids,
58
- guardians: rents,
46
+ # @note Get all student ids & guardian ids with associated last updated timestamp (matching the criteria in params)
47
+ # @param params[:status] - (String or Array of Strings) - list the status wanted
48
+ # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
49
+ # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
50
+ # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
51
+ def many_ids_updated_time( params )
52
+ response = many_students_summaries( params )
53
+ kids = response[:students].map{ |kid| {kid[:id] => kid[:updated_at]} }
54
+ rents = response[:guardians].map{ |rent| {rent[:id] => rent[:updated_at]} }
55
+ { ids_updated_at:
56
+ { students: kids,
57
+ guardians: rents,
58
+ }
59
59
  }
60
- }
61
- end
62
-
63
- # @note Get all student summaries matching the criteria in params
64
- # @param params[:status] - (String or Array of Strings) - list the status wanted
65
- # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
66
- # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
67
- # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
68
- def many_students_summaries( params={} )
69
- # status=nil,since_id=nil,since_date=nil,count=api_records)
70
- return {error: 'no query provided'} if params.empty?
71
-
72
- students = []
73
- guardians = []
74
-
75
- count = params[:count]
76
- count ||= api_records()
77
- since_date = params[:since_date]
78
- statuses = params[:status]
79
- statuses = [statuses] if not statuses.nil? and
80
- statuses.is_a? String
81
- statuses.each do |status|
82
-
83
- # these values need to be reset for each status loop
84
- page_number = nil
85
- since_id = params[:since_id]
86
-
87
- # loop until all pages recieved
88
- while page_number.nil? or page_number > 1
89
- url = url_for_many_students_summaries(status, since_id, since_date, count)
90
- answer = oa_answer( url )
91
- break if answer.nil? or answer[:students].empty?
60
+ end
92
61
 
93
- students += answer[:students]
94
- guardians += answer[:linked][:parents]
62
+ # @note Get all student summaries matching the criteria in params
63
+ # @param params[:status] - (String or Array of Strings) - list the status wanted
64
+ # @param params[:since_id] - (Integer) - get all ids matching the criteria LARGER than the given number
65
+ # @param params[:since_date] - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
66
+ # @param params[:count] - (Integer) - The number of customers to return - large numbers need a large timeout
67
+ def many_students_summaries( params={} )
68
+ # status=nil,since_id=nil,since_date=nil,count=api_records)
69
+ return {error: 'no query provided'} if params.empty?
70
+ students = []
71
+ guardians = []
72
+ count = params[:count]
73
+ count ||= api_records()
74
+ since_date = params[:since_date]
75
+ statuses = params[:status]
76
+ statuses = [statuses] if not statuses.nil? and
77
+ statuses.is_a? String
78
+ statuses.each do |status|
79
+ page_number = nil
80
+ since_id = params[:since_id]
95
81
 
96
- last_student = answer[:students].last
97
- since_id = last_student[:id]
98
- # since_id = (answer[:students].last)[:id]
99
- page_number = answer[:meta][:pages]
82
+ # loop until all pages recieved
83
+ while page_number.nil? or page_number > 1
84
+ url = url_for_many_students_summaries(status, since_id, since_date, count)
85
+ answer = oa_answer( url )
86
+ break if answer.nil? or answer[:students].empty?
87
+ students += answer[:students]
88
+ guardians += answer[:linked][:parents]
89
+ last_student = answer[:students].last
90
+ since_id = last_student[:id]
91
+ page_number = 0 if answer[:meta].nil?
92
+ page_number = answer[:meta][:pages].to_i unless answer[:meta].nil?
93
+ end
100
94
  end
95
+ return { students: students,
96
+ guardians: guardians,
97
+ }
101
98
  end
102
- return {
103
- students: students,
104
- guardians: guardians,
105
- }
106
- end
107
99
 
108
- # @note Get url to query for student summaries matching the criteria in params
109
- # @param status - (String or Array of Strings) - list the status wanted
110
- # @param since_id - (Integer) - get all ids matching the criteria LARGER than the given number
111
- # @param since_date - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
112
- # @param count - (Integer) - The number of customers to return - large numbers need a large timeout
113
- def url_for_many_students_summaries(status=nil, since_id=nil,
114
- since_date=nil, count=api_records)
115
- url_options = []
116
- url_options << "status=#{status}" unless status.to_s.eql? ""
117
- url_options << "since_id=#{since_id}" unless since_id.to_s.eql? ""
118
- url_options << "since_date=#{since_date}" unless since_date.to_s.eql? ""
119
- url_options << "count=#{count}"
120
- url_options << "auth_token=#{api_key}"
100
+ # @note Get url to query for student summaries matching the criteria in params
101
+ # @param status - (String or Array of Strings) - list the status wanted
102
+ # @param since_id - (Integer) - get all ids matching the criteria LARGER than the given number
103
+ # @param since_date - (String) - all records updated after the given date (YYYY-MM-DD) or Date and Time (YYYY-MM-DD HH:MM:SS) - 24 hour clock (not sure about timeszone)
104
+ # @param count - (Integer) - The number of customers to return - large numbers need a large timeout
105
+ def url_for_many_students_summaries(status=nil, since_id=nil,
106
+ since_date=nil, count=api_records)
107
+ url_options = []
108
+ url_options << "status=#{status}" unless status.to_s.eql? ""
109
+ url_options << "since_id=#{since_id}" unless since_id.to_s.eql? ""
110
+ url_options << "since_date=#{since_date}" unless since_date.to_s.eql? ""
111
+ url_options << "count=#{count}"
112
+ url_options << "auth_token=#{api_key}"
121
113
 
122
- return "#{api_path}?#{url_options.join('&')}"
123
- end
114
+ return "#{api_path}?#{url_options.join('&')}"
115
+ end
124
116
 
117
+ end
125
118
  end
@@ -1,65 +1,54 @@
1
1
  # SINGLE STUDENT API GET CALLS
2
2
  ##############################
3
+ module Openapply
4
+ module GetOneStudent
5
+
6
+ # @note Get all student details matching the associated id
7
+ # @param ids - (Integer) - ids of student to lookup
8
+ # @param options[:get_payments] (Boolean) - get student payments (or not)
9
+ def one_student_details_by_id( id, options={} )
10
+ get_payments = options[:get_payments] unless options.nil? or options.empty?
11
+ get_payments ||= true if get_payments.nil?
12
+ student_info = one_student_record_by_id( "#{id}" )
13
+
14
+ return {student: {id: id, empty: []}} if student_info.nil? or
15
+ student_info[:student].nil?
16
+ student_info[:student].empty?
17
+ student = []
18
+ student = student_info[:student] unless student_info[:student].nil?
19
+ guardians = []
20
+ guardians = student_info[:linked][:parents].dup unless
21
+ student_info[:linked].nil? or
22
+ student_info[:linked].empty? or
23
+ student_info[:linked][:parents].nil?
24
+ payments = []
25
+ payment_info = one_student_payments_by_id("#{id}") if get_payments.eql? true
26
+ payments = payment_info[:payments].dup unless payment_info.nil? or
27
+ payment_info[:payments].nil?
28
+ return { student: { id: id,
29
+ record: student,
30
+ payments: payments,
31
+ guardians: guardians,
32
+ },
33
+ guardians: guardians,
34
+ }
35
+ end
36
+
37
+ # @note Get one student's primary record matching the associated id
38
+ # @param ids - (Integer) - ids of student to lookup
39
+ # @param options - http options
40
+ def one_student_record_by_id(id, options ={})
41
+ url = "#{api_path}#{id}?auth_token=#{api_key}"
42
+ return oa_answer( url, options )
43
+ end
44
+
45
+ # @note Get one student's details matching the associated id
46
+ # @param ids - (Integer) - ids of student to lookup
47
+ # @param options - http options
48
+ def one_student_payments_by_id(id, options={})
49
+ url = "#{api_path}#{id}/payments?auth_token=#{api_key}"
50
+ return oa_answer( url, options )
51
+ end
3
52
 
4
- module Get
5
-
6
- # @note Get all student details matching the associated id
7
- # @param ids - (Integer) - ids of student to lookup
8
- # @param options[:get_payments] (Boolean) - get student payments (or not)
9
- def one_student_details_by_id( id, options={} )
10
-
11
- get_payments = options[:get_payments] unless options.nil? or options.empty?
12
- get_payments ||= true if get_payments.nil?
13
-
14
- # get full student record and guardian information
15
- student_info = one_student_record_by_id( "#{id}" )
16
-
17
- # be sure there is student data to process -- if not return an empty record
18
- return {student: {id: id, empty: []}} if student_info.nil? or
19
- student_info[:student].nil?
20
- student_info[:student].empty?
21
- student = []
22
- # extract the student info
23
- student = student_info[:student] unless student_info[:student].nil?
24
-
25
- guardians = []
26
- # extract guardian information
27
- guardians = student_info[:linked][:parents].dup unless
28
- student_info[:linked].nil? or
29
- student_info[:linked].empty? or
30
- student_info[:linked][:parents].nil?
31
- payments = []
32
- # get student payment records
33
- payment_info = one_student_payments_by_id("#{id}") if get_payments.eql? true
34
- # extract payment information
35
- payments = payment_info[:payments].dup unless payment_info.nil? or
36
- payment_info[:payments].nil?
37
- # organize the student details
38
- return {
39
- student:
40
- { id: id,
41
- record: student,
42
- payments: payments,
43
- guardians: guardians,
44
- },
45
- guardians: guardians,
46
- }
47
53
  end
48
-
49
- # @note Get one student's primary record matching the associated id
50
- # @param ids - (Integer) - ids of student to lookup
51
- # @param options - http options
52
- def one_student_record_by_id(id, options ={})
53
- url = "#{api_path}#{id}?auth_token=#{api_key}"
54
- return oa_answer( url, options )
55
- end
56
-
57
- # @note Get one student's details matching the associated id
58
- # @param ids - (Integer) - ids of student to lookup
59
- # @param options - http options
60
- def one_student_payments_by_id(id, options={})
61
- url = "#{api_path}#{id}/payments?auth_token=#{api_key}"
62
- return oa_answer( url, options )
63
- end
64
-
65
54
  end
@@ -1,3 +1,5 @@
1
- module Put
1
+ module Openapply
2
+ module Put
2
3
 
4
+ end
3
5
  end
@@ -1,3 +1,5 @@
1
1
  module Openapply
2
- VERSION = "0.3.0"
2
+ module Version
3
+ VERSION = "0.3.1"
4
+ end
3
5
  end
@@ -5,15 +5,11 @@ require "openapply/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "openapply"
8
- spec.version = Openapply::VERSION
8
+ spec.version = Openapply::Version::VERSION
9
9
  spec.authors = ["Bill Tihen"]
10
- spec.email = ["btihen@las.ch"]
10
+ spec.email = ["btihen@gmail.com","btihen@las.ch"]
11
11
 
12
- spec.summary = %q{Access OpenApply's API with Ruby}
13
- spec.description = %q{Access to OpenApply's API and extra utilities that
14
- accomplish common needs -- such as recursively query
15
- for all students of a given status or change-date
16
- until all needed records are recieved.}
12
+ spec.summary = %q{Access OpenApply's v1 API with Ruby}
17
13
  spec.homepage = "https://github.com/las-it/openapply"
18
14
  spec.license = "MIT"
19
15
 
@@ -26,10 +22,7 @@ Gem::Specification.new do |spec|
26
22
 
27
23
  spec.add_dependency "httparty", "~> 0.15"
28
24
  spec.add_dependency "json" , "~> 2.1"
29
- spec.add_dependency "net-ssh", "~> 4.2"
30
- spec.add_dependency "net-scp", "~> 1.2"
31
- #
32
- # spec.add_development_dependency "simplecov", "~> 0.15"
25
+
33
26
  spec.add_development_dependency 'codacy-coverage', '~> 1.1'
34
27
  spec.add_development_dependency "webmock", "~> 3.2"
35
28
  spec.add_development_dependency "bundler", "~> 1.15"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Tihen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.1'
41
- - !ruby/object:Gem::Dependency
42
- name: net-ssh
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '4.2'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '4.2'
55
- - !ruby/object:Gem::Dependency
56
- name: net-scp
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.2'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.2'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: codacy-coverage
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -150,17 +122,15 @@ dependencies:
150
122
  - - "~>"
151
123
  - !ruby/object:Gem::Version
152
124
  version: '0.11'
153
- description: |-
154
- Access to OpenApply's API and extra utilities that
155
- accomplish common needs -- such as recursively query
156
- for all students of a given status or change-date
157
- until all needed records are recieved.
125
+ description:
158
126
  email:
127
+ - btihen@gmail.com
159
128
  - btihen@las.ch
160
129
  executables: []
161
130
  extensions: []
162
131
  extra_rdoc_files: []
163
132
  files:
133
+ - ".bettercodehub.yml"
164
134
  - ".circleci/config.yml"
165
135
  - ".gitignore"
166
136
  - ".rspec"
@@ -176,6 +146,7 @@ files:
176
146
  - Rakefile
177
147
  - bin/console
178
148
  - bin/setup
149
+ - examples/demo.rb
179
150
  - lib/openapply.rb
180
151
  - lib/openapply/client.rb
181
152
  - lib/openapply/get_many_students.rb
@@ -203,8 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
174
  version: '0'
204
175
  requirements: []
205
176
  rubyforge_project:
206
- rubygems_version: 2.7.4
177
+ rubygems_version: 2.7.6
207
178
  signing_key:
208
179
  specification_version: 4
209
- summary: Access OpenApply's API with Ruby
180
+ summary: Access OpenApply's v1 API with Ruby
210
181
  test_files: []