Sha256: fdb541aebb441612487b627d3a6b0a9ae035542a8a939afc73a8887c60db20c4

Contents?: true

Size: 766 Bytes

Versions: 11

Compression:

Stored size: 766 Bytes

Contents

module Roqua
  module CoreApi
    # @api private
    class CreateProfessional < Base
      object :session, class: Sessions::AuthSession
      string :dossier_group_id
      object :person, class: Models::Person
      string :email_subject, default: nil
      string :email_body, default: nil

      def execute
        response = session.post "/dossier_groups/#{dossier_group_id}/people", params
        if response.code == 422
          errors_to_object(response, person)
          person
        else
          Models::Person.new(response['person'])
        end
      end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
roqua-core-api-0.7.0 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.6.0 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.5.0 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.4.0 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.3.1 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.3.0 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.2.4 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.2.3 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.2.2 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.2.1 lib/roqua/core_api/create_professional.rb
roqua-core-api-0.2.0 lib/roqua/core_api/create_professional.rb