Sha256: 3d0e2a62bd3d69e0b57350b1fe5db9429ae142d5f7f3d4f016c2d5438c3b85fc

Contents?: true

Size: 1.58 KB

Versions: 30

Compression:

Stored size: 1.58 KB

Contents

module RockRMS
  class Client
    module Person
      def list_people(options = {})
        res = get(people_path, options)
        Response::Person.format(res)
      end

      def find_person(id)
        res = get(people_path(id))
        Response::Person.format(res)
      end

      def find_person_by_alias_id(id)
        Response::Person.format(get("People/GetByPersonAliasId/#{id}"))
      end

      def find_person_by_email(email)
        res = get("People/GetByEmail/#{email}")
        Response::Person.format(res)
      end

      NAME_SEARCH_DEFAULTS = {
        includeHtml: false,
        includeDetails: true,
        includeBusinesses: false,
        includeDeceased: false
      }.freeze

      def find_person_by_name(full_name, options = {})
        priority = options.merge(name: full_name)

        Response::Person.format(
          get('People/Search', NAME_SEARCH_DEFAULTS.merge(priority))
        )
      end

      def create_person(first_name:, last_name:, email:, connection_status_value_id: nil, record_status_value_id: nil)
        options = {
          'IsSystem' => false,
          'FirstName' => first_name,
          'LastName' => last_name,
          'Email' => email,
          'Gender' => 1,
          'ConnectionStatusValueId' => connection_status_value_id,
          'RecordStatusValueId'     => record_status_value_id
        }
        post(people_path, options)
      end

      def update_person(id, options = {})
        put(people_path(id), options)
      end

      private

      def people_path(id = nil)
        id ? "People/#{id}" : 'People'
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rock_rms-5.15.0 lib/rock_rms/resources/person.rb
rock_rms-5.14.0 lib/rock_rms/resources/person.rb
rock_rms-5.13.0 lib/rock_rms/resources/person.rb
rock_rms-5.12.0 lib/rock_rms/resources/person.rb
rock_rms-5.11.0 lib/rock_rms/resources/person.rb
rock_rms-5.10.0 lib/rock_rms/resources/person.rb
rock_rms-5.9.2 lib/rock_rms/resources/person.rb
rock_rms-5.9.1 lib/rock_rms/resources/person.rb
rock_rms-5.9.0 lib/rock_rms/resources/person.rb
rock_rms-5.8.1 lib/rock_rms/resources/person.rb
rock_rms-5.8.0 lib/rock_rms/resources/person.rb
rock_rms-5.7.1 lib/rock_rms/resources/person.rb
rock_rms-5.7.0 lib/rock_rms/resources/person.rb
rock_rms-5.6.0 lib/rock_rms/resources/person.rb
rock_rms-5.5.0 lib/rock_rms/resources/person.rb
rock_rms-5.4.0 lib/rock_rms/resources/person.rb
rock_rms-5.3.0 lib/rock_rms/resources/person.rb
rock_rms-5.2.0 lib/rock_rms/resources/person.rb
rock_rms-5.1.0 lib/rock_rms/resources/person.rb
rock_rms-5.0.0 lib/rock_rms/resources/person.rb