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.34.0 examples/create_update_category.rb
discourse_api-0.33.0 examples/create_update_category.rb
discourse_api-0.32.0 examples/create_update_category.rb
discourse_api-0.31.0 examples/create_update_category.rb
discourse_api-0.30.0 examples/create_update_category.rb
discourse_api-0.29.0 examples/create_update_category.rb
discourse_api-0.28.1 examples/create_update_category.rb
discourse_api-0.28.0 examples/create_update_category.rb
discourse_api-0.27.0 examples/create_update_category.rb
discourse_api-0.26.0 examples/create_update_category.rb
discourse_api-0.25.0 examples/create_update_category.rb
discourse_api-0.24.0 examples/create_update_category.rb
discourse_api-0.23.1 examples/create_update_category.rb
discourse_api-0.23.0 examples/create_update_category.rb
discourse_api-0.22.0 examples/create_update_category.rb
discourse_api-0.20.1 examples/create_update_category.rb
discourse_api-0.20.0 examples/create_update_category.rb
discourse_api-0.19.0 examples/create_update_category.rb
discourse_api-0.18.0 examples/create_update_category.rb
discourse_api-0.17.0 examples/create_update_category.rb