discourse_api 0.14.1 → 0.15.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: ba2465be5a6d174341ef11e71de4d2b498a0e3c8
4
- data.tar.gz: 62de6896356366f2a37dd3e71776809437c952b4
3
+ metadata.gz: 90d97e9771aa2f4cb2c06fed9c40b5dc731c19cf
4
+ data.tar.gz: accbb8997a8343471fd23d156b0746f52551025d
5
5
  SHA512:
6
- metadata.gz: 48a9e53c1558dc9ffab527577e7833da53a34f17b2a41037c0f492898fdade56824888d0aa0053fd4c85486524dbd61f6d5f9fd169131ffe8b7e1b85ed926677
7
- data.tar.gz: 7550c6806d1534180b63e51ad8a166f9ccea49017bcdaebedaeee821cf99cf23ab973906cfd4f9ccb8c6d9619b2a87fddcd0b8b70565e5ca070f8488754d5ae9
6
+ metadata.gz: 6f177e29569f3d153f624590a066a3b13b64fda9356242928d114b6ff6bb3d713a1a6677e036c6098be9ac5b35e9e3199a5c10d71b5716f0a98d64569ef31780
7
+ data.tar.gz: 7573dd18b98da929223a1cb6bfd0d7eda423222dd9a8817f433b744bcc738f53c8b279468b35451c9bb5a263e6e5f50348d1cf51459252349739e1897330fb7b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
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.15.0] - 2017-04-12
6
+ ### Added
7
+ - added the ability to create private messages
8
+
5
9
  ## [0.14.1] - 2016-12-20
6
10
  ### Fixed
7
11
  - allow for rack 2.0+ versions so that it doesn't clash with rails.
data/README.md CHANGED
@@ -44,7 +44,7 @@ client.search("sandbox") #=> Gets a list of topics that m
44
44
 
45
45
  # Categories endpoint
46
46
  client.categories #=> Gets a list of categories
47
- client.category_latest_posts("category-slug") #=> Gets a list of latest posts in a category
47
+ client.category_latest_topics(category_slug: "lounge") #=> Gets a list of latest topics in a category
48
48
 
49
49
  # SSO endpoint
50
50
  client.sync_sso( #=> Synchronizes the SSO record
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require File.expand_path('../../lib/discourse_api', __FILE__)
3
+
4
+ client = DiscourseApi::Client.new("http://localhost:3000")
5
+ client.api_key = "YOUR_API_KEY"
6
+ client.api_username = "YOUR_USERNAME"
7
+
8
+ client.create_private_message(
9
+ title: "Confidential: Hello World!",
10
+ raw: "This is the raw markdown for my private message",
11
+ target_usernames: ["user1", "user2"]
12
+ )
@@ -6,9 +6,12 @@ client.api_key = "YOUR_API_KEY"
6
6
  client.api_username = "YOUR_USERNAME"
7
7
 
8
8
  # create user
9
- client.create_user(
9
+ user = client.create_user(
10
10
  name: "Bruce Wayne",
11
11
  email: "bruce@wayne.com",
12
12
  username: "batman",
13
13
  password: "WhySoSerious"
14
14
  )
15
+
16
+ # activate user
17
+ client.activate(user["user_id"])
@@ -1,6 +1,18 @@
1
1
  module DiscourseApi
2
2
  module API
3
3
  module PrivateMessages
4
+
5
+ # :target_usernames REQUIRED comma separated list of usernames
6
+ # :category OPTIONAL name of category, not ID
7
+ # :created_at OPTIONAL seconds since epoch.
8
+ def create_private_message(args={})
9
+ args[:archetype] = 'private_message'
10
+ args = API.params(args)
11
+ .required(:title, :raw, :target_usernames, :archetype)
12
+ .optional(:category, :created_at, :api_username)
13
+ post("/posts", args.to_h)
14
+ end
15
+
4
16
  def private_messages(username, *args)
5
17
  response = get("topics/private-messages/#{username}.json", args)
6
18
  response[:body]['topic_list']['topics']
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.14.1"
2
+ VERSION = "0.15.0"
3
3
  end
@@ -19,4 +19,20 @@ describe DiscourseApi::API::PrivateMessages do
19
19
  end
20
20
  end
21
21
 
22
+ describe '#create_private_message' do
23
+ before do
24
+ stub_post("http://localhost:3000/posts?api_key=test_d7fd0429940&api_username=test_user")
25
+ subject.create_private_message(
26
+ title: "Confidential: Hello World!",
27
+ raw: "This is the raw markdown for my private message",
28
+ target_usernames: ["user1", "user2"]
29
+ )
30
+ end
31
+
32
+ it "makes a create private message request" do
33
+ expect(a_post("http://localhost:3000/posts?api_key=test_d7fd0429940&api_username=test_user").with(body:
34
+ 'archetype=private_message&raw=This+is+the+raw+markdown+for+my+private+message&target_usernames%5B%5D=user1&target_usernames%5B%5D=user2&title=Confidential%3A+Hello+World%21')
35
+ ).to have_been_made
36
+ end
37
+ end
22
38
  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.14.1
4
+ version: 0.15.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: 2016-12-20 00:00:00.000000000 Z
14
+ date: 2017-04-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -190,6 +190,7 @@ files:
190
190
  - examples/badges.rb
191
191
  - examples/category.rb
192
192
  - examples/change_topic_status.rb
193
+ - examples/create_private_message.rb
193
194
  - examples/create_topic.rb
194
195
  - examples/create_update_category.rb
195
196
  - examples/create_user.rb