Sha256: f58c6b13ee5f495cc8649f9f05d5672c48464ff94d9c096750050a7d44db43e5

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

require "request"

module MyMoip
  class TransparentRequest < Request

    HTTP_METHOD   = :post
    PATH          = "/ws/alpha/EnviarInstrucao/Unica"
    REQUIRES_AUTH = true

    def api_call(data, logger = MyMoip.logger)
      params = {
        body:          data.to_xml,
        http_method:   HTTP_METHOD,
        requires_auth: REQUIRES_AUTH,
        path:          PATH,
        logger:        logger
      }

      super params
    end

    def success?
      @response && @response["EnviarInstrucaoUnicaResponse"]["Resposta"]["Status"] == "Sucesso"
    rescue NoMethodError => e
      false
    end

    def token
      @response["EnviarInstrucaoUnicaResponse"]["Resposta"]["Token"] || nil
    rescue NoMethodError => e
      nil
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mymoip-0.2.2 lib/mymoip/transparent_request.rb
mymoip-0.2.1 lib/mymoip/transparent_request.rb