Sha256: 6b080ce0b60c157428776d0de0325b399a52b147066768a71aee63fdc9381436

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

module Roqua
  module CoreApi
    # @api private
    class SendInviteEmail < ActiveInteraction::Base
      object :session, class: Sessions::AuthSession
      string :dossier_id, default: nil
      string :person_id, default: nil
      string :email_subject, default: nil
      string :email_body, default: nil

      validates :person_id, presence: true, if: -> { dossier_id.nil? }

      def execute
        session.post url, params
      end

      private

      def url
        if person_id
          "/people/#{person_id}/send_invite_email"
        else
          "/dossiers/#{dossier_id}/send_invite_email"
        end
      end

      def params
        {
          email_subject: email_subject, email_body: email_body
        }.delete_if { |k, v| v.nil? }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roqua-core-api-0.7.0 lib/roqua/core_api/send_invite_email.rb
roqua-core-api-0.6.0 lib/roqua/core_api/send_invite_email.rb