main
 1# frozen_string_literal: true
 2
 3module SCIM
 4  class UserMapper
 5    def initialize(url_helpers)
 6      @url_helpers = url_helpers
 7    end
 8
 9    def map_from(user)
10      schema = Scim::Kit::V2.configuration.schemas[Scim::Kit::V2::Schemas::USER]
11      Scim::Kit::V2::Resource.new(
12        schemas: [schema],
13        location: @url_helpers.scim_v2_user_url(user)
14      ) do |x|
15        x.meta.version = user.lock_version
16        x.meta.created = user.created_at
17        x.meta.last_modified = user.updated_at
18        x.id = user.to_param
19        x.user_name = user.email
20        x.locale = user.locale
21        x.timezone = user.timezone
22        x.emails = [{ value: user.email, primary: true }]
23      end
24    end
25  end
26end