File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed
Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 99client . api_username = config [ 'api_username' ] || "YOUR_USERNAME"
1010
1111# invite user
12- client . invite_user ( email : "name@example.com" , group_ids : "41,42" )
12+ invite = client . invite_user ( email : "name@example.com" , group_ids : "41,42" )
13+
14+ #update invite
15+ client . update_invite ( invite [ "id" ] , email : "namee@example.com" )
1316
1417# invite to a topic
1518client . invite_user_to_topic ( email : "foo@bar.com" , topic_id : 1 )
Original file line number Diff line number Diff line change @@ -39,6 +39,22 @@ def invite_to_topic(topic_id, params = {})
3939 def disposable_tokens ( params = { } )
4040 post ( "/invite-token/generate" , params )
4141 end
42+
43+ def update_invite ( invite_id , params = { } )
44+ args = API . params ( params )
45+ . optional (
46+ :topic_id ,
47+ :group_ids ,
48+ :group_names ,
49+ :email ,
50+ :send_email ,
51+ :custom_message ,
52+ :max_redemptions_allowed ,
53+ :expires_at
54+ ) . to_h
55+
56+ put ( "invites/#{ invite_id } " , args )
57+ end
4258 end
4359 end
4460end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+ require 'spec_helper'
3+
4+ describe DiscourseApi ::API ::Invite do
5+ subject { DiscourseApi ::Client . new ( "#{ host } " , "test_d7fd0429940" , "test_user" ) }
6+
7+ describe "#invite_user" do
8+ before do
9+ stub_post ( "#{ host } /invites" ) . to_return ( body : fixture ( "topic_invite_user.json" ) , headers : { content_type : "application/json" } )
10+ end
11+
12+ it "requests the correct resource" do
13+ subject . invite_user ( email : "fake_user@example.com" , group_ids : "41,42" )
14+ expect ( a_post ( "#{ host } /invites" ) ) . to have_been_made
15+ end
16+
17+ it "returns success" do
18+ response = subject . invite_user ( email : "fake_user@example.com" , group_ids : "41,42" )
19+ expect ( response ) . to be_a Hash
20+ expect ( response [ 'success' ] ) . to be_truthy
21+ end
22+ end
23+
24+ describe "#update_invite" do
25+ before do
26+ stub_put ( "#{ host } /invites/27" ) . to_return ( body : fixture ( "topic_invite_user.json" ) , headers : { content_type : "application/json" } )
27+ end
28+
29+ it "updates invite" do
30+ subject . update_invite ( 27 , email : "namee@example.com" )
31+ expect ( a_put ( "#{ host } /invites/27" ) ) . to have_been_made
32+ end
33+ end
34+ end
You can’t perform that action at this time.
0 commit comments