Module: DiscourseApi::API::Invite

Included in:
Client
Defined in:
lib/discourse_api/api/invite.rb

Instance Method Summary collapse

Instance Method Details

#destroy_all_expired_invitesObject



67
68
69
# File 'lib/discourse_api/api/invite.rb', line 67

def destroy_all_expired_invites
  post("invites/destroy-all-expired")
end

#destroy_invite(invite_id) ⇒ Object



79
80
81
# File 'lib/discourse_api/api/invite.rb', line 79

def destroy_invite(invite_id)
  delete("/invites", { id: invite_id })
end

#disposable_tokens(params = {}) ⇒ Object



44
45
46
# File 'lib/discourse_api/api/invite.rb', line 44

def disposable_tokens(params = {})
  post("/invite-token/generate", params)
end

#invite_to_topic(topic_id, params = {}) ⇒ Object



29
30
31
32
33
# File 'lib/discourse_api/api/invite.rb', line 29

def invite_to_topic(topic_id, params = {})
  args = API.params(params).optional(:email, :user, :group_ids, :custom_message).to_h

  post("/t/#{topic_id}/invite", args)
end

#invite_user(params = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/discourse_api/api/invite.rb', line 5

def invite_user(params = {})
  args =
    API
      .params(params)
      .optional(
        :email,
        :skip_email,
        :custom_message,
        :max_redemptions_allowed,
        :topic_id,
        :group_ids,
        :expires_at,
      )
      .to_h

  post("/invites", args)
end

#invite_user_to_topic(params = {}) ⇒ Object

TODO: Deprecated. Remove after 20220506



24
25
26
27
# File 'lib/discourse_api/api/invite.rb', line 24

def invite_user_to_topic(params = {})
  deprecated(__method__, "invite_to_topic")
  invite_to_topic(params[:topic_id], params)
end

#resend_all_invitesObject



71
72
73
# File 'lib/discourse_api/api/invite.rb', line 71

def resend_all_invites
  post("invites/reinvite-all")
end

#resend_invite(email) ⇒ Object



75
76
77
# File 'lib/discourse_api/api/invite.rb', line 75

def resend_invite(email)
  post("invites/reinvite", { email: email })
end

#retrieve_invite(params = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/discourse_api/api/invite.rb', line 35

def retrieve_invite(params = {})
  args = API.params(params).required(:email).to_h

  response = get("invites/retrieve.json", args)

  response.body
end

#update_invite(invite_id, params = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/discourse_api/api/invite.rb', line 48

def update_invite(invite_id, params = {})
  args =
    API
      .params(params)
      .optional(
        :topic_id,
        :group_ids,
        :group_names,
        :email,
        :send_email,
        :custom_message,
        :max_redemptions_allowed,
        :expires_at,
      )
      .to_h

  put("invites/#{invite_id}", args)
end