module Eco module API class MicroCases #self.define("set_account") do |entry, person, session, options| # @param entry [PersonEntry] the input entry with the data we should set on person. # @param person [Person] the person we want to update, carrying the changes to be done. # @param options [Hash] the options def set_account(entry, person, options) unless options.dig(:exclude, :account) ini_pg_ids = person.account&.policy_group_ids || [] account_excluded = [] if options.dig(:exclude, :policy_groups) && !person.new? account_excluded.push("policy_group_ids") end entry.set_account(person, exclude: account_excluded) session.microcases.set_default_group(entry, person, session, options) unless options.dig(:exclude, :abilities) && !person.new? person.account.permissions_custom = session.new_preset(person) end session.microcases.set_default_tag(entry, person, session, options) person.account.send_invites = options[:send_invites] if options.key?(:send_invites) end end end end end