Here’s what I have:
examples/example_helper.rb
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require File.expand_path('../../lib/discourse_api', __FILE__)
require 'yaml'
CONFIG = YAML.load_file(File.expand_path('../../config.yml', __FILE__))
def client
discourse_client = DiscourseApi::Client.new(CONFIG['host'])
discourse_client.api_key = CONFIG['api_key']
discourse_client.api_username = CONFIG['api_username']
discourse_client
end
examples/config-example.yml
# host e.g. localhost:3000 or discourse.my_domain.com
host: YOUR_HOST_NAME
# api user (can effect results returned, e.g. .categories method returns only the categories your api_username can see)
# create a new client with when changing api user
api_username: YOUR_API_KEY
# api key from Discourse admin panel /admin/api/keys
api_key: YOUR_API_KEY
examples/badges.rb
require_relative 'example_helper'
# get badges
puts client.badges
Thoughts? Sure we need the yml now, given the examples_helper.rb?