discourse_api 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/examples/create_private_message.rb +12 -0
- data/examples/create_user.rb +4 -1
- data/lib/discourse_api/api/private_messages.rb +12 -0
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/private_messages_spec.rb +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90d97e9771aa2f4cb2c06fed9c40b5dc731c19cf
|
4
|
+
data.tar.gz: accbb8997a8343471fd23d156b0746f52551025d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
+
)
|
data/examples/create_user.rb
CHANGED
@@ -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']
|
@@ -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.
|
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:
|
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
|