Sha256: 63fed235a04e3015efef5419ba241bda049299f134136b95f89f47c252778a72

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

module Segurofacil
  class Estagiario

    extend Segurofacil::REST::EstagiarioCreate
    extend Segurofacil::REST::EstagiarioRemove

    NAME='nome'
    CPF='cPF'
    BIRTHDATE='dOB'
    GENDER='sexoId'

    MALE=1
    FEMALE=2

    attr_reader :name, :cpf, :birthdate, :gender

    def initialize(options)
      @name      = options.fetch(NAME)
      @cpf       = options.fetch(CPF)
      @birthdate = options.fetch(BIRTHDATE)
      @gender    = options.fetch(GENDER)
    end

    def male?
      gender == MALE
    end

    def female?
      gender == FEMALE
    end

    class << self

      def create(estagiario, cnpj)
        res = super estagiario, cnpj
        get_create_response(res)
      end

      # Remove a estagiario from the policy
      # @param estagiario_cpf [String] the estagiario to be removed
      # @param cnpj [String] the cnpj of the company that holds the estagiario's policy
      # @return EstagiarioRemoveResponse
      def remove(estagiario_cpf, cnpj)
        res = super estagiario_cpf, cnpj
        get_remove_response(res)
      end

      def convert_to_estagiario(hash)
        self.new hash
      end

      def ary_to_estagiarios(list)
        return [] if list.nil?
        list.map {|item| convert_to_estagiario(item) }
      end

      private

      def get_create_response(res)
        Segurofacil::Responses::EstagiarioCreateResponse.new(res)
      end

      def get_remove_response(res)
        Segurofacil::Responses::EstagiarioRemoveResponse.new(res)
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
segurofacil-ruby-0.1.8 lib/segurofacil/estagiario.rb
segurofacil-ruby-0.1.7 lib/segurofacil/estagiario.rb
segurofacil-0.1.7 lib/segurofacil/estagiario.rb