Sha256: bca274362dde9a71174443e7c07e4d667c4d0e82ca919507b65916651d764255

Contents?: true

Size: 1.39 KB

Versions: 25

Compression:

Stored size: 1.39 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:)
        options = {
          'IsSystem' => false,
          'FirstName' => first_name,
          'LastName' => last_name,
          'Email' => email,
          'Gender' => 1
        }
        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

25 entries across 25 versions & 1 rubygems

Version Path
rock_rms-4.9.0 lib/rock_rms/resources/person.rb
rock_rms-4.8.0 lib/rock_rms/resources/person.rb
rock_rms-4.7.0 lib/rock_rms/resources/person.rb
rock_rms-4.6.0 lib/rock_rms/resources/person.rb
rock_rms-4.5.0 lib/rock_rms/resources/person.rb
rock_rms-4.4.0 lib/rock_rms/resources/person.rb
rock_rms-4.3.0 lib/rock_rms/resources/person.rb
rock_rms-4.2.3 lib/rock_rms/resources/person.rb
rock_rms-4.2.2 lib/rock_rms/resources/person.rb
rock_rms-4.2.1 lib/rock_rms/resources/person.rb
rock_rms-4.2.0 lib/rock_rms/resources/person.rb
rock_rms-4.1.1 lib/rock_rms/resources/person.rb
rock_rms-4.1.0 lib/rock_rms/resources/person.rb
rock_rms-4.0.0 lib/rock_rms/resources/person.rb
rock_rms-3.9.0 lib/rock_rms/resources/person.rb
rock_rms-3.8.0 lib/rock_rms/resources/person.rb
rock_rms-3.7.0 lib/rock_rms/resources/person.rb
rock_rms-3.6.3 lib/rock_rms/resources/person.rb
rock_rms-3.6.2 lib/rock_rms/resources/person.rb
rock_rms-3.6.1 lib/rock_rms/resources/person.rb