Sha256: 3fdb62ef99b2ecfb8f5c8e51baaeea5223f9cd5777f1ff7cb3ade3e8ff3802e6

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

module Bamboozled
  module API
    class Employee < Base

      def all(fields = nil)
        fields = all_fields if fields.nil?
        fields = fields.join(',') if fields.is_a?(Array)

        response = request(:get, "employees/directory?fields=#{fields}")
        response['employees']
      end

      def find(id, fields = nil)
        fields = all_fields if fields.nil?
        fields = fields.join(',') if fields.is_a?(Array)

        request(:get, "employees/#{id}?fields=#{fields}")
      end

      # Tabular data
      [:job_info, :employment_status, :compensation, :dependents, :contacts].each do |action|
        define_method(action.to_s) do |argument_id|
          request(:get, "employees/#{argument_id}/tables/#{action.to_s.gsub(/_(.)/) {|e| $1.upcase}}")
        end
      end

      def time_off_estimate(id, end_date)
        end_date = end_date.strftime("%F") unless end_date.is_a?(String)
        request(:get, "employees/#{id}/time_off/calculator?end=#{end_date}")
      end

      def default_fields
        %w(displayName firstName lastName jobTitle workPhone mobilePhone workEmail department location photoUploaded photoUrl canUploadPhoto).join(',')
      end

      def all_fields
        %w(address1 address2 age bestEmail birthday city country dateOfBirth department division eeo employeeNumber employmentHistoryStatus ethnicity exempt firstName flsaCode fullName1 fullName2 fullName3 fullName4 fullName5 displayName gender hireDate homeEmail homePhone id jobTitle lastChanged lastName location maritalStatus middleName mobilePhone nickname payChangeReason payGroup payGroupId payRate payRateEffectiveDate payType ssn sin state stateCode status supervisor supervisorId supervisorEId terminationDate workEmail workPhone workPhonePlusExtension workPhoneExtension zipcode photoUploaded rehireDate standardHoursPerWeek bonusDate bonusAmount bonusReason bonusComment commissionDate commisionDate commissionAmount commissionComment).join(',')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bamboozled-0.0.2 lib/bamboozled/api/employee.rb