Class: Iesde::Model::Matricula

Inherits:
Object
  • Object
show all
Includes:
Stringable
Defined in:
lib/iesde/model/matricula.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Stringable

#to_s

Constructor Details

#initialize(*args) ⇒ Matricula

Returns a new instance of Matricula.



8
9
10
# File 'lib/iesde/model/matricula.rb', line 8

def initialize(*args)
  @matricula_id, @login_id, @situacao, @dt_cadastro, @curso_id, @polo_id, @curso, @aluno, @cpf, @email, @situacao_descricao, @sexo = args
end

Instance Attribute Details

#alunoObject

Returns the value of attribute aluno.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def aluno
  @aluno
end

#cpfObject

Returns the value of attribute cpf.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def cpf
  @cpf
end

#cursoObject

Returns the value of attribute curso.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def curso
  @curso
end

#curso_idObject

Returns the value of attribute curso_id.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def curso_id
  @curso_id
end

#dt_cadastroObject

Returns the value of attribute dt_cadastro.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def dt_cadastro
  @dt_cadastro
end

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def email
  @email
end

#login_idObject

Returns the value of attribute login_id.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def 
  @login_id
end

#matricula_idObject

Returns the value of attribute matricula_id.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def matricula_id
  @matricula_id
end

#polo_idObject

Returns the value of attribute polo_id.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def polo_id
  @polo_id
end

#sexoObject

Returns the value of attribute sexo.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def sexo
  @sexo
end

#situacaoObject

Returns the value of attribute situacao.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def situacao
  @situacao
end

#situacao_descricaoObject

Returns the value of attribute situacao_descricao.



6
7
8
# File 'lib/iesde/model/matricula.rb', line 6

def situacao_descricao
  @situacao_descricao
end

Class Method Details

.alterar_status(params) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/iesde/model/matricula.rb', line 43

def self.alterar_status(params)
  api = Iesde::Api::AlterarStatusMatricula.new(:json, params)

  if api.salvo_com_sucesso?
    api.msg
  else
    raise Iesde::Error::WSError.new(api.msg)
  end
end

.buscar(config = {}) ⇒ Object



12
13
14
15
16
# File 'lib/iesde/model/matricula.rb', line 12

def self.buscar(config = {})
  matriculas_obtidas = Iesde::Api::ObterMatricula.new(:json, config)

  matriculas_obtidas.underscorize_fields(Matricula)
end

.criar(params = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/iesde/model/matricula.rb', line 18

def self.criar(params = {})
  matricula = Iesde::Api::CriarMatricula.new(:json, params)

  if matricula.salvo_com_sucesso?
    Iesde::Model::Matricula.buscar(params).select do |mat|
      mat.matricula_id.to_s == matricula.matricula_id_do_retorno.to_s
    end.first
  else
    raise Iesde::Error::WSError.new(matricula.msg)
  end
end

.criar_com_campos_obrigatorios(curso_id, nome, cpf, email, cep, numero, opts = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/iesde/model/matricula.rb', line 30

def self.criar_com_campos_obrigatorios(curso_id, nome, cpf, email, cep, numero, opts = {})
  self.criar(
  {
    'CursoID' => curso_id,
    'Nome'    => nome,
    'CPF'     => cpf,
    'Email'   => email,
    'CEP'     => cep,
    'Numero'  => numero
  }.merge(opts)
  )
end

Instance Method Details

#ativar!(opts = {}) ⇒ Object



53
54
55
56
57
58
# File 'lib/iesde/model/matricula.rb', line 53

def ativar!(opts = {})
  Iesde::Model::Matricula.alterar_status({
    'MatriculaID' => self.matricula_id,
    'Situacao'    => 'A'
  }.merge(opts))
end

#inativar!(opts = {}) ⇒ Object



60
61
62
63
64
65
# File 'lib/iesde/model/matricula.rb', line 60

def inativar!(opts = {})
  Iesde::Model::Matricula.alterar_status({
    'MatriculaID' => self.matricula_id,
    'Situacao'    => 'I'
  }.merge(opts))
end