Class: DiscourseApi::Client
- Inherits:
-
Object
- Object
- DiscourseApi::Client
- Includes:
- API::Categories, API::Invite, API::Notifications, API::PrivateMessages, API::SSO, API::Search, API::Topics, API::Users
- Defined in:
- lib/discourse_api/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_username ⇒ Object
Returns the value of attribute api_username.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #connection_options ⇒ Object
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(host, api_key = nil, api_username = nil) ⇒ Client
constructor
A new instance of Client.
- #post(path, params = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
- #user_agent ⇒ Object
Methods included from API::Notifications
Methods included from API::PrivateMessages
Methods included from API::Invite
#disposable_tokens, #invite_user, #invite_user_to_topic
Methods included from API::Users
#activate, #create_user, #update_avatar, #update_email, #update_user, #update_username, #user
Methods included from API::Topics
#create_topic, #delete_topic, #latest_topics, #new_topics, #recategorize_topic, #rename_topic, #topic, #topics_by
Methods included from API::SSO
Methods included from API::Search
Methods included from API::Categories
#categories, #category_latest_topics
Constructor Details
#initialize(host, api_key = nil, api_username = nil) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 |
# File 'lib/discourse_api/client.rb', line 28 def initialize(host, api_key=nil, api_username=nil) @host = host @api_key = api_key @api_username = api_username end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
16 17 18 |
# File 'lib/discourse_api/client.rb', line 16 def api_key @api_key end |
#api_username ⇒ Object
Returns the value of attribute api_username.
16 17 18 |
# File 'lib/discourse_api/client.rb', line 16 def api_username @api_username end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
17 18 19 |
# File 'lib/discourse_api/client.rb', line 17 def host @host end |
Instance Method Details
#connection_options ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/discourse_api/client.rb', line 34 def @connection_options ||= { url: @host, headers: { accept: 'application/json', user_agent: user_agent, } } end |
#delete(path, params = {}) ⇒ Object
44 45 46 |
# File 'lib/discourse_api/client.rb', line 44 def delete(path, params={}) request(:delete, path, params) end |
#get(path, params = {}) ⇒ Object
48 49 50 |
# File 'lib/discourse_api/client.rb', line 48 def get(path, params={}) request(:get, path, params) end |
#post(path, params = {}) ⇒ Object
52 53 54 |
# File 'lib/discourse_api/client.rb', line 52 def post(path, params={}) request(:post, path, params) end |
#put(path, params = {}) ⇒ Object
56 57 58 |
# File 'lib/discourse_api/client.rb', line 56 def put(path, params={}) request(:put, path, params) end |
#user_agent ⇒ Object
60 61 62 |
# File 'lib/discourse_api/client.rb', line 60 def user_agent @user_agent ||= "DiscourseAPI Ruby Gem #{DiscourseApi::VERSION}" end |