mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
DEV: Update API documentation for invites (#12360)
This commit is contained in:
parent
36ec09a07b
commit
9c93a62b97
@ -57,7 +57,6 @@ class InvitesController < ApplicationController
|
||||
|
||||
begin
|
||||
invite = Invite.generate(current_user,
|
||||
invite_key: params[:invite_key],
|
||||
email: params[:email],
|
||||
skip_email: params[:skip_email],
|
||||
invited_by: current_user,
|
||||
|
@ -133,7 +133,7 @@ class Invite < ActiveRecord::Base
|
||||
emailed_status: emailed_status
|
||||
)
|
||||
else
|
||||
create_args = opts.slice(:invite_key, :email, :moderator, :custom_message, :max_redemptions_allowed)
|
||||
create_args = opts.slice(:email, :moderator, :custom_message, :max_redemptions_allowed)
|
||||
create_args[:invited_by] = invited_by
|
||||
create_args[:email] = email
|
||||
create_args[:emailed_status] = emailed_status
|
||||
|
@ -5,9 +5,10 @@ class InviteSerializer < ApplicationSerializer
|
||||
:link,
|
||||
:email,
|
||||
:emailed,
|
||||
:redemption_count,
|
||||
:max_redemptions_allowed,
|
||||
:redemption_count,
|
||||
:custom_message,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:expires_at,
|
||||
:expired
|
||||
@ -27,6 +28,18 @@ class InviteSerializer < ApplicationSerializer
|
||||
object.emailed_status != Invite.emailed_status_types[:not_required]
|
||||
end
|
||||
|
||||
def include_custom_message?
|
||||
email.present?
|
||||
end
|
||||
|
||||
def include_max_redemptions_allowed?
|
||||
email.blank?
|
||||
end
|
||||
|
||||
def include_redemption_count?
|
||||
email.blank?
|
||||
end
|
||||
|
||||
def expired
|
||||
object.expired?
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ describe 'invites' do
|
||||
let(:'Api-Username') { 'system' }
|
||||
|
||||
path '/invites.json' do
|
||||
post 'Invite to site by email' do
|
||||
post 'Create an invite' do
|
||||
tags 'Invites'
|
||||
consumes 'application/json'
|
||||
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
||||
@ -16,16 +16,31 @@ describe 'invites' do
|
||||
parameter name: :request_body, in: :body, schema: {
|
||||
type: :object,
|
||||
properties: {
|
||||
email: { type: :string },
|
||||
group_names: { type: :string },
|
||||
custom_message: { type: :string },
|
||||
}, required: ['email']
|
||||
email: { type: :string, example: "not-a-user-yet@example.com", description: "required for email invites only" },
|
||||
skip_email: { type: :boolean, default: false },
|
||||
custom_message: { type: :string, description: "optional, for email invites" },
|
||||
max_redemptions_allowed: { type: :integer, example: 5, default: 1, description: "optional, for link invites" },
|
||||
topic_id: { type: :int },
|
||||
group_id: { type: [:int], description: "optional, either this or `group_names`" },
|
||||
group_names: { type: :string, description: "optional, either this or `group_id`" },
|
||||
expires_at: { type: :string, default: "controlled by invite_expiry_days site setting" },
|
||||
}
|
||||
}
|
||||
|
||||
produces 'application/json'
|
||||
response '200', 'success response' do
|
||||
schema type: :object, properties: {
|
||||
success: { type: :string, example: "OK" }
|
||||
id: { type: :integer, example: 42 },
|
||||
link: { type: :string, example: "http://example.com/invites/9045fd767efe201ca60c6658bcf14158" },
|
||||
email: { type: :string, example: "not-a-user-yet@example.com" },
|
||||
emailed: { type: :boolean, example: false },
|
||||
custom_message: { type: :string, example: "Hello world!", nullable: true },
|
||||
topics: { type: :array, example: [] },
|
||||
groups: { type: :array, example: [] },
|
||||
created_at: { type: :string, example: "2021-01-01T12:00:00.000Z" },
|
||||
updated_at: { type: :string, example: "2021-01-01T12:00:00.000Z" },
|
||||
expires_at: { type: :string, example: "2021-02-01T12:00:00.000Z" },
|
||||
expired: { type: :boolean, example: false },
|
||||
}
|
||||
|
||||
let(:request_body) { { email: 'not-a-user-yet@example.com' } }
|
||||
|
Loading…
Reference in New Issue
Block a user