Sha256: b2b9a8bcc32e2a277937ef09e1c483602dddc1bcedaf1f98a5dbf030d5f7dba3

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

module Moip::Assinaturas
  class Invoice

    class << self

      def list(subscription_code, opts={})
        response = Moip::Assinaturas::Client.list_invoices(subscription_code, opts)
        hash     = JSON.load(response.body).with_indifferent_access

        case response.code
        when 200
          return {
            success:  true,
            invoices: hash[:invoices]
          }
        else
          raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
        end
      end

      def details(id, opts={})
        response = Moip::Assinaturas::Client.details_invoice(id, opts)
        hash     = JSON.load(response.body)
        hash     = hash.with_indifferent_access if hash

        case response.code
        when 200
          return {
            success:  true,
            invoice:  hash
          }
        when 404
          return {
            success: false,
            message: 'not found'
          }
        else
          raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
moip-assinaturas-0.6.0 lib/moip-assinaturas/invoice.rb
moip-assinaturas-0.5.1 lib/moip-assinaturas/invoice.rb
moip-assinaturas-0.5.0 lib/moip-assinaturas/invoice.rb
moip-assinaturas-0.4.2 lib/moip-assinaturas/invoice.rb
moip-assinaturas-0.4.1 lib/moip-assinaturas/invoice.rb
moip-assinaturas-0.4.0 lib/moip-assinaturas/invoice.rb