Sha256: d292b5591d1e6cf0282f75e923f9f7945839a7c7de2fedbbad412be0b3401710

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

module Inforouter #:nodoc:
  module Responses #:nodoc:
    # Response to an infoRouter Get All Users API call.
    #
    # See http://www.inforouter.com/web-services-80/default.aspx?op=GetAllUsers
    class Users < Base
      response_success 'get_all_users_response/get_all_users_result/response/@success'
      error_message 'get_all_users_response/get_all_users_result/response/@error'

      class << self
        # Parse an infoRouter response.
        #
        # @param savon_response [Savon::Response] SOAP response.
        #
        # @return [Array]
        def parse(savon_response)
          response = new(savon_response)
          users = response.match('get_all_users_response/get_all_users_result/response/users/user')
          users.map do |user|
            Inforouter::User.new(
              id: user[:@user_id].to_i,
              domain: user[:@domain].strip,
              user_name: user[:@user_name].strip,
              first_name: user[:@first_name].strip,
              last_name: user[:@last_name].strip,
              last_logon: DateTime.strptime(user[:@last_logon_date], '%Y-%m-%d %H:%M:%S'),
              last_password_change: DateTime.strptime(user[:@last_password_change_date], '%Y-%m-%d %H:%M:%S'),
              authentication_authority: user[:@authentication_authority].strip,
              read_only: user[:@read_only_user] == 'TRUE',
              email: user[:@email].strip,
              enabled: user[:@enabled] == 'TRUE'
            )
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inforouter-0.3.0 lib/inforouter/responses/users.rb
inforouter-0.2.9 lib/inforouter/responses/users.rb
inforouter-0.2.8 lib/inforouter/responses/users.rb
inforouter-0.2.7 lib/inforouter/responses/users.rb
inforouter-0.2.6 lib/inforouter/responses/users.rb