Class: Doconomy::Api::Category
- Defined in:
- lib/doconomy/api/category.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#main_category ⇒ Object
Returns the value of attribute main_category.
-
#sub_category ⇒ Object
Returns the value of attribute sub_category.
Attributes inherited from Base
Class Method Summary collapse
-
.all ⇒ Array<Doconomy::Api::Category>
Get all categories.
-
.find(id) ⇒ Doconomy::Api::Category
Get a category with the given ID.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Category
constructor
A new instance of Category.
Methods inherited from Base
Constructor Details
#initialize(attributes = {}) ⇒ Category
Returns a new instance of Category.
8 9 10 11 12 13 |
# File 'lib/doconomy/api/category.rb', line 8 def initialize(attributes = {}) @attributes = attributes.deep_symbolize_keys @id = @attributes[:id] @main_category = OpenStruct.new(@attributes[:main_category]) if @attributes[:main_category] @sub_category = OpenStruct.new(@attributes[:sub_category]) if @attributes[:sub_category] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/doconomy/api/category.rb', line 6 def id @id end |
#main_category ⇒ Object
Returns the value of attribute main_category.
6 7 8 |
# File 'lib/doconomy/api/category.rb', line 6 def main_category @main_category end |
#sub_category ⇒ Object
Returns the value of attribute sub_category.
6 7 8 |
# File 'lib/doconomy/api/category.rb', line 6 def sub_category @sub_category end |
Class Method Details
.all ⇒ Array<Doconomy::Api::Category>
Get all categories
20 21 22 23 |
# File 'lib/doconomy/api/category.rb', line 20 def all response = client.get("/aland-index/#{Doconomy::Api.configuration.api_version}/categories") response[:categories].map { |attributes| new(attributes) } end |
.find(id) ⇒ Doconomy::Api::Category
Get a category with the given ID
29 30 31 |
# File 'lib/doconomy/api/category.rb', line 29 def find(id) new(client.get("/aland-index/#{Doconomy::Api.configuration.api_version}/categories/#{id}")) end |