discourse_api 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ef911002c1690ecf2093d99c557ae50703185d6
4
- data.tar.gz: d641e827fc1717f3a72b5db1af1e8ab9d9c8ec9f
3
+ metadata.gz: c30c8d6075c413eb4eb59d301ef84df97e09bb02
4
+ data.tar.gz: c9d564671e6b060d7c220e075f78f8459c6e1338
5
5
  SHA512:
6
- metadata.gz: 677f0b8b8e7a1225936f4a9bf50c74d2dc8e0dd1a909a5e2aa4b33685e385e8aff7372510d35081e4dbca430e7533737cff3a95dbb941e889087868858d8e4b4
7
- data.tar.gz: 443b8b0733f8294d473fa8bd35a97e5cc1050dc242ef1fcf6bcd42fa98698307c8e1485d8532b7dad6ae0e392616a93a5541ec1214c3a04d7cca6a13df99bc88
6
+ metadata.gz: fee2ef5f539d1ab91009f220dd25427dbe5e91afabb9e5b079d1bef32715a4f8f1151a11cd1ee5783e8523438a9dc3e343e9b61da5ea3495513ce379091f3e94
7
+ data.tar.gz: ae8ad784a1d21fed5e4142763e759534243567c472fbcaac325d9d6988eae24d233f965aed03580db860161b8730da25a6dcec11e9250c245460819b703172ae
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [0.18.0] - 2017-10-17
6
+ ### Added
7
+ - Added update_group API call
8
+ ### Fixed
9
+ - Fixed params for create groups endpoint
10
+ - Fixed invite token API endpoint
11
+
5
12
  ## [0.17.0] - 2017-06-29
6
13
  ### Added
7
14
  - Add title to SSO sync
@@ -1,3 +1,5 @@
1
+ # requires this plugin => https://github.com/discourse/discourse-invite-tokens
2
+
1
3
  require 'csv'
2
4
 
3
5
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
@@ -4,9 +4,57 @@ module DiscourseApi
4
4
  def create_group(args)
5
5
  args = API.params(args)
6
6
  .required(:name)
7
- .default(visible: true)
7
+ .default(visibility_level: 0)
8
+ .optional(:mentionable_level,
9
+ :messageable_level,
10
+ :automatic_membership_email_domains,
11
+ :automatic_membership_retroactive,
12
+ :title,
13
+ :primary_group,
14
+ :grant_trust_level,
15
+ :incoming_email,
16
+ :flair_url,
17
+ :flair_bg_color,
18
+ :flair_color,
19
+ :bio_raw,
20
+ :public_admission,
21
+ :public_exit,
22
+ :allow_membership_requests,
23
+ :full_name,
24
+ :default_notification_level,
25
+ :usernames,
26
+ :owner_usernames,
27
+ :membership_request_template)
8
28
  .to_h
9
- post("/admin/groups", args)
29
+ post("/admin/groups", group: args)
30
+ end
31
+
32
+ def update_group(group_id, args)
33
+ args = API.params(args)
34
+ .default(visibility_level: 0)
35
+ .optional(:mentionable_level,
36
+ :messageable_level,
37
+ :name,
38
+ :automatic_membership_email_domains,
39
+ :automatic_membership_retroactive,
40
+ :title,
41
+ :primary_group,
42
+ :grant_trust_level,
43
+ :incoming_email,
44
+ :flair_url,
45
+ :flair_bg_color,
46
+ :flair_color,
47
+ :bio_raw,
48
+ :public_admission,
49
+ :public_exit,
50
+ :allow_membership_requests,
51
+ :full_name,
52
+ :default_notification_level,
53
+ :usernames,
54
+ :owner_usernames,
55
+ :membership_request_template)
56
+ .to_h
57
+ put("/admin/groups/#{group_id}", group: args)
10
58
  end
11
59
 
12
60
  def groups
@@ -9,8 +9,9 @@ module DiscourseApi
9
9
  post("/t/#{params[:topic_id]}/invite", params)
10
10
  end
11
11
 
12
+ # requires this plugin => https://github.com/discourse/discourse-invite-tokens
12
13
  def disposable_tokens(params={})
13
- post("/invites/disposable", params)
14
+ post("/invite-token/generate", params)
14
15
  end
15
16
  end
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.17.0"
2
+ VERSION = "0.18.0"
3
3
  end
@@ -22,8 +22,18 @@ describe DiscourseApi::API::Groups do
22
22
  it "create new groups" do
23
23
  stub_post("http://localhost:3000/admin/groups?api_key=test_d7fd0429940&api_username=test_user")
24
24
  subject.create_group(name: "test_group")
25
+ params = escape_params("group[name]" => "test_group", "group[visibility_level]" => 0)
25
26
  expect(a_post("http://localhost:3000/admin/groups?api_key=test_d7fd0429940&api_username=test_user").
26
- with(body: {name: "test_group", visible: "true"})
27
+ with(body: params)
28
+ ).to have_been_made
29
+ end
30
+
31
+ it "update an existing group" do
32
+ stub_put("http://localhost:3000/admin/groups/42?api_key=test_d7fd0429940&api_username=test_user")
33
+ subject.update_group(42, name: "test_group")
34
+ params = escape_params("group[name]" => "test_group", "group[visibility_level]" => 0)
35
+ expect(a_put("http://localhost:3000/admin/groups/42?api_key=test_d7fd0429940&api_username=test_user").
36
+ with(body: params)
27
37
  ).to have_been_made
28
38
  end
29
39
 
data/spec/spec_helper.rb CHANGED
@@ -59,3 +59,9 @@ end
59
59
  def fixture(file)
60
60
  File.new(fixture_path + '/' + file)
61
61
  end
62
+
63
+ def escape_params(params)
64
+ params.map do |key, value|
65
+ [CGI.escape(key), value].join('=')
66
+ end.join('&')
67
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-06-30 00:00:00.000000000 Z
14
+ date: 2017-10-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday