2020-10-26 22:55:22 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require "swagger_helper"
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe "invites" do
|
2020-10-26 22:55:22 +08:00
|
|
|
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"
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId "createInvite"
|
2020-10-26 22:55:22 +08:00
|
|
|
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: {
|
2023-01-09 19:18:21 +08:00
|
|
|
email: {
|
2020-10-26 22:55:22 +08:00
|
|
|
type: :string,
|
2021-03-12 00:19:32 +08:00
|
|
|
example: "not-a-user-yet@example.com",
|
2020-10-26 22:55:22 +08:00
|
|
|
description: "required for email invites only",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-03-12 00:19:32 +08:00
|
|
|
skip_email: {
|
2020-10-26 22:55:22 +08:00
|
|
|
type: :boolean,
|
2021-03-12 00:19:32 +08:00
|
|
|
default: false,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-08-13 02:25:17 +08:00
|
|
|
custom_message: {
|
2021-03-12 00:19:32 +08:00
|
|
|
type: :string,
|
|
|
|
description: "optional, for email invites",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-03-12 00:19:32 +08:00
|
|
|
max_redemptions_allowed: {
|
2020-10-26 22:55:22 +08:00
|
|
|
type: :integer,
|
2021-03-12 00:19:32 +08:00
|
|
|
example: 5,
|
|
|
|
default: 1,
|
|
|
|
description: "optional, for link invites",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-10-26 22:55:22 +08:00
|
|
|
topic_id: {
|
2021-03-12 00:19:32 +08:00
|
|
|
type: :integer,
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-08-13 02:25:17 +08:00
|
|
|
group_id: {
|
2021-03-12 00:19:32 +08:00
|
|
|
type: :integer,
|
2021-08-13 02:25:17 +08:00
|
|
|
description: "optional, either this or `group_names`",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-03-12 00:19:32 +08:00
|
|
|
group_names: {
|
2020-10-26 22:55:22 +08:00
|
|
|
type: :string,
|
|
|
|
description: "optional, either this or `group_id`",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2020-10-26 22:55:22 +08:00
|
|
|
expires_at: {
|
|
|
|
type: :string,
|
|
|
|
description:
|
|
|
|
"optional, if not supplied, the invite_expiry_days site setting is used",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
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,
|
|
|
|
},
|
2023-01-09 19:18:21 +08:00
|
|
|
link: {
|
2021-03-12 00:19:32 +08:00
|
|
|
type: :string,
|
|
|
|
example: "http://example.com/invites/9045fd767efe201ca60c6658bcf14158",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-03-12 00:19:32 +08:00
|
|
|
email: {
|
|
|
|
type: :string,
|
|
|
|
example: "not-a-user-yet@example.com",
|
|
|
|
},
|
|
|
|
emailed: {
|
|
|
|
type: :boolean,
|
|
|
|
example: false,
|
|
|
|
},
|
|
|
|
custom_message: {
|
|
|
|
type: %i[string null],
|
|
|
|
example: "Hello world!",
|
|
|
|
},
|
|
|
|
topics: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
},
|
|
|
|
example: [],
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2022-06-21 00:56:56 +08:00
|
|
|
groups: {
|
|
|
|
type: :array,
|
2023-01-09 19:18:21 +08:00
|
|
|
items: {
|
|
|
|
},
|
2022-06-21 00:56:56 +08:00
|
|
|
example: [],
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-03-12 00:19:32 +08:00
|
|
|
created_at: {
|
|
|
|
type: :string,
|
|
|
|
example: "2021-01-01T12:00:00.000Z",
|
|
|
|
},
|
2021-10-07 19:41:04 +08:00
|
|
|
updated_at: {
|
|
|
|
type: :string,
|
|
|
|
example: "2021-01-01T12:00:00.000Z",
|
|
|
|
},
|
|
|
|
expires_at: {
|
|
|
|
type: :string,
|
2021-03-12 00:19:32 +08:00
|
|
|
example: "2021-02-01T12:00:00.000Z",
|
2023-01-09 19:18:21 +08:00
|
|
|
},
|
2021-10-07 19:41:04 +08:00
|
|
|
expired: {
|
2021-03-12 00:19:32 +08:00
|
|
|
type: :boolean,
|
2021-10-07 19:41:04 +08:00
|
|
|
example: false,
|
2021-03-12 00:19:32 +08:00
|
|
|
},
|
2020-10-26 22:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let(:request_body) { { email: "not-a-user-yet@example.com" } }
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|