discourse_api 0.8.1 → 0.9.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: 1b16d39076c47bcf8981135aaa0200f7d53d97eb
4
- data.tar.gz: 8827f146d4565777ea9257332002b80a9bb1ecf8
3
+ metadata.gz: bfa614598891c7820dd1be6a73982e16950caac4
4
+ data.tar.gz: cf2d491b91223382f4272bdf1a003be8c84fe661
5
5
  SHA512:
6
- metadata.gz: b7c10094e68e98260f544c74d913ff3f0f356d19b40cfdb32317bcc4a1dd9cc07563765d9f915cf071f32c5e79d2b672260bf485d8a39fa2a24bd41f5e2b81f0
7
- data.tar.gz: 47e94f1eb157f6caccc9e8ea749a984e810e50305d775887b16f304cad1c1990c1ef4c884e54c9ca61892f867f03e8c56b5c23f8d35c9325c2ccd3b69ce6e784
6
+ metadata.gz: e09cb8531f1e2ff99d138176a0684be30f4ff3a5c1f68b81e5a9b5a9396769adcacf9596b98f2a5e68ac6a8acf04d0bda8be33d9c1ea83a87c03e2a8cbaf5c7e
7
+ data.tar.gz: 735e055ee3754052a1247772bd077f59f74a62b74944e750a9006424a3d9283c734530eed226ac7c612a7bd82d750058e6f00d43ad8194d3658ca75263a831f9
@@ -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.9.0] - 2016-03-22
6
+ ### Added
7
+ - can now like/flag topics and posts
8
+
5
9
  ## [0.8.1] - 2016-03-03
6
10
  ### Fixed
7
11
  - enable use of discourse_api to make unauthenticated requests to discourse
@@ -0,0 +1,25 @@
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
+ # Post Action Type IDs
9
+ # 1 - Bookmark
10
+ # 2 - Like
11
+ # 3 - Flag: Off-topic
12
+ # 4 - Flag: Inappropriate
13
+ # 5 - Vote
14
+ # 6 - Notify User
15
+ # 7 - Flag - Notify Moderators
16
+ # 8 - Flag - Spam
17
+
18
+ # Like a post
19
+ client.create_post_action(post_id: 1, post_action_type_id: 2)
20
+
21
+ # Flag a topic as spam
22
+ client.create_topic_action(topic_id: 1, post_action_type_id: 8)
23
+
24
+ # Unlike a post
25
+ client.destroy_post_action(post_id: 1, post_action_type_id: 2)
@@ -7,6 +7,12 @@ module DiscourseApi
7
7
  post("/posts", args)
8
8
  end
9
9
 
10
+ def create_post_action(args)
11
+ args = API.params(args)
12
+ .required(:post_id, :post_action_type_id)
13
+ post("/post_actions", args.to_h.merge(flag_topic: false))
14
+ end
15
+
10
16
  def get_post(id, args = {})
11
17
  args = API.params(args)
12
18
  .optional(:version)
@@ -21,6 +27,16 @@ module DiscourseApi
21
27
  def edit_post(id, raw)
22
28
  put("/posts/#{id}", post: {raw: raw})
23
29
  end
30
+
31
+ def destroy_post_action(post_id:, post_action_type_id:)
32
+ delete("/post_actions/#{post_id}.json", post_action_type_id: post_action_type_id)
33
+ end
34
+
35
+ # This will need to be updated when Discourse 1.5 is released
36
+ def post_action_users(post_id:, post_action_type_id:)
37
+ response = get("/post_actions/users.json", {id: post_id, post_action_type_id: post_action_type_id})
38
+ response[:body]
39
+ end
24
40
  end
25
41
  end
26
42
  end
@@ -11,6 +11,12 @@ module DiscourseApi
11
11
  post("/posts", args.to_h)
12
12
  end
13
13
 
14
+ def create_topic_action(args)
15
+ args = API.params(args)
16
+ .required(:topic_id, :post_action_type_id)
17
+ post("/post_actions", args.to_h.merge(flag_topic: true))
18
+ end
19
+
14
20
  def latest_topics(params={})
15
21
  response = get('/latest.json', params)
16
22
  response[:body]['topic_list']['topics']
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  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.8.1
4
+ version: 0.9.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-03-04 00:00:00.000000000 Z
14
+ date: 2016-03-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -195,6 +195,7 @@ files:
195
195
  - examples/example.rb
196
196
  - examples/groups.rb
197
197
  - examples/invite_users.rb
198
+ - examples/post_action.rb
198
199
  - examples/search.rb
199
200
  - examples/sso.rb
200
201
  - examples/topic_lists.rb