discourse_api 0.7.0 → 0.8.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: 6c0790579478eedc23d1ee9c2845584fc2eeb35e
4
- data.tar.gz: 4fc797b4a90520a46f7ac3b64c51fb8129868149
3
+ metadata.gz: e774662e2101d7cc9efd59ecc530b1fd850d9aae
4
+ data.tar.gz: e957df497e9510660dfb359f0e2964279c069036
5
5
  SHA512:
6
- metadata.gz: 2ff4ce4800eca2118a78afc0953b65fe1786b6dd0ba1889909e8054ec21e7fdb4c1006b771d149571bc73e63df1ae88ac56849d49d5e31df654945150dff1a42
7
- data.tar.gz: 23a89130ee7d7976895713207a95dbec071b6108a7f3d22ef6f3d91c68388004888af27be422907b4667df40200a9af4c321f4d54e7ee20605c2053d790465ff
6
+ metadata.gz: 5cb7f3d6efe4850225c1ed35a2e0ff8508afa97f358e1d1b68a45f15ff37d42f70a72b23981779d3b2315f8495d2d9258848f5411cc8da14ccd3f2480d216ca2
7
+ data.tar.gz: 76422bb639def262ac7ab4c075f063a6bf972e950d9d098813cd7b702a113c00bde43ccd548ae343a77b7cacbaf451f0f978a05a0814b413f94718d864698e09
@@ -12,3 +12,12 @@ client.create_topic(
12
12
  title: "Concert Master: A new way to choose",
13
13
  raw: "This is the raw markdown for my post"
14
14
  )
15
+
16
+ # create Poll topic
17
+ client.create_topic(
18
+ category: "general",
19
+ skip_validations: false,
20
+ auto_track: false,
21
+ title: "Your Favorite Color?",
22
+ raw: "[poll name=color]\n- Green\n- Blue\n- Red\n[/poll]"
23
+ )
@@ -0,0 +1,13 @@
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
+ # get all dashboard status as json
9
+ puts client.get_dashboard_stats
10
+
11
+ # get hash of some dashboard total value
12
+ puts client.get_dashboard_stats_totals
13
+ # sample output: {"users"=>9, "topics"=>230, "posts"=>441}
@@ -0,0 +1,24 @@
1
+ module DiscourseApi
2
+ module API
3
+ module Dashboard
4
+ def get_dashboard_stats
5
+ response = get("admin/dashboard.json")
6
+ response[:body]
7
+ end
8
+
9
+ def get_dashboard_stats_totals
10
+ stats = get_dashboard_stats
11
+ global_reports = stats['global_reports']
12
+ users = global_reports[1]
13
+ topics = global_reports[3]
14
+ posts = global_reports[4]
15
+
16
+ totals = {
17
+ 'users' => users['total'],
18
+ 'topics' => topics['total'],
19
+ 'posts' => posts['total']
20
+ }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -17,6 +17,7 @@ require 'discourse_api/api/badges'
17
17
  require 'discourse_api/api/email'
18
18
  require 'discourse_api/api/api_key'
19
19
  require 'discourse_api/api/backups'
20
+ require 'discourse_api/api/dashboard'
20
21
 
21
22
  module DiscourseApi
22
23
  class Client
@@ -38,6 +39,7 @@ module DiscourseApi
38
39
  include DiscourseApi::API::Email
39
40
  include DiscourseApi::API::ApiKey
40
41
  include DiscourseApi::API::Backups
42
+ include DiscourseApi::API::Dashboard
41
43
 
42
44
  def initialize(host, api_key = nil, api_username = nil)
43
45
  raise ArgumentError, 'host needs to be defined' if host.nil? || host.empty?
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.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.7.0
4
+ version: 0.8.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: 2015-12-09 00:00:00.000000000 Z
14
+ date: 2016-02-28 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/category.rb
191
191
  - examples/create_topic.rb
192
192
  - examples/create_user.rb
193
+ - examples/dashboard.rb
193
194
  - examples/disposable_invite_tokens.rb
194
195
  - examples/example.rb
195
196
  - examples/groups.rb
@@ -203,6 +204,7 @@ files:
203
204
  - lib/discourse_api/api/backups.rb
204
205
  - lib/discourse_api/api/badges.rb
205
206
  - lib/discourse_api/api/categories.rb
207
+ - lib/discourse_api/api/dashboard.rb
206
208
  - lib/discourse_api/api/email.rb
207
209
  - lib/discourse_api/api/groups.rb
208
210
  - lib/discourse_api/api/invite.rb