Class: PatientZero::Profile
- Inherits:
-
Object
- Object
- PatientZero::Profile
- Includes:
- Client
- Defined in:
- lib/patient_zero/profile.rb
Constant Summary collapse
- CATEGORIES =
['General', 'Brand', 'Television', 'Movies', 'Music', 'Person', 'Sports', 'Politics', 'Topic']
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Profile
constructor
A new instance of Profile.
Methods included from Client
#connection, #get, included, #parse, #post, #put
Constructor Details
#initialize(attributes) ⇒ Profile
Returns a new instance of Profile.
9 10 11 12 13 14 |
# File 'lib/patient_zero/profile.rb', line 9 def initialize attributes @id = attributes.fetch 'id' @expression = attributes.fetch 'expression' @name = attributes.fetch 'name' @category = attributes.fetch 'category' end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
7 8 9 |
# File 'lib/patient_zero/profile.rb', line 7 def category @category end |
#expression ⇒ Object
Returns the value of attribute expression.
7 8 9 |
# File 'lib/patient_zero/profile.rb', line 7 def expression @expression end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/patient_zero/profile.rb', line 7 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/patient_zero/profile.rb', line 7 def name @name end |
Class Method Details
.all ⇒ Object
16 17 18 19 20 21 |
# File 'lib/patient_zero/profile.rb', line 16 def self.all response = get '/social/api/v2/monitoring/profiles', api_key: PatientZero.api_key response['profiles'].map do |profile_attributes| new profile_attributes end end |
.create(params = {}) ⇒ Object
28 29 30 31 |
# File 'lib/patient_zero/profile.rb', line 28 def self.create params={} response = post '/social/api/v2/monitoring/profiles', api_key: PatientZero.api_key, profile: params new response['profile'] end |
.find(id) ⇒ Object
23 24 25 26 |
# File 'lib/patient_zero/profile.rb', line 23 def self.find id response = get "/social/api/v2/monitoring/profiles/#{id}", api_key: PatientZero.api_key new response['profile'] end |
.update(params = {}) ⇒ Object
33 34 35 36 |
# File 'lib/patient_zero/profile.rb', line 33 def self.update params={} response = put "/social/api/v2/monitoring/profiles/#{params[:id]}", api_key: PatientZero.api_key, profile: params new response['profile'] end |