Class: PQSDK::Brand
- Inherits:
-
Object
- Object
- PQSDK::Brand
- Defined in:
- lib/pqsdk/brand.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
Class Method Summary collapse
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/pqsdk/brand.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/pqsdk/brand.rb', line 3 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug.
3 4 5 |
# File 'lib/pqsdk/brand.rb', line 3 def slug @slug end |
Class Method Details
.find(name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pqsdk/brand.rb', line 16 def self.find(name) res = RestLayer.get('v1/brands/search', { q: name }, { 'Authorization' => "Bearer #{Token.access_token}" }) if res[0] == 200 Brand.from_json res[1] elsif res[0] == 404 nil else raise Exception.new("Unexpected HTTP status code #{res[0]}, #{res[1]}") end end |
.list ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pqsdk/brand.rb', line 5 def self.list res = RestLayer.get('v1/brands', {}, { 'Authorization' => "Bearer #{Token.access_token}" }) if res[0] == 200 res[1].map{|brand| Brand.from_json(brand)} elsif res[0] == 404 nil else raise Exception.new("Unexpected HTTP status code #{res[0]}, #{res[1]}") end end |