module MobileApi::User

Public Instance Methods

activities_as_api() click to toggle source

Returns user activities.

# File app/models/concerns/mobile_api/user.rb, line 45
def activities_as_api
  [courses_as_api].inject(&:merge)
end
destroy_auth_token() click to toggle source

Destroy auth token.

# File app/models/concerns/mobile_api/user.rb, line 13
def destroy_auth_token
  update_columns(auth_token: nil)
end
full_info() click to toggle source

Returns full information of user.

# File app/models/concerns/mobile_api/user.rb, line 50
def full_info
  attributes.except('crypted_password', 'salt', 'major', 'minor', 'uuid', 'auth_token', 'created_at', 'updated_at', 'balanced_student_uri').merge(image: ActionController::Base.helpers.image_url(image_url))
end
generate_auth_token() click to toggle source

Generate auth token for mobile api user.

# File app/models/concerns/mobile_api/user.rb, line 7
def generate_auth_token
  update_columns(auth_token: SecureRandom.uuid)
  auth_token
end
info() click to toggle source

Returns user info hash.

# File app/models/concerns/mobile_api/user.rb, line 18
def info
  {
    id: id,
    name: name,
    image: ActionController::Base.helpers.image_url(image_url),
    email: email,
    type: type,
    average_rating: try(:average_rating).try(:round, 2),
    profile_visits: try(:profile_visits).try(:sum, :count),
    hourly_rate_in_cents: try(:rate_in_cents_with_charge),
    university_name: ActsAsTenant.current_tenant.try(:name),
    school_name: educations.first.try(:school_name),
    graduation_year: educations.first.try(:end_date).try(:year),
    major: educations.first.try(:field_of_study),
    minor: educations.first.try(:minor)
  }
end
pending_sessions_as_student() click to toggle source

Returns pending session of students.

# File app/models/concerns/mobile_api/user.rb, line 80
def  pending_sessions_as_student
  tutored_sessions.upcoming.pending
end
pending_sessions_as_tutor() click to toggle source

Returns pending session of tutors.

# File app/models/concerns/mobile_api/user.rb, line 75
def  pending_sessions_as_tutor
  tutoring_sessions.upcoming.pending
end
previous_sessions_as_student() click to toggle source

Returns previous session of students.

# File app/models/concerns/mobile_api/user.rb, line 70
def  previous_sessions_as_student
  tutored_sessions.confirmed.previous
end
previous_sessions_as_tutor() click to toggle source

Returns previous session of tutors.

# File app/models/concerns/mobile_api/user.rb, line 65
def  previous_sessions_as_tutor
  tutoring_sessions.confirmed.previous
end
courses_as_api() click to toggle source

Returns user and tutor courses.

# File app/models/concerns/mobile_api/user.rb, line 37
def courses_as_api
  data = {}
  data[:user_courses] = user_courses.as_json
  data[:tutor_courses] = courses.as_json if tutor?
  data
end
upcomming_sessions_as_student() click to toggle source

Returns upcoming session of students.

# File app/models/concerns/mobile_api/user.rb, line 60
def  upcomming_sessions_as_student
  tutored_sesions.confirmed.upcoming
end
upcomming_sessions_as_tutor() click to toggle source

Returns upcoming session of tutors.

# File app/models/concerns/mobile_api/user.rb, line 55
def  upcomming_sessions_as_tutor
  tutoring_sessions.confirmed.upcoming
end