Sha256: 056af0d5894be3a6ee790d1551d6b0e8e075572c71ed658eb0fe38f110366b11

Contents?: true

Size: 718 Bytes

Versions: 6

Compression:

Stored size: 718 Bytes

Contents

module PagSeguro
  class Refund < Request
    attr_accessor :request

    def initialize(transaction_code)
      @transaction_code = transaction_code
      @request = {}
    end

    def request(account = nil)
      @request = post("/transactions/refunds", account, transactionCode: @transaction_code)
      @request.response.code == '200'
    end

    def errors
      case @request.response.code
      when '400'
        errors = @request.parsed_response
        [errors['errors']['error']].flatten
      when '200'
        []
      when '403'
        [{'code' => '403', 'message' => 'Forbidden'}]
      else
        [{'code' => @request.response.code.to_s, 'message' => 'Unkown Error'}]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pagseguro-transparente-0.2.5 lib/pagseguro/refund.rb
pagseguro-transparente-0.2.4 lib/pagseguro/refund.rb
pagseguro-transparente-0.2.3 lib/pagseguro/refund.rb
pagseguro-transparente-0.2.2 lib/pagseguro/refund.rb
pagseguro-transparente-0.2.1 lib/pagseguro/refund.rb
pagseguro-transparente-0.2.0 lib/pagseguro/refund.rb