Class: Hudu::Client
Overview
Wrapper for the Hudu REST API
Constant Summary
Constants included from Configuration
Hudu::Configuration::DEFAULT_PAGE_SIZE, Hudu::Configuration::DEFAULT_PAGINATION, Hudu::Configuration::DEFAULT_UA, Hudu::Configuration::VALID_OPTIONS_KEYS
Instance Method Summary collapse
-
#api_url(path) ⇒ Object
return api path.
- #company_articles(company_id, params = {}) ⇒ Object
- #company_asset(id, asset_id, params = {}) ⇒ Object
- #company_assets(id, params = {}) ⇒ Object
-
#hudu_data(result, resource) ⇒ Object
hudu returns data as resource:{} or resource:[].
- #update_company_asset(asset) ⇒ Object
Methods inherited from API
Methods included from Authentication
Methods included from Configuration
Constructor Details
This class inherits a constructor from Hudu::API
Instance Method Details
#api_url(path) ⇒ Object
return api path
74 75 76 |
# File 'lib/hudu/client.rb', line 74 def api_url path "/api/v1/#{path}" end |
#company_articles(company_id, params = {}) ⇒ Object
59 60 61 |
# File 'lib/hudu/client.rb', line 59 def company_articles( company_id, params = {} ) articles({company_id: company_id}.merge(params)) end |
#company_asset(id, asset_id, params = {}) ⇒ Object
65 66 67 |
# File 'lib/hudu/client.rb', line 65 def company_asset(id,asset_id,params={}) get(api_url("companies/#{id}/assets/#{asset_id}"), params) end |
#company_assets(id, params = {}) ⇒ Object
62 63 64 |
# File 'lib/hudu/client.rb', line 62 def company_assets(id,params={}) get_paged(api_url("companies/#{id}/assets"), params) end |
#hudu_data(result, resource) ⇒ Object
hudu returns data as resource:{} or resource:[]
79 80 81 82 83 84 85 |
# File 'lib/hudu/client.rb', line 79 def hudu_data(result,resource) if result.is_a?(Hash) && result[resource.to_s] result[resource.to_s] else result end end |
#update_company_asset(asset) ⇒ Object
69 70 71 |
# File 'lib/hudu/client.rb', line 69 def update_company_asset(asset) put(api_url("companies/#{asset.company_id}/assets/#{asset.id}"), AssetHelper.construct_asset(asset)) end |