Sha256: a5796ccc7949a2f38cce56e80b167812b04831549fc2a08839c12a9ab9b388d6

Contents?: true

Size: 952 Bytes

Versions: 7

Compression:

Stored size: 952 Bytes

Contents

require 'rubygems'

module EROI
  module Response
    class Base
      attr_reader :data

      def initialize(data)
        @data = data
      end
    end

    class Get < Base
      def success?
        (@data['ErrorCode'] || @data['xml']) ? false : true
      end

      def contact
        @data['Retrieve']['Record']
      end

      alias :contacts :contact

      def error_message
        case @data['ErrorCode'].to_i
        when 1
          'Invalid username/password was provided.'
        when 2
          'Invalid mailing list was provided.'
        when 3
          'Invalid edition was provided.'
        end
      end
    end

    class Post < Base
      def success?
        @data['Response']['Compiled'] == 'Yes' &&
        @data['Response']['DBConnect'] == 'OK' &&
        @data['Response']['XMLUpload'] == 'Complete'
      end

      def number_of_records
        @data['Response']['ImportRecords'].to_i
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eroi-0.2.1 lib/eroi/response.rb
eroi-0.2.0 lib/eroi/response.rb
eroi-0.1.4 lib/eroi/response.rb
eroi-0.1.3 lib/eroi/response.rb
eroi-0.1.2 lib/eroi/response.rb
eroi-0.1.1 lib/eroi/response.rb
eroi-0.1.0 lib/eroi/response.rb