Class: LearnSprout::Client
- Inherits:
-
Object
- Object
- LearnSprout::Client
- Includes:
- Connection
- Defined in:
- lib/learnsprout/client.rb
Instance Method Summary collapse
- #course(org_id, course_id) ⇒ Object
- #courses(org_id, options = {}) ⇒ Object
- #current_term(org_id, school_id) ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
- #org(org_id) ⇒ Object
- #orgs ⇒ Object
- #school(org_id, school_id) ⇒ Object
- #schools(org_id) ⇒ Object
- #section(org_id, section_id) ⇒ Object
- #sections(org_id, options = {}) ⇒ Object
- #student(org_id, student_id) ⇒ Object
- #students(org_id, options = {}) ⇒ Object
- #teacher(org_id, teacher_id) ⇒ Object
- #teachers(org_id, options = {}) ⇒ Object
- #term(org_id, term_id) ⇒ Object
- #terms(org_id, options = {}) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/learnsprout/client.rb', line 5 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#course(org_id, course_id) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/learnsprout/client.rb', line 111 def course(org_id, course_id) url = "org/#{org_id}/course/#{course_id}?apikey=#{@api_key}" course = get(url) course["org_id"] = org_id course["client"] = self Course.new(course) end |
#courses(org_id, options = {}) ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'lib/learnsprout/client.rb', line 119 def courses(org_id, = {}) school_id = [:school_id] if (school_id) url = "org/#{org_id}/school/#{school_id}/course?apikey=#{@api_key}" else url = "org/#{org_id}/course?apikey=#{@api_key}" end Page.new(url, Course, :org_id => org_id, :client => self) end |
#current_term(org_id, school_id) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/learnsprout/client.rb', line 103 def current_term(org_id, school_id) url = "org/#{org_id}/school/#{school_id}/term/current?apikey=#{@api_key}" term = get(url) term["org_id"] = org_id term["client"] = self Term.new(term) end |
#org(org_id) ⇒ Object
9 10 11 12 13 |
# File 'lib/learnsprout/client.rb', line 9 def org(org_id) org = get("org/#{org_id}?apikey=#{@api_key}") org["client"] = self Org.new(org) end |
#orgs ⇒ Object
15 16 17 18 |
# File 'lib/learnsprout/client.rb', line 15 def orgs orgs = get("org?apikey=#{@api_key}") instances_from_orgs(orgs) end |
#school(org_id, school_id) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/learnsprout/client.rb', line 20 def school(org_id, school_id) school = get("org/#{org_id}/school/#{school_id}?apikey=#{@api_key}") school["org_id"] = org_id school["client"] = self School.new(school) end |
#schools(org_id) ⇒ Object
27 28 29 30 |
# File 'lib/learnsprout/client.rb', line 27 def schools(org_id) schools = get("org/#{org_id}/school?apikey=#{@api_key}") Page.new("org/#{org_id}/school?apikey=#{@api_key}", School, :client => self, :org_id => org_id) end |
#section(org_id, section_id) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/learnsprout/client.rb', line 49 def section(org_id, section_id) url = "org/#{org_id}/section/#{section_id}?apikey=#{@api_key}" section = get(url) section["org_id"] = org_id section["client"] = self Section.new(section) end |
#sections(org_id, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/learnsprout/client.rb', line 57 def sections(org_id, = {}) school_id = [:school_id] if (school_id) url = "org/#{org_id}/school/#{school_id}/section?apikey=#{@api_key}" else url = "org/#{org_id}/section?apikey=#{@api_key}" end Page.new(url, Section, :org_id => org_id, :client => self) end |
#student(org_id, student_id) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/learnsprout/client.rb', line 32 def student(org_id, student_id) student = get("org/#{org_id}/student/#{student_id}?apikey=#{@api_key}") student["org_id"] = org_id student["client"] = self Student.new(student) end |
#students(org_id, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/learnsprout/client.rb', line 39 def students(org_id, = {}) school_id = [:school_id] if (school_id) url = "org/#{org_id}/school/#{school_id}/student?apikey=#{@api_key}" else url = "org/#{org_id}/student?apikey=#{@api_key}" end Page.new(url, Student, :org_id => org_id, :client => self) end |
#teacher(org_id, teacher_id) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/learnsprout/client.rb', line 67 def teacher(org_id, teacher_id) url = "org/#{org_id}/teacher/#{teacher_id}?apikey=#{@api_key}" teacher = get(url) teacher["org_id"] = org_id teacher["client"] = self Teacher.new(teacher) end |
#teachers(org_id, options = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/learnsprout/client.rb', line 75 def teachers(org_id, = {}) school_id = [:school_id] if (school_id) url = "org/#{org_id}/school/#{school_id}/teacher?apikey=#{@api_key}" else url = "org/#{org_id}/teacher?apikey=#{@api_key}" end Page.new(url, Teacher, :org_id => org_id, :client => self) end |
#term(org_id, term_id) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/learnsprout/client.rb', line 85 def term(org_id, term_id) url = "org/#{org_id}/term/#{term_id}?apikey=#{@api_key}" term = get(url) term["org_id"] = org_id term["client"] = self Term.new(term) end |
#terms(org_id, options = {}) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/learnsprout/client.rb', line 93 def terms(org_id, = {}) school_id = [:school_id] if (school_id) url = "org/#{org_id}/school/#{school_id}/term?apikey=#{@api_key}" else url = "org/#{org_id}/term?apikey=#{@api_key}" end Page.new(url, Term, :org_id => org_id, :client => self) end |