Class: Freshdesk::Api::Client::Solution
- Inherits:
-
Object
- Object
- Freshdesk::Api::Client::Solution
- Defined in:
- lib/freshdesk/api/client/solution.rb
Constant Summary collapse
- CATEGORIES =
"solution/categories".freeze
- FOLDERS =
"solution/folders".freeze
- ARTICLES =
"solution/articles".freeze
Instance Method Summary collapse
-
#create_article(category_id, topic_id, payload) ⇒ Object
Create article by passing its id.
-
#create_category(payload) ⇒ Object
Create category by passing its id.
-
#create_folder(category_id, payload) ⇒ Object
Create folder by passing its id.
-
#delete_category(id) ⇒ Object
Delete category by its id.
-
#delete_folder(category_id, id) ⇒ Object
Delete folder by category id and folder id.
-
#get_article(id) ⇒ Object
Get article by its id.
-
#get_category(id) ⇒ Object
Get category by its id.
-
#get_folder(id) ⇒ Object
Get folder by its id.
-
#initialize(base_url, api_key) ⇒ Solution
constructor
Initialize with your freshdesk account url and api key.
-
#list_articles(category_id, folder_id) ⇒ Object
List all articles by passing the category id and folder id together.
-
#list_categories ⇒ Object
List all categories.
-
#list_folders(category_id) ⇒ Object
List all folders by it category id.
Constructor Details
#initialize(base_url, api_key) ⇒ Solution
Initialize with your freshdesk account url and api key.
12 13 14 |
# File 'lib/freshdesk/api/client/solution.rb', line 12 def initialize base_url, api_key @connection = Freshdesk::Api::Client::Request.new base_url, api_key end |
Instance Method Details
#create_article(category_id, topic_id, payload) ⇒ Object
Create article by passing its id. Please refer freshdesk.com/api#solution-category
28 29 30 |
# File 'lib/freshdesk/api/client/solution.rb', line 28 def create_article category_id, topic_id, payload Freshdesk::Api::Client.convert_to_hash( @connection.post ARTICLES, payload, category_id, topic_id, "create_article" ) end |
#create_category(payload) ⇒ Object
Create category by passing its id. Please refer freshdesk.com/api#solution-category
17 18 19 |
# File 'lib/freshdesk/api/client/solution.rb', line 17 def create_category payload Freshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload ) end |
#create_folder(category_id, payload) ⇒ Object
Create folder by passing its id. Please refer freshdesk.com/api#solution-category
23 24 25 |
# File 'lib/freshdesk/api/client/solution.rb', line 23 def create_folder category_id, payload Freshdesk::Api::Client.convert_to_hash( @connection.post FOLDERS, payload, category_id, nil, "create_folder" ) end |
#delete_category(id) ⇒ Object
Delete category by its id.
63 64 65 66 67 |
# File 'lib/freshdesk/api/client/solution.rb', line 63 def delete_category id Freshdesk::Api::Client.delete_status_wrapper do ( @connection.delete CATEGORIES, id, "delete_category" ).code end end |
#delete_folder(category_id, id) ⇒ Object
Delete folder by category id and folder id.
70 71 72 73 74 |
# File 'lib/freshdesk/api/client/solution.rb', line 70 def delete_folder category_id, id Freshdesk::Api::Client.delete_status_wrapper do ( @connection.delete FOLDERS, category_id, id, "delete_folder" ).code end end |
#get_article(id) ⇒ Object
Get article by its id.
43 44 45 |
# File 'lib/freshdesk/api/client/solution.rb', line 43 def get_article id Freshdesk::Api::Client.convert_to_hash( @connection.get ARTICLES, id ) end |
#get_category(id) ⇒ Object
Get category by its id.
33 34 35 |
# File 'lib/freshdesk/api/client/solution.rb', line 33 def get_category id Freshdesk::Api::Client.convert_to_hash( @connection.get CATEGORIES, id ) end |
#get_folder(id) ⇒ Object
Get folder by its id.
38 39 40 |
# File 'lib/freshdesk/api/client/solution.rb', line 38 def get_folder id Freshdesk::Api::Client.convert_to_hash( @connection.get FOLDERS, id ) end |
#list_articles(category_id, folder_id) ⇒ Object
List all articles by passing the category id and folder id together.
48 49 50 |
# File 'lib/freshdesk/api/client/solution.rb', line 48 def list_articles category_id, folder_id Freshdesk::Api::Client.convert_to_hash( @connection.get ARTICLES, category_id, nil, folder_id, "list_articles" ) end |
#list_categories ⇒ Object
List all categories.
58 59 60 |
# File 'lib/freshdesk/api/client/solution.rb', line 58 def list_categories Freshdesk::Api::Client.convert_to_hash( @connection.get CATEGORIES ) end |
#list_folders(category_id) ⇒ Object
List all folders by it category id.
53 54 55 |
# File 'lib/freshdesk/api/client/solution.rb', line 53 def list_folders category_id Freshdesk::Api::Client.convert_to_hash( @connection.get FOLDERS, category_id, nil, nil, "list_folders" ) end |