Class: FedenaSdk::Attendance

Inherits:
Model
  • Object
show all
Defined in:
lib/fedena_sdk/attendance.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

attr_accessor, #attributes, #get, get, #initialize, post, #post, request, #request

Constructor Details

This class inherits a constructor from FedenaSdk::Model

Instance Attribute Details

#afternoonObject

Returns the value of attribute afternoon.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def afternoon
  @afternoon
end

#batch_nameObject

Returns the value of attribute batch_name.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def batch_name
  @batch_name
end

#class_timing_nameObject

Returns the value of attribute class_timing_name.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def class_timing_name
  @class_timing_name
end

#dateObject

Returns the value of attribute date.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def date
  @date
end

#forenoonObject

Returns the value of attribute forenoon.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def forenoon
  @forenoon
end

#reasonObject

Returns the value of attribute reason.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def reason
  @reason
end

#student_admission_noObject

Returns the value of attribute student_admission_no.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def student_admission_no
  @student_admission_no
end

#subject_codeObject

Returns the value of attribute subject_code.



3
4
5
# File 'lib/fedena_sdk/attendance.rb', line 3

def subject_code
  @subject_code
end

Class Method Details

.create(*args) ⇒ Object



37
38
39
40
# File 'lib/fedena_sdk/attendance.rb', line 37

def self.create(*args)
  attendance = Attendance.new *args
  attendance.save
end

.destroy(admission_no, date) ⇒ Object



42
43
44
45
46
47
# File 'lib/fedena_sdk/attendance.rb', line 42

def self.destroy(admission_no, date)
  url = "/api/attendances/#{admission_no}"
  params = { date: date }
  options = { params: params }
  request(:delete, url, options)
end

.search(query) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/fedena_sdk/attendance.rb', line 19

def self.search(query)
  url = '/api/attendances'
  params = { search: query }
  options = { params: params }
  hash = get(url, options)
  hash['attendance_detail']['attendance'].map do |attendance_hash|
    new attendance_hash
  end
end

.show(admission_no, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fedena_sdk/attendance.rb', line 5

def self.show(admission_no, options = {})
  date = options[:date]
  attendance_type = options[:attendance_type]
  subject_code = options[:subject_code]
  class_timing_name = options[:class_timing_name]
  url = "/api/attendances/#{admission_no}"
  options = { params: { attendance_type: attendance_type,
                        date: date,
                        subject_code: subject_code,
                        class_timing_name: class_timing_name } }
  hash = get(url, options)
  new hash['attendance_detail']['attendance']
end

Instance Method Details

#attributes_hashObject

Overrides



54
55
56
# File 'lib/fedena_sdk/attendance.rb', line 54

def attributes_hash
  super.merge(admission_no: @student_admission_no)
end

#destroyObject



49
50
51
# File 'lib/fedena_sdk/attendance.rb', line 49

def destroy
  self.class.destroy(student_admission_no, date)
end

#saveObject



29
30
31
32
33
34
35
# File 'lib/fedena_sdk/attendance.rb', line 29

def save
  url = '/api/attendances'
  params = attributes_hash
  options = { params: params }
  hash = post(url, options)
  new hash['attendance_detail']['attendance']
end