Sha256: 7fb99aa6748dae5adea520d0fbdf1a757dee3205b50bfc550082ec54e5107483

Contents?: true

Size: 1.21 KB

Versions: 35

Compression:

Stored size: 1.21 KB

Contents

module RockRMS
  class Client
    module Group
      def list_groups(options = {})
        Response::Group.format(get(group_path, options))
      end

      def find_group(id)
        Response::Group.format(get(group_path(id)))
      end

      def list_groups_for_person(person_id, options = {})
        opts = options.dup
        opts['$filter'] = Array(opts['$filter'])
          .push("Members/any(m: m/PersonId eq #{person_id})")
          .join(' and ')
        opts['$expand'] ||= 'Members'

        list_groups(opts)
      end

      def list_families_for_person(person_id, options = {})
        Response::Group.format(
          get("Groups/GetFamilies/#{person_id}", options)
        )
      end

      #
      # address_format
      # {
      #   street1:,
      #   street2:,
      #   city:,
      #   state:,
      #   postal_code:,
      #   country:,
      # }
      #
      def save_group_address(group_id:, location_type_id:, address:)
        url_params = TransformHashKeys.camelize_keys(address)

        put("Groups/SaveAddress/#{group_id}/#{location_type_id}?#{URI.encode_www_form(url_params)}")
      end

      private

      def group_path(id = nil)
        id ? "Groups/#{id}" : 'Groups'
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
rock_rms-9.14.0 lib/rock_rms/resources/group.rb
rock_rms-9.13.0 lib/rock_rms/resources/group.rb
rock_rms-9.12.0 lib/rock_rms/resources/group.rb
rock_rms-9.11.0 lib/rock_rms/resources/group.rb
rock_rms-9.10.0 lib/rock_rms/resources/group.rb
rock_rms-9.9.0 lib/rock_rms/resources/group.rb
rock_rms-9.8.0 lib/rock_rms/resources/group.rb
rock_rms-9.7.0 lib/rock_rms/resources/group.rb
rock_rms-9.6.0 lib/rock_rms/resources/group.rb
rock_rms-9.5.0 lib/rock_rms/resources/group.rb
rock_rms-9.4.0 lib/rock_rms/resources/group.rb
rock_rms-9.3.0 lib/rock_rms/resources/group.rb
rock_rms-9.2.0 lib/rock_rms/resources/group.rb
rock_rms-9.1.0 lib/rock_rms/resources/group.rb
rock_rms-9.0.0 lib/rock_rms/resources/group.rb
rock_rms-8.23.0 lib/rock_rms/resources/group.rb
rock_rms-8.22.0 lib/rock_rms/resources/group.rb
rock_rms-8.21.0 lib/rock_rms/resources/group.rb
rock_rms-8.20.0 lib/rock_rms/resources/group.rb
rock_rms-8.19.0 lib/rock_rms/resources/group.rb