|
1 | 1 | # frozen_string_literal: true |
2 | | -$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) |
3 | | -require File.expand_path('../../lib/discourse_api', __FILE__) |
| 2 | +$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) |
| 3 | +require File.expand_path("../../lib/discourse_api", __FILE__) |
4 | 4 |
|
5 | 5 | config = DiscourseApi::ExampleHelper.load_yml |
6 | 6 |
|
7 | | -client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000') |
8 | | -client.api_key = config['api_key'] || "YOUR_API_KEY" |
9 | | -client.api_username = config['api_username'] || "YOUR_USERNAME" |
| 7 | +client = DiscourseApi::Client.new(config["host"] || "http://localhost:3000") |
| 8 | +client.api_key = config["api_key"] || "YOUR_API_KEY" |
| 9 | +client.api_username = config["api_username"] || "YOUR_USERNAME" |
10 | 10 |
|
11 | | -response = client.create_topic( |
| 11 | +response = |
| 12 | + client.create_topic( |
12 | 13 | category: 1, |
13 | 14 | skip_validations: true, |
14 | 15 | auto_track: false, |
15 | 16 | title: "Concert Master: A new way to choose", |
16 | | - raw: "This is the raw markdown for my post" |
17 | | -) |
| 17 | + raw: "This is the raw markdown for my post", |
| 18 | + ) |
18 | 19 |
|
19 | 20 | # get topic_id from response |
20 | | -topic_id = response['topic_id'] |
| 21 | +topic_id = response["topic_id"] |
21 | 22 |
|
22 | 23 | ## |
23 | 24 | # available options (guessing from reading discourse source) |
|
26 | 27 | ## |
27 | 28 |
|
28 | 29 | # lock topic (note: api_username determines user that is performing action) |
29 | | -params = { status: 'closed', enabled: true, api_username: "YOUR USERNAME/USERS USERNAME" } |
| 30 | +params = { status: "closed", enabled: true, api_username: "YOUR USERNAME/USERS USERNAME" } |
30 | 31 | client.change_topic_status(topic_id, params) |
31 | 32 |
|
32 | 33 | # unlock topic (note: api_username determines user that is performing action) |
33 | | -params = { status: 'closed', enabled: false, api_username: "YOUR USERNAME/USERS USERNAME" } |
| 34 | +params = { status: "closed", enabled: false, api_username: "YOUR USERNAME/USERS USERNAME" } |
34 | 35 | client.change_topic_status(topic_id, params) |
0 commit comments