2020-10-26 22:55:22 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'swagger_helper'
|
|
|
|
|
|
|
|
describe 'invites' do
|
|
|
|
|
|
|
|
let(:'Api-Key') { Fabricate(:api_key).key }
|
|
|
|
let(:'Api-Username') { 'system' }
|
|
|
|
|
|
|
|
path '/invites.json' do
|
2021-03-12 00:19:32 +08:00
|
|
|
post 'Create an invite' do
|
2020-10-26 22:55:22 +08:00
|
|
|
tags 'Invites'
|
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
|
|
|
|
parameter name: :request_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
2021-03-12 00:19:32 +08:00
|
|
|
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" },
|
2021-08-13 02:25:17 +08:00
|
|
|
topic_id: { type: :integer },
|
|
|
|
group_id: { type: :integer, description: "optional, either this or `group_names`" },
|
2021-03-12 00:19:32 +08:00
|
|
|
group_names: { type: :string, description: "optional, either this or `group_id`" },
|
|
|
|
expires_at: { type: :string, default: "controlled by invite_expiry_days site setting" },
|
|
|
|
}
|
2020-10-26 22:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'success response' do
|
|
|
|
schema type: :object, properties: {
|
2021-03-12 00:19:32 +08:00
|
|
|
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 },
|
2021-08-13 02:25:17 +08:00
|
|
|
custom_message: { type: [:string, :null], example: "Hello world!" },
|
2021-03-12 00:19:32 +08:00
|
|
|
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 },
|
2020-10-26 22:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let(:request_body) { { email: 'not-a-user-yet@example.com' } }
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|