discourse_api 0.42.0 → 0.43.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ea694de473b398c706c2b61333e05663dcb69423178a6bcb25c2f6b1ac4abde
4
- data.tar.gz: 85fb225fd5d9ab4aa407510a437b7b92a55f4c117b480cecbfb026c0f0b3750f
3
+ metadata.gz: 47b23caec63bf36a246bfa9ce104e32ac5e1d0978e2e469154b976fed097aa91
4
+ data.tar.gz: afe90f37b0464d43df29b38884c77f747975f805a5f7d17797fbd82c62fa0d9f
5
5
  SHA512:
6
- metadata.gz: fbdd42c087c47c52ea91ba75d70fba75989ee6242a914f1147755d851d2645403c5f153cefbd60f04073cf34bc94e1e2fb01247204bce128538fe5b485b0b332
7
- data.tar.gz: 43cf32bef0aba4d313c2d198e04be5531cc9e52bb5473ff6e6dbbfe6406090fa121c18b681e45847f4624031e0c7e004bb62443cb79a03e3fe972703b9d73410
6
+ metadata.gz: 04a47e1164ab7b298292a840b5263967e333baff682839fe87ed791412364e4e87b6465d36737761ce98271258544519206484a8e06d9396fd2d9514fd6547c3
7
+ data.tar.gz: 895e1c5a9e021eb6b6a8fd12e0aa05e45b9865e11bdf10639d1b05941ce4512d311c71cf427b0e9395c94085a63831531e7903c2cbdb5c5fb79aabbacf438906
@@ -1,6 +1,16 @@
1
- # Change Log
1
+ # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.43.0] - 2020-11-04
10
+ ### Added
11
+ - Add pagination to list groups endpoint
12
+ ### Deprecated
13
+ - `change_topic_status` has been deprecated, use `update_topic_status` instead.
4
14
 
5
15
  ## [0.42.0] - 2020-07-09
6
16
  ### Added
data/README.md CHANGED
@@ -34,7 +34,6 @@ client.ssl(...) #=> specify SSL connection setti
34
34
 
35
35
  # Topic endpoints
36
36
  client.latest_topics #=> Gets a list of the latest topics
37
- client.hot_topics #=> Gets a list of hot topics
38
37
  client.new_topics #=> Gets a list of new topics
39
38
  client.topics_by("sam") #=> Gets a list of topics created by user "sam"
40
39
  client.topic(57) #=> Gets the topic with id 57
@@ -16,9 +16,8 @@ response = client.create_topic(
16
16
  raw: "This is the raw markdown for my post"
17
17
  )
18
18
 
19
- # get topic_id and topic_slug from response
19
+ # get topic_id from response
20
20
  topic_id = response['topic_id']
21
- topic_slug = response['topic_slug']
22
21
 
23
22
  ##
24
23
  # available options (guessing from reading discourse source)
@@ -28,8 +27,8 @@ topic_slug = response['topic_slug']
28
27
 
29
28
  # lock topic (note: api_username determines user that is performing action)
30
29
  params = { status: 'closed', enabled: true, api_username: "YOUR USERNAME/USERS USERNAME" }
31
- client.change_topic_status(topic_slug, topic_id, params)
30
+ client.change_topic_status(topic_id, params)
32
31
 
33
32
  # unlock topic (note: api_username determines user that is performing action)
34
33
  params = { status: 'closed', enabled: false, api_username: "YOUR USERNAME/USERS USERNAME" }
35
- client.change_topic_status(topic_slug, topic_id, params)
34
+ client.change_topic_status(topic_id, params)
@@ -60,8 +60,16 @@ module DiscourseApi
60
60
  put("/groups/#{group_id}", group: args)
61
61
  end
62
62
 
63
- def groups
64
- response = get("/groups.json")
63
+ def groups(args = {})
64
+ params = API.params(args)
65
+ .optional(:page)
66
+ .to_h
67
+
68
+ url = "/groups.json"
69
+ if params.include?(:page)
70
+ url += "?page=#{params[:page]}"
71
+ end
72
+ response = get(url)
65
73
  response.body
66
74
  end
67
75
 
@@ -42,11 +42,17 @@ module DiscourseApi
42
42
  put("/t/#{topic_id}.json", topic_id: topic_id, category_id: category_id)
43
43
  end
44
44
 
45
+ # TODO: Deprecated. Remove after 20201231
45
46
  def change_topic_status(topic_slug, topic_id, params = {})
47
+ deprecated(__method__, 'update_topic_status')
48
+ update_topic_status(topic_id, params)
49
+ end
50
+
51
+ def update_topic_status(topic_id, params = {})
46
52
  params = API.params(params)
47
53
  .required(:status, :enabled)
48
54
  .optional(:api_username)
49
- put("/t/#{topic_id}/status", params.to_h)
55
+ put("/t/#{topic_id}/status", params)
50
56
  end
51
57
 
52
58
  def topic(id, params = {})
@@ -109,6 +109,10 @@ module DiscourseApi
109
109
  @user_agent ||= "DiscourseAPI Ruby Gem #{DiscourseApi::VERSION}"
110
110
  end
111
111
 
112
+ def deprecated(old, new)
113
+ warn "[DEPRECATED]: `#{old}` is deprecated. Please use `#{new}` instead."
114
+ end
115
+
112
116
  private
113
117
 
114
118
  def connection
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module DiscourseApi
3
- VERSION = "0.42.0"
3
+ VERSION = "0.43.0"
4
4
  end
@@ -10,7 +10,7 @@ describe DiscourseApi::API::Topics do
10
10
  end
11
11
 
12
12
  it "changes the topic status" do
13
- subject.change_topic_status(nil, 57, { status: 'visible', enabled: false })
13
+ subject.update_topic_status(57, { status: 'visible', enabled: false })
14
14
  expect(a_put("#{host}/t/57/status")).to have_been_made
15
15
  end
16
16
  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.42.0
4
+ version: 0.43.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: 2020-07-09 00:00:00.000000000 Z
14
+ date: 2020-11-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday