Sha256: 1442d655865faa7b681f3f851a09150c7f42dc2efbf1e89a23dfdf3ae23848e4

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

module Velocity
  module Api
    class Invite < Velocity::Api::Base
      def create
        post("/invitations", body)
      end

      private

      def body
        {
          body: {
            data: {
              type: "invitations",
              attributes: attributes,
              relationships: relationships
            }
          }.to_json
        }
      end

      def attributes
        {
          name: args.fetch(:name),
          email: args.fetch(:email),
          jobFunction: args.fetch(:job_function)
        }
      end

      def relationships
        {
          roles: {
            data: args.fetch(:role_ids).map do |role_id|
              {
                type: "roles",
                id: role_id
              }
            end
          }
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
velocity_client_ruby-0.3.0 lib/velocity/api/invite.rb