iesde 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE +23 -0
- data/README.md +242 -0
- data/Rakefile +5 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/iesde.gemspec +28 -0
- data/lib/iesde.rb +39 -0
- data/lib/iesde/clients/cadastro.rb +32 -0
- data/lib/iesde/clients/inativa_acesso.rb +21 -0
- data/lib/iesde/clients/lista_curso.rb +22 -0
- data/lib/iesde/clients/logout.rb +34 -0
- data/lib/iesde/clients/obtem_aulas.rb +21 -0
- data/lib/iesde/clients/obtem_matriculas.rb +23 -0
- data/lib/iesde/config.rb +5 -0
- data/lib/iesde/error/validation_error.rb +6 -0
- data/lib/iesde/error/ws_error.rb +9 -0
- data/lib/iesde/model/aluno.rb +21 -0
- data/lib/iesde/model/aula.rb +21 -0
- data/lib/iesde/model/curso.rb +113 -0
- data/lib/iesde/model/matricula.rb +46 -0
- data/lib/iesde/version.rb +3 -0
- data/lib/iesde/wsdl_client.rb +79 -0
- metadata +140 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 1c838a05aa5322e830e239c6cddd036971c4f8e7
         | 
| 4 | 
            +
              data.tar.gz: 6db88f708d18409085c435d4910cd31864e22692
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: c88f21a60a06b95872d681d70488a513e7f83f789bc3fbfa34cee4586a4dc1003694fc2cef279c7626c4e721cd87e93c7391d73965d4fb26f46159d685b4103a
         | 
| 7 | 
            +
              data.tar.gz: 3acd2c40509fcdabcd5a508d1d4e766bcce1ccedb1858ceb69e302347d9af33a08d1b091b811a58dc2b62030e99901bd8d40fe946663d468595139a48db31424
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            LICENSE
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            The MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Copyright (c) 2016 Fortes Tecnologia.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 8 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 9 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 10 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 11 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 12 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 15 | 
            +
            all copies or substantial portions of the Software.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 18 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 19 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 20 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 21 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 22 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 23 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,242 @@ | |
| 1 | 
            +
            # Iesde
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Interface para acesso ao WebService do [Iesde][siteiesde] para sistemas Rails. Não se trata de uma ferramenta oficial pois foi desenvolvida por necessidade dos nossos desenvolvedores. Sintam-se livres para contribuir.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Índice
         | 
| 6 | 
            +
            \- [Iesde](#iesde)
         | 
| 7 | 
            +
              - [Versão](#vers%C3%A3o)
         | 
| 8 | 
            +
              - [Instalação](#instala%C3%A7%C3%A3o)
         | 
| 9 | 
            +
              - [Uso](#uso)
         | 
| 10 | 
            +
                - [Listagem de Cursos](#listagem-de-cursos)
         | 
| 11 | 
            +
                - [Busca de curso por Id](#busca-de-curso-por-id)
         | 
| 12 | 
            +
                - [Listagem de Aulas](#listagem-de-aulas)
         | 
| 13 | 
            +
                - [Listagem de Matrículas](#listagem-de-matr%C3%ADculas)
         | 
| 14 | 
            +
                - [Matricular Aluno](#matricular-aluno)
         | 
| 15 | 
            +
                - [Inativação de Aluno](#inativa%C3%A7%C3%A3o-de-aluno)
         | 
| 16 | 
            +
                - [Logout](#logout)
         | 
| 17 | 
            +
              - [Default Configs](#default-configs)
         | 
| 18 | 
            +
              - [Relacionamentos](#relacionamentos)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            ## Versão
         | 
| 21 | 
            +
            1.0.0 - Seguindo a documentação v14 do WebService
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ## Instalação
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ```sh
         | 
| 26 | 
            +
            gem install iesde -v 1.0.0
         | 
| 27 | 
            +
            ```
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            Ou no seu Gemfile
         | 
| 30 | 
            +
            ```ruby
         | 
| 31 | 
            +
            gem 'iesde', '~> 1.0.0'
         | 
| 32 | 
            +
            ```
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ## Uso
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            > Todas as buscas no WebService exigem os parâmetros **login** e **senha**.
         | 
| 37 | 
            +
            > Caso você possua apenas um usuário de acesso ao WebService, você pode configurar esses parâmetros em um initializer. 
         | 
| 38 | 
            +
            > Veja na seção [Default Configs](#default-configs).
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            ### Listagem de Cursos
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            Retorna um array de ```Iesde::Model::Curso```
         | 
| 43 | 
            +
            ```ruby
         | 
| 44 | 
            +
            parametros = {
         | 
| 45 | 
            +
                login:  "0123456789", 
         | 
| 46 | 
            +
                senha: "9d7d5741ab23397aa15937fcd4121a32", 
         | 
| 47 | 
            +
                busca: "", 
         | 
| 48 | 
            +
                tipo: "C", 
         | 
| 49 | 
            +
                site: "", 
         | 
| 50 | 
            +
                idCurso: ""
         | 
| 51 | 
            +
            }
         | 
| 52 | 
            +
            cursos = Iesde::Model::Curso.buscar(parametros)
         | 
| 53 | 
            +
            => [#<Iesde::Model::Curso>, #<Iesde::Model::Curso>, #<Iesde::Model::Curso>, ...]
         | 
| 54 | 
            +
            ```
         | 
| 55 | 
            +
            ### Busca de curso por Id
         | 
| 56 | 
            +
            Esta busca realiza uma varredura em todos os cursos e pacotes em busca do **id** passado como parâmetro.
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            Retorna um ```Iesde::Model::Curso```
         | 
| 59 | 
            +
            ```ruby
         | 
| 60 | 
            +
            curso = Iesde::Model::Curso.find id: 1000, login: "0123456789", senha: "9d7d5741ab23397aa15937fcd4121a32"
         | 
| 61 | 
            +
            => #<Iesde::Model::Curso>
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            curso.id
         | 
| 64 | 
            +
            => "1000"
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            curso.nome
         | 
| 67 | 
            +
            => "A BUSCA DA PERFEICÃO"
         | 
| 68 | 
            +
            ```
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            ### Listagem de Aulas
         | 
| 71 | 
            +
            Retorna um array de ```Iesde::Model::Aula```
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            ```ruby
         | 
| 74 | 
            +
            parametros = {
         | 
| 75 | 
            +
                login: "0123456789", 
         | 
| 76 | 
            +
                senha: "9d7d5741ab23397aa15937fcd4121a32", 
         | 
| 77 | 
            +
                loginAluno: "", 
         | 
| 78 | 
            +
                cpf: "", 
         | 
| 79 | 
            +
                curso: "1000", 
         | 
| 80 | 
            +
                ancora: "", 
         | 
| 81 | 
            +
                tipo: "C"
         | 
| 82 | 
            +
            }
         | 
| 83 | 
            +
            aulas = Iesde::Model::Aula.buscar(parametros)
         | 
| 84 | 
            +
            => [#<Iesde::Model::Aula>, #<Iesde::Model::Aula>, #<Iesde::Model::Aula>, ...]
         | 
| 85 | 
            +
            ```
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            Ou já tendo o curso carregado...
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            ```ruby
         | 
| 90 | 
            +
            curso.aulas
         | 
| 91 | 
            +
            => [#<Iesde::Model::Aula>, #<Iesde::Model::Aula>, #<Iesde::Model::Aula>, ...] 
         | 
| 92 | 
            +
            ```
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            ### Listagem de Matrículas
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            Retorna um array de ```Iesde::Model::Matricula ```
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            ```ruby
         | 
| 99 | 
            +
            parametros = {
         | 
| 100 | 
            +
                login: "0123456789", 
         | 
| 101 | 
            +
                senha: "9d7d5741ab23397aa15937fcd4121a32", 
         | 
| 102 | 
            +
                curso: "6376", 
         | 
| 103 | 
            +
                tipo: "C"
         | 
| 104 | 
            +
            }
         | 
| 105 | 
            +
            Iesde::Model::Matricula.buscar(parametros)
         | 
| 106 | 
            +
            => [#<Iesde::Model::Matricula>, #<Iesde::Model::Matricula>, #<Iesde::Model::Matricula>, ...]
         | 
| 107 | 
            +
            ```
         | 
| 108 | 
            +
            Ou já tendo o curso carregado...
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            ```ruby
         | 
| 111 | 
            +
            curso.matriculas
         | 
| 112 | 
            +
            => [#<Iesde::Model::Matricula>, #<Iesde::Model::Matricula>, #<Iesde::Model::Matricula>, ...]
         | 
| 113 | 
            +
            ```
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            ### Matricular Aluno
         | 
| 116 | 
            +
             | 
| 117 | 
            +
            Realiza a matrícula no WebService e retorna um ```Iesde::Model::Matricula```
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            ```ruby
         | 
| 120 | 
            +
            parametros = {
         | 
| 121 | 
            +
                login: "0190001388", 
         | 
| 122 | 
            +
                senha: "9d7d5741ab23397afeb81829a3d5ebd7", 
         | 
| 123 | 
            +
                loginAluno: "aluno@minhaorganizacao.com.br", 
         | 
| 124 | 
            +
                cpf: "12345678900", 
         | 
| 125 | 
            +
                curso: "1000", 
         | 
| 126 | 
            +
                duracao: "90", 
         | 
| 127 | 
            +
                tipo: "C", 
         | 
| 128 | 
            +
                valor: ""
         | 
| 129 | 
            +
            }
         | 
| 130 | 
            +
            matricula = Iesde::Model::Matricula.criar(parametros)
         | 
| 131 | 
            +
            => #<Iesde::Model::Matricula>
         | 
| 132 | 
            +
            ```
         | 
| 133 | 
            +
             | 
| 134 | 
            +
            ### Inativação de Aluno
         | 
| 135 | 
            +
             | 
| 136 | 
            +
            Inativa a matrícula e retorna ```true``` se sucesso.
         | 
| 137 | 
            +
             | 
| 138 | 
            +
            ```ruby
         | 
| 139 | 
            +
            parametros = {
         | 
| 140 | 
            +
                login: "0190001388", 
         | 
| 141 | 
            +
                senha: "9d7d5741ab23397afeb81829a3d5ebd7", 
         | 
| 142 | 
            +
                :"LoginID" => "12345"
         | 
| 143 | 
            +
            }
         | 
| 144 | 
            +
            Iesde::Model::Matricula.inativar(parametros)
         | 
| 145 | 
            +
            => true
         | 
| 146 | 
            +
            ```
         | 
| 147 | 
            +
             | 
| 148 | 
            +
            Ou caso já possua a matrícula carregada...
         | 
| 149 | 
            +
             | 
| 150 | 
            +
            ```ruby
         | 
| 151 | 
            +
            matricula.inativar
         | 
| 152 | 
            +
            => true
         | 
| 153 | 
            +
            ```
         | 
| 154 | 
            +
            ### Logout
         | 
| 155 | 
            +
             | 
| 156 | 
            +
            Realiza logout do aluno e retorna ```true``` se sucesso.
         | 
| 157 | 
            +
             | 
| 158 | 
            +
            ```ruby
         | 
| 159 | 
            +
            parametros = {
         | 
| 160 | 
            +
                login: "0190001388", 
         | 
| 161 | 
            +
                senha: "9d7d5741ab23397afeb81829a3d5ebd7", 
         | 
| 162 | 
            +
                loginAluno: "aluno@minhaorganizacao.com.br", 
         | 
| 163 | 
            +
                cpf: "12345678900"
         | 
| 164 | 
            +
            }
         | 
| 165 | 
            +
            Iesde::Model::Aluno.logout(parametros)
         | 
| 166 | 
            +
            => true
         | 
| 167 | 
            +
            ```
         | 
| 168 | 
            +
             | 
| 169 | 
            +
            Ou você pode obter a instância de ```Iesde::Model::Aluno``` e chamar diretamente...
         | 
| 170 | 
            +
             | 
| 171 | 
            +
            ```ruby
         | 
| 172 | 
            +
            aluno = matricula.aluno
         | 
| 173 | 
            +
            => #<Iesde::Model::Aluno>
         | 
| 174 | 
            +
            aluno.logout
         | 
| 175 | 
            +
            => true
         | 
| 176 | 
            +
            ```
         | 
| 177 | 
            +
             | 
| 178 | 
            +
            ```ruby
         | 
| 179 | 
            +
            aluno = curso.matriculas.first.aluno
         | 
| 180 | 
            +
            => #<Iesde::Model::Aluno>
         | 
| 181 | 
            +
            aluno.logout
         | 
| 182 | 
            +
            => true
         | 
| 183 | 
            +
            ```
         | 
| 184 | 
            +
             | 
| 185 | 
            +
            ## Default Configs
         | 
| 186 | 
            +
            Caso você utilize apenas um usuário do WebService em sua aplicação, seria interessante não passar os parâmetros **login** e **senha** em toda busca.
         | 
| 187 | 
            +
             | 
| 188 | 
            +
            Você pode configurar num initializer esses parâmetros:
         | 
| 189 | 
            +
             | 
| 190 | 
            +
            ```ruby
         | 
| 191 | 
            +
            Iesde::configure do |config|
         | 
| 192 | 
            +
                config.default_username = "0190001388"
         | 
| 193 | 
            +
                config.default_password = "9d7d5741ab23397afeb81829a3d5ebd7"
         | 
| 194 | 
            +
            end
         | 
| 195 | 
            +
            ```
         | 
| 196 | 
            +
             | 
| 197 | 
            +
            Então poderá realizar as requisições sem passar estes parâmetros. Exemplos:
         | 
| 198 | 
            +
             | 
| 199 | 
            +
            ```ruby
         | 
| 200 | 
            +
            cursos = Iesde::Model::Curso.buscar busca: "", tipo: "C", site: "", idCurso: ""
         | 
| 201 | 
            +
            => [#<Iesde::Model::Curso>, #<Iesde::Model::Curso>, #<Iesde::Model::Curso>, ...]
         | 
| 202 | 
            +
             | 
| 203 | 
            +
            curso = Iesde::Model::Curso.find id: 1000
         | 
| 204 | 
            +
            => #<Iesde::Model::Curso>
         | 
| 205 | 
            +
             | 
| 206 | 
            +
            Iesde::Model::Matricula.inativar :"LoginID" => "12345"
         | 
| 207 | 
            +
            => true
         | 
| 208 | 
            +
            ```
         | 
| 209 | 
            +
             | 
| 210 | 
            +
            ## Relacionamentos
         | 
| 211 | 
            +
             | 
| 212 | 
            +
             - Um ```Iesde::Model::Curso``` possui várias ```Iesde::Model::Aula```e várias ```Iesde::Model::Matricula```
         | 
| 213 | 
            +
             - Uma ```Iesde::Model::Matricula``` possui um ```Iesde::Model::Aluno``` e um ```Iesde::Model::Curso```
         | 
| 214 | 
            +
             - Logo ```Iesde::Model::Curso``` possui vários ```Iesde::Model::Aluno```
         | 
| 215 | 
            +
            ```ruby
         | 
| 216 | 
            +
            # Busca aulas no WS do curso
         | 
| 217 | 
            +
            curso.aulas
         | 
| 218 | 
            +
            => [#<Iesde::Model::Aula>, #<Iesde::Model::Aula>, #<Iesde::Model::Aula>, ...]
         | 
| 219 | 
            +
             | 
| 220 | 
            +
            aula.curso
         | 
| 221 | 
            +
            => #<Iesde::Model::Curso>
         | 
| 222 | 
            +
             | 
| 223 | 
            +
            curso.matriculas
         | 
| 224 | 
            +
            => [#<Iesde::Model::Matricula>, #<Iesde::Model::Matricula>, #<Iesde::Model::Matricula>, ...]
         | 
| 225 | 
            +
             | 
| 226 | 
            +
            matricula.curso
         | 
| 227 | 
            +
            => #<Iesde::Model::Curso>
         | 
| 228 | 
            +
             | 
| 229 | 
            +
            matricula.aluno
         | 
| 230 | 
            +
            => #<Iesde::Model::Aluno>
         | 
| 231 | 
            +
             | 
| 232 | 
            +
            curso.alunos
         | 
| 233 | 
            +
            => [#<Iesde::Model::Aluno>, #<Iesde::Model::Aluno>, #<Iesde::Model::Aluno>, ...]
         | 
| 234 | 
            +
            ```
         | 
| 235 | 
            +
             | 
| 236 | 
            +
            > A maioria destas operações só busca do WS uma vez. Ao buscar as aulas de um curso, elas já vem com o curso carregado em suas instâncias, evitando outra chamada ao WS para buscar o curso ao fazer ```aula.curso```.
         | 
| 237 | 
            +
             | 
| 238 | 
            +
            ## Licença
         | 
| 239 | 
            +
             | 
| 240 | 
            +
            MIT Licence. Copyright (c) 2016 Fortes Tecnologia. http://www.fortestecnologia.com.br
         | 
| 241 | 
            +
             | 
| 242 | 
            +
            [siteiesde]:<http://www.iesde.com.br>
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "iesde"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 | 
            +
            # with your gem easier. You can also use a different console, if you like.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         | 
| 10 | 
            +
            # require "pry"
         | 
| 11 | 
            +
            # Pry.start
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "irb"
         | 
| 14 | 
            +
            IRB.start
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/iesde.gemspec
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'iesde/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "iesde"
         | 
| 8 | 
            +
              spec.version       = Iesde::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Pedro Benevides"]
         | 
| 10 | 
            +
              spec.email         = ["pedroaugusto@gmail.com"]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = "Client do WebService SOAP do IESDE"
         | 
| 13 | 
            +
              spec.description   = "Esta não é uma versão oficial"
         | 
| 14 | 
            +
              spec.homepage      = "https://github.com/fortesinformatica/iesde"
         | 
| 15 | 
            +
              spec.license       = "MIT"
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 18 | 
            +
              spec.bindir        = "exe"
         | 
| 19 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 20 | 
            +
              spec.require_paths = ["lib"]
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              spec.add_development_dependency "bundler", "~> 1.8"
         | 
| 23 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 24 | 
            +
              spec.add_dependency "savon", "~> 2.10"
         | 
| 25 | 
            +
              spec.add_dependency "json", "~> 1.7"
         | 
| 26 | 
            +
              spec.add_dependency "activesupport", "~> 4.2"
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            end
         | 
    
        data/lib/iesde.rb
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'active_support/core_ext/module/attribute_accessors'
         | 
| 2 | 
            +
            require 'active_support/inflector'
         | 
| 3 | 
            +
            require 'json'
         | 
| 4 | 
            +
            require 'savon'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Iesde
         | 
| 7 | 
            +
              module Clients
         | 
| 8 | 
            +
                autoload :ListaCurso,"iesde/clients/lista_curso"
         | 
| 9 | 
            +
                autoload :ObtemAula,"iesde/clients/obtem_aulas"
         | 
| 10 | 
            +
                autoload :ObtemMatricula,"iesde/clients/obtem_matriculas"
         | 
| 11 | 
            +
                autoload :Cadastro,"iesde/clients/cadastro"
         | 
| 12 | 
            +
                autoload :InativaAcesso,"iesde/clients/inativa_acesso"
         | 
| 13 | 
            +
                autoload :Logout,"iesde/clients/logout"
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              module Error
         | 
| 17 | 
            +
                autoload :ValidationError,'iesde/error/validation_error'
         | 
| 18 | 
            +
                autoload :WSError,'iesde/error/ws_error'
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              module Model
         | 
| 22 | 
            +
                autoload :Curso,"iesde/model/curso"
         | 
| 23 | 
            +
                autoload :Aula,"iesde/model/aula"
         | 
| 24 | 
            +
                autoload :Matricula,"iesde/model/matricula"
         | 
| 25 | 
            +
                autoload :Aluno,"iesde/model/aluno"
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              autoload :VERSION, "iesde/version"
         | 
| 29 | 
            +
              autoload :Config,"iesde/config"
         | 
| 30 | 
            +
              autoload :WSDLClient,"iesde/wsdl_client"
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              mattr_accessor :config
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def self.configure
         | 
| 35 | 
            +
                self.config ||= Iesde::Config.new
         | 
| 36 | 
            +
                yield(config) if block_given?
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Clients
         | 
| 3 | 
            +
                class Cadastro < Iesde::WSDLClient
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  CODIGO_RETORNO_SUCESSO = "001"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def initialize
         | 
| 8 | 
            +
                    @action = "Cadastro"
         | 
| 9 | 
            +
                    @wsdl_url = "http://ws.videoaulasonline.com.br/aluno/cadastro/wsdl"
         | 
| 10 | 
            +
                    @format = [ :login, :senha, :loginAluno, :cpf, :curso, :duracao, :tipo, :valor ]
         | 
| 11 | 
            +
                    @obligatory_params = [ :login, :senha, :loginAluno, :cpf, :curso, :duracao, :tipo ]
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def check_params params
         | 
| 15 | 
            +
                    errors = super params
         | 
| 16 | 
            +
                    errors << "[LoginAluno pode ter no máx 100 digitos]" if params[:loginAluno].size > 100
         | 
| 17 | 
            +
                    errors << "[CPF pode ter no máx 11 digitos]" if params[:cpf].size > 11
         | 
| 18 | 
            +
                    errors << "[Curso pode ter no máx 6 digitos]" if params[:curso].size > 6
         | 
| 19 | 
            +
                    errors << "[Duracao precisa ser múltiplo de 30 dias e ter no máx 4 dígitos]" if params[:duracao].to_s.size > 4 || params[:duracao].to_i % 30 != 0
         | 
| 20 | 
            +
                    errors << "[Tipo pode ser uma das letras P, C ou E]" unless ['P','C', 'E'].include?(params[:tipo])
         | 
| 21 | 
            +
                    errors
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def map response
         | 
| 25 | 
            +
                    ws_message = Iesde::Error::WSError.new(response)
         | 
| 26 | 
            +
                    raise ws_message if ws_message.code != CODIGO_RETORNO_SUCESSO
         | 
| 27 | 
            +
                    true
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Clients
         | 
| 3 | 
            +
                class InativaAcesso < Iesde::WSDLClient
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  CODIGO_RETORNO_SUCESSO = "020"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def initialize
         | 
| 8 | 
            +
                    @action = "inativaAcesso"
         | 
| 9 | 
            +
                    @format = [ :login, :senha, :"LoginID" ]
         | 
| 10 | 
            +
                    @obligatory_params = [ :login, :senha, :"LoginID" ]
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def map response
         | 
| 14 | 
            +
                    ws_message = Iesde::Error::WSError.new(response)
         | 
| 15 | 
            +
                    raise ws_message if ws_message.code != CODIGO_RETORNO_SUCESSO
         | 
| 16 | 
            +
                    true
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Clients
         | 
| 3 | 
            +
                class ListaCurso < Iesde::WSDLClient
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def initialize
         | 
| 6 | 
            +
                    @model = Iesde::Model::Curso
         | 
| 7 | 
            +
                    @action = "listaCurso"
         | 
| 8 | 
            +
                    @format = [ :login, :senha, :busca, :tipo, :site, :idCurso ]
         | 
| 9 | 
            +
                    @obligatory_params = [ :login, :senha, :busca, :tipo, :site ]
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def check_params params
         | 
| 13 | 
            +
                    errors = super params
         | 
| 14 | 
            +
                    errors << "[Busca pode ter no máx 100 digitos]" if params[:busca].size > 100
         | 
| 15 | 
            +
                    errors << "[Tipo pode ser uma das letras P, C ou E]" unless ['P','C', 'E'].include?(params[:tipo])
         | 
| 16 | 
            +
                    errors << "[Quando tipo for P precisa especificar idCurso]" if params[:tipo] == 'P' && params[:idCurso].blank?
         | 
| 17 | 
            +
                    errors
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Clients
         | 
| 3 | 
            +
                class Logout < Iesde::WSDLClient
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  CODIGO_RETORNO_LOGOUT_JA_REALIZADO = "027"
         | 
| 6 | 
            +
                  CODIGO_RETORNO_LOGOUT_REALIZADO = "028"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def initialize
         | 
| 9 | 
            +
                    @wsdl_url = "http://ws.videoaulasonline.com.br/index.php/aluno/logout/wsdl"
         | 
| 10 | 
            +
                    @action = "logout"
         | 
| 11 | 
            +
                    @format = [ :login, :senha, :loginAluno, :cpf ]
         | 
| 12 | 
            +
                    @obligatory_params = [ :login, :senha, :loginAluno, :cpf ]
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def check_params params
         | 
| 16 | 
            +
                    errors = super params
         | 
| 17 | 
            +
                    errors << "[LoginAluno pode ter no máx 100 digitos]" if params[:loginAluno].size > 100
         | 
| 18 | 
            +
                    errors << "[CPF pode ter no máx 11 digitos]" if params[:cpf].size > 11
         | 
| 19 | 
            +
                    errors
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def map response
         | 
| 23 | 
            +
                    ws_message = Iesde::Error::WSError.new(response)
         | 
| 24 | 
            +
                    raise ws_message unless [CODIGO_RETORNO_LOGOUT_JA_REALIZADO, CODIGO_RETORNO_LOGOUT_REALIZADO].include?(ws_message.code)
         | 
| 25 | 
            +
                    true
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def response_param
         | 
| 29 | 
            +
                    :logout
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Clients
         | 
| 3 | 
            +
                class ObtemAula < Iesde::WSDLClient
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def initialize
         | 
| 6 | 
            +
                    @model = Iesde::Model::Aula
         | 
| 7 | 
            +
                    @action = "obtemAulas"
         | 
| 8 | 
            +
                    @format = [ :login, :senha, :loginAluno, :cpf, :curso, :ancora, :tipo ]
         | 
| 9 | 
            +
                    @obligatory_params = [ :login, :senha, :loginAluno, :cpf, :curso, :tipo ]
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def check_params params
         | 
| 13 | 
            +
                    errors = super params
         | 
| 14 | 
            +
                    errors << "[Curso pode ter no máx 6 digitos]" if params[:curso].size > 6
         | 
| 15 | 
            +
                    errors << "[Tipo pode ser uma das letras P, C ou E]" unless ['P','C', 'E'].include?(params[:tipo])
         | 
| 16 | 
            +
                    errors
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Clients
         | 
| 3 | 
            +
                class ObtemMatricula < Iesde::WSDLClient
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  CODIGO_RETORNO_NENHUMA_ENCONTRADA = "010"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def initialize
         | 
| 8 | 
            +
                    @model = Iesde::Model::Matricula
         | 
| 9 | 
            +
                    @action = "obtemMatriculas"
         | 
| 10 | 
            +
                    @format = [ :login, :senha, :curso, :tipo ]
         | 
| 11 | 
            +
                    @obligatory_params = [ :login, :senha, :curso, :tipo ]
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def check_params params
         | 
| 15 | 
            +
                    errors = super params
         | 
| 16 | 
            +
                    errors << "[Curso pode ter no máx 6 digitos]" if params[:curso].size > 6
         | 
| 17 | 
            +
                    errors << "[Tipo pode ser uma das letras P, C ou E]" unless ['P','C', 'E'].include?(params[:tipo])
         | 
| 18 | 
            +
                    errors
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        data/lib/iesde/config.rb
    ADDED
    
    
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Model
         | 
| 3 | 
            +
                class Aluno
         | 
| 4 | 
            +
                  attr_accessor :login_aluno, :cpf, :login, :senha
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def initialize(*args)
         | 
| 7 | 
            +
                    @login_aluno, @cpf, @login, @senha = args
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def self.logout params
         | 
| 11 | 
            +
                    client_logout = Iesde::WSDLClient.create :logout
         | 
| 12 | 
            +
                    client_logout.run params
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def logout
         | 
| 16 | 
            +
                    Aluno.logout login: @login, senha: @senha, loginAluno: @login_aluno, cpf: @cpf
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Model
         | 
| 3 | 
            +
                class Aula
         | 
| 4 | 
            +
                  attr_accessor :curso_id, :nome_curso, :categoria, :subcategoria, :id, :ordem, :tema, :autores, :duracao, :login_aluno, :cpf, :disciplina_id, :disciplina, :login, :senha, :curso
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def initialize(*args)
         | 
| 7 | 
            +
                    @curso_id, @nome_curso, @categoria, @subcategoria, @id, @ordem, @tema, @autores, @duracao, @login_aluno, @cpf, @disciplina_id, @disciplina = args
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def self.buscar params
         | 
| 11 | 
            +
                    client_obtem_aulas = WSDLClient.create :obtem_aulas
         | 
| 12 | 
            +
                    client_obtem_aulas.run params
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def curso
         | 
| 16 | 
            +
                    @curso ||= Curso.find id: @curso_id, login: @login, senha: @senha
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,113 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Model
         | 
| 3 | 
            +
                class Curso
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  TIPO_CURSOS_PADRAO = %w(C E)
         | 
| 6 | 
            +
                  TIPO_CURSO_PACOTE = 'P'
         | 
| 7 | 
            +
                  SITES_CURSOS = %w(4 22 10 7 6 13)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  attr_accessor :tipo, :id, :nome, :objetivo, :temas, :autores, :carga_horaria, :valor, :quant_aulas, :categoria, :video_demo, :pdf_demo, :login, :senha
         | 
| 10 | 
            +
                  attr_reader :aulas, :matriculas
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def initialize(*args)
         | 
| 13 | 
            +
                    @tipo, @id, @nome, @objetivo, @temas, @autores, @carga_horaria, @valor, @quant_aulas, @categoria, @video_demo, @pdf_demo = args
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def self.find params
         | 
| 17 | 
            +
                    curso = nil
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    if !params[:id].blank? && !params[:login].blank? && !params[:senha].blank?
         | 
| 20 | 
            +
                      search_params = { login: params[:login], senha: params[:senha], busca: "", tipo: "", site: "", idCurso: params[:id].to_s }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                      curso = buscar_cursos_padrao search_params
         | 
| 23 | 
            +
                      curso = buscar_cursos_nos_pacotes search_params unless curso
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                    return curso
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def self.buscar params
         | 
| 29 | 
            +
                    client_busca_curso = WSDLClient.create :lista_curso
         | 
| 30 | 
            +
                    cursos = client_busca_curso.run params
         | 
| 31 | 
            +
                    cursos.each do |curso|
         | 
| 32 | 
            +
                      curso.login = params[:login] 
         | 
| 33 | 
            +
                      curso.senha = params[:senha] 
         | 
| 34 | 
            +
                      curso.tipo = params[:tipo] 
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def aulas
         | 
| 39 | 
            +
                    @aulas ||= buscar_aulas
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  def matriculas
         | 
| 43 | 
            +
                    begin
         | 
| 44 | 
            +
                      @matriculas ||= buscar_matriculas
         | 
| 45 | 
            +
                    rescue Iesde::Error::WSError => e
         | 
| 46 | 
            +
                      if e.code == Iesde::Clients::ObtemMatricula::CODIGO_RETORNO_NENHUMA_ENCONTRADA
         | 
| 47 | 
            +
                        @matriculas = []
         | 
| 48 | 
            +
                      else
         | 
| 49 | 
            +
                        raise e
         | 
| 50 | 
            +
                      end
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                    @matriculas
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def alunos
         | 
| 56 | 
            +
                    matriculas.map &:aluno
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  private
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  def self.buscar_cursos_padrao params
         | 
| 62 | 
            +
                    curso = nil
         | 
| 63 | 
            +
                    TIPO_CURSOS_PADRAO.each do |tipo|
         | 
| 64 | 
            +
                      begin
         | 
| 65 | 
            +
                        params[:tipo] = tipo
         | 
| 66 | 
            +
                        cursos = Curso.buscar params
         | 
| 67 | 
            +
                        if cursos
         | 
| 68 | 
            +
                          curso = cursos.first
         | 
| 69 | 
            +
                          break
         | 
| 70 | 
            +
                        end
         | 
| 71 | 
            +
                      rescue Exception
         | 
| 72 | 
            +
                      end
         | 
| 73 | 
            +
                    end
         | 
| 74 | 
            +
                    curso
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  def self.buscar_cursos_nos_pacotes params
         | 
| 78 | 
            +
                    curso = nil
         | 
| 79 | 
            +
                    params[:tipo] = TIPO_CURSO_PACOTE
         | 
| 80 | 
            +
                    SITES_CURSOS.each do |site|
         | 
| 81 | 
            +
                      begin
         | 
| 82 | 
            +
                        params[:site] = site
         | 
| 83 | 
            +
                        cursos = Curso.buscar params
         | 
| 84 | 
            +
                        if cursos
         | 
| 85 | 
            +
                          curso = cursos.first
         | 
| 86 | 
            +
                          break
         | 
| 87 | 
            +
                        end
         | 
| 88 | 
            +
                      rescue Exception
         | 
| 89 | 
            +
                      end
         | 
| 90 | 
            +
                    end
         | 
| 91 | 
            +
                    curso
         | 
| 92 | 
            +
                  end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  def buscar_aulas
         | 
| 95 | 
            +
                    aulas = Aula.buscar login: @login, senha: @senha, loginAluno: "", cpf: "", curso: @id, ancora: "", tipo: @tipo
         | 
| 96 | 
            +
                    passar_dados aulas
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  def buscar_matriculas
         | 
| 100 | 
            +
                    matriculas = Matricula.buscar login: @login, senha: @senha, curso: @id, tipo: @tipo
         | 
| 101 | 
            +
                    passar_dados matriculas
         | 
| 102 | 
            +
                  end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                  def passar_dados modelos
         | 
| 105 | 
            +
                    modelos.each do |modelo|
         | 
| 106 | 
            +
                      modelo.login = @login
         | 
| 107 | 
            +
                      modelo.senha = @senha
         | 
| 108 | 
            +
                      modelo.curso = self
         | 
| 109 | 
            +
                    end
         | 
| 110 | 
            +
                  end
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              module Model
         | 
| 3 | 
            +
                class Matricula
         | 
| 4 | 
            +
                  attr_accessor :curso_id, :nome_curso, :data_inclusao, :duracao, :email_aluno, :cpf_aluno, :id, :login, :senha, :curso
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def initialize(*args)
         | 
| 7 | 
            +
                    @curso_id, @nome_curso, @data_inclusao, @duracao, @email_aluno, @cpf_aluno, @id = args
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def self.buscar params
         | 
| 11 | 
            +
                    client_obtem_matriculas = WSDLClient.create :obtem_matriculas
         | 
| 12 | 
            +
                    matriculas = client_obtem_matriculas.run params
         | 
| 13 | 
            +
                    matriculas.each do |matricula|
         | 
| 14 | 
            +
                      matricula.login = params[:login]
         | 
| 15 | 
            +
                      matricula.senha = params[:senha]
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def self.criar params
         | 
| 20 | 
            +
                    client_cadastro = WSDLClient.create :cadastro
         | 
| 21 | 
            +
                    if client_cadastro.run(params)
         | 
| 22 | 
            +
                      matriculas = buscar params.except(:loginAluno, :cpf, :duracao, :valor)
         | 
| 23 | 
            +
                      matriculas.select { |matricula| matricula.email_aluno == params[:loginAluno] }.first
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def self.inativar params
         | 
| 28 | 
            +
                    client_inativa_acesso = WSDLClient.create :inativa_acesso
         | 
| 29 | 
            +
                    client_inativa_acesso.run params
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def inativar
         | 
| 33 | 
            +
                    Matricula.inativar login: @login, senha: @senha, :"LoginID" => @id
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  def curso
         | 
| 37 | 
            +
                    @curso ||= Curso.find id: @curso_id, login: @login, senha: @senha
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  def aluno
         | 
| 41 | 
            +
                    @aluno ||= Aluno.new @email_aluno, @cpf_aluno, @login, @senha
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| @@ -0,0 +1,79 @@ | |
| 1 | 
            +
            module Iesde
         | 
| 2 | 
            +
              class WSDLClient
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                CLIENTS_FOLDER = 'iesde/clients/'
         | 
| 5 | 
            +
                SAVON_WEB_SERVICE_ENCODING = "iso-8859-1"
         | 
| 6 | 
            +
                DEFAULT_WSDL_URL = "http://ws.videoaulasonline.com.br/acoes_webservice/:action/wsdl"
         | 
| 7 | 
            +
                REQUEST_SUFIX = 'Request'
         | 
| 8 | 
            +
                RESPONSE_PARAM_SUFIX = '_response'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                attr_accessor :action, :client, :format, :obligatory_params, :model, :wsdl_url
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def self.create client_name
         | 
| 13 | 
            +
                  client_name.to_s.prepend(CLIENTS_FOLDER).classify.constantize.new
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def fetch_user_credentials params
         | 
| 17 | 
            +
                  { login: Iesde.config.default_username, senha: Iesde.config.default_password }.merge(params)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def check_params_format params
         | 
| 21 | 
            +
                  errors = ""
         | 
| 22 | 
            +
                  errors << "[Parâmetros incorretos! formato -> #{@format}]" unless params.keys.eql? @format
         | 
| 23 | 
            +
                  errors
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def check_obligatory_params params
         | 
| 27 | 
            +
                  errors = ""
         | 
| 28 | 
            +
                  @obligatory_params.each do |param|
         | 
| 29 | 
            +
                    errors << "#{param} - Parâmetro Obrigatório!" if params[param].nil?
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                  errors
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def check_params params
         | 
| 35 | 
            +
                  errors = ""
         | 
| 36 | 
            +
                  errors << "[Login pode ter no máx 10 digitos]" if params[:login].size > 10
         | 
| 37 | 
            +
                  errors << "[Senha pode ter no máx 32 digitos]" if params[:senha].size > 32
         | 
| 38 | 
            +
                  errors
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def validate params
         | 
| 42 | 
            +
                  errors = check_params_format params
         | 
| 43 | 
            +
                  errors = check_obligatory_params params if errors.empty?
         | 
| 44 | 
            +
                  errors = check_params params if errors.empty?
         | 
| 45 | 
            +
                  errors
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                def map response
         | 
| 49 | 
            +
                  JSON.parse(response).collect do |item|
         | 
| 50 | 
            +
                    model.new *item.values
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
                rescue JSON::ParserError
         | 
| 53 | 
            +
                  raise Iesde::Error::WSError.new(response)
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def response_param
         | 
| 57 | 
            +
                  :resultado
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def run params
         | 
| 61 | 
            +
                  params = fetch_user_credentials(params) if Iesde.config && params[:login].blank? && params[:senha].blank?
         | 
| 62 | 
            +
                  errors = validate params
         | 
| 63 | 
            +
                  raise Iesde::Error::ValidationError.new(errors) unless errors.blank?
         | 
| 64 | 
            +
                  ws_response = client.call @action.underscore.to_sym, message: params, attributes: { name: (@action + REQUEST_SUFIX) }
         | 
| 65 | 
            +
                  raw_response = ws_response.body[@action.underscore.concat(RESPONSE_PARAM_SUFIX).to_sym][response_param]
         | 
| 66 | 
            +
                  map raw_response
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                private
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                def client
         | 
| 72 | 
            +
                  @client ||= Savon.client encoding: SAVON_WEB_SERVICE_ENCODING, wsdl: build_wsdl_url
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                def build_wsdl_url
         | 
| 76 | 
            +
                  @wsdl_url || DEFAULT_WSDL_URL.gsub(/:action/, @action)
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,140 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: iesde
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Pedro Benevides
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2016-02-24 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ~>
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.8'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ~>
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.8'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ~>
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ~>
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '10.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: savon
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ~>
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '2.10'
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ~>
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '2.10'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: json
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ~>
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '1.7'
         | 
| 62 | 
            +
              type: :runtime
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ~>
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '1.7'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: activesupport
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ~>
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '4.2'
         | 
| 76 | 
            +
              type: :runtime
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ~>
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '4.2'
         | 
| 83 | 
            +
            description: Esta não é uma versão oficial
         | 
| 84 | 
            +
            email:
         | 
| 85 | 
            +
            - pedroaugusto@gmail.com
         | 
| 86 | 
            +
            executables: []
         | 
| 87 | 
            +
            extensions: []
         | 
| 88 | 
            +
            extra_rdoc_files: []
         | 
| 89 | 
            +
            files:
         | 
| 90 | 
            +
            - .gitignore
         | 
| 91 | 
            +
            - .rspec
         | 
| 92 | 
            +
            - .travis.yml
         | 
| 93 | 
            +
            - Gemfile
         | 
| 94 | 
            +
            - LICENSE
         | 
| 95 | 
            +
            - README.md
         | 
| 96 | 
            +
            - Rakefile
         | 
| 97 | 
            +
            - bin/console
         | 
| 98 | 
            +
            - bin/setup
         | 
| 99 | 
            +
            - iesde.gemspec
         | 
| 100 | 
            +
            - lib/iesde.rb
         | 
| 101 | 
            +
            - lib/iesde/clients/cadastro.rb
         | 
| 102 | 
            +
            - lib/iesde/clients/inativa_acesso.rb
         | 
| 103 | 
            +
            - lib/iesde/clients/lista_curso.rb
         | 
| 104 | 
            +
            - lib/iesde/clients/logout.rb
         | 
| 105 | 
            +
            - lib/iesde/clients/obtem_aulas.rb
         | 
| 106 | 
            +
            - lib/iesde/clients/obtem_matriculas.rb
         | 
| 107 | 
            +
            - lib/iesde/config.rb
         | 
| 108 | 
            +
            - lib/iesde/error/validation_error.rb
         | 
| 109 | 
            +
            - lib/iesde/error/ws_error.rb
         | 
| 110 | 
            +
            - lib/iesde/model/aluno.rb
         | 
| 111 | 
            +
            - lib/iesde/model/aula.rb
         | 
| 112 | 
            +
            - lib/iesde/model/curso.rb
         | 
| 113 | 
            +
            - lib/iesde/model/matricula.rb
         | 
| 114 | 
            +
            - lib/iesde/version.rb
         | 
| 115 | 
            +
            - lib/iesde/wsdl_client.rb
         | 
| 116 | 
            +
            homepage: https://github.com/fortesinformatica/iesde
         | 
| 117 | 
            +
            licenses:
         | 
| 118 | 
            +
            - MIT
         | 
| 119 | 
            +
            metadata: {}
         | 
| 120 | 
            +
            post_install_message: 
         | 
| 121 | 
            +
            rdoc_options: []
         | 
| 122 | 
            +
            require_paths:
         | 
| 123 | 
            +
            - lib
         | 
| 124 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 125 | 
            +
              requirements:
         | 
| 126 | 
            +
              - - '>='
         | 
| 127 | 
            +
                - !ruby/object:Gem::Version
         | 
| 128 | 
            +
                  version: '0'
         | 
| 129 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 130 | 
            +
              requirements:
         | 
| 131 | 
            +
              - - '>='
         | 
| 132 | 
            +
                - !ruby/object:Gem::Version
         | 
| 133 | 
            +
                  version: '0'
         | 
| 134 | 
            +
            requirements: []
         | 
| 135 | 
            +
            rubyforge_project: 
         | 
| 136 | 
            +
            rubygems_version: 2.4.6
         | 
| 137 | 
            +
            signing_key: 
         | 
| 138 | 
            +
            specification_version: 4
         | 
| 139 | 
            +
            summary: Client do WebService SOAP do IESDE
         | 
| 140 | 
            +
            test_files: []
         |