Sha256: db70777f810169351fa63702e6c12a5309ea050bd33e699f30b8d433901535e8

Contents?: true

Size: 1.12 KB

Versions: 26

Compression:

Stored size: 1.12 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require File.expand_path('../../lib/discourse_api', __FILE__)

# client = DiscourseApi::Client.new("http://localhost:3000")
# client.api_key = "YOUR_API_KEY"
# client.api_username = "YOUR_USERNAME"
#

client = DiscourseApi::Client.new("http://localhost:8080")
client.api_key = "a56a349e1870529d8d8da11453ea782ce8ab8de34d6564a65727171163be4338"
client.api_username = "system"

###
# Required category params:
#   :name, :color, :text_color
# Optional category params:
#   :slug, :permissions, :auto_close_hours, :auto_close_based_on_last_post, :position, :email_in,
#   :email_in_allow_strangers, :logo_url, :background_url, :allow_badges, :topic_template
###


# Create category
new_category = client.create_category(
    name: "Test Category",
    color: "AB9364",
    text_color: "FFFFFF"
)
puts 'Created category: ' + new_category.to_s

# Update category
response = client.update_category(
    id: new_category['id'],
    name: "The Best Test Category",
    slug: "the-best-test-category",
    color: "0E76BD",
    text_color: "000000"
)
puts 'Updated category: ' + response.to_s

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
discourse_api-0.16.1 examples/create_update_category.rb
discourse_api-0.16.0 examples/create_update_category.rb
discourse_api-0.15.0 examples/create_update_category.rb
discourse_api-0.14.1 examples/create_update_category.rb
discourse_api-0.14.0 examples/create_update_category.rb
discourse_api-0.13.0 examples/create_update_category.rb