Class: Hubspot::Task
- Inherits:
-
Object
- Object
- Hubspot::Task
- Defined in:
- lib/hubspot/task.rb
Overview
Constant Summary collapse
- TASKS_PATH =
'/crm/v3/objects/tasks'- TASK_PATH =
'/crm/v3/objects/tasks/:task_id'- DEFAULT_TASK_FIELDS =
'hs_timestamp,hs_task_body,hubspot_owner_id,hs_task_subject,hs_task_status,hs_task_priority,'\ 'hs_task_type,hs_task_reminders'
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Class Method Summary collapse
- .create!(params = {}, associations: []) ⇒ Object
- .find(task_id, properties = DEFAULT_TASK_FIELDS) ⇒ Object
Instance Method Summary collapse
-
#initialize(response_hash) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(response_hash) ⇒ Task
Returns a new instance of Task.
17 18 19 20 |
# File 'lib/hubspot/task.rb', line 17 def initialize(response_hash) @id = response_hash['id'] @properties = response_hash['properties'].deep_symbolize_keys end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/hubspot/task.rb', line 15 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
15 16 17 |
# File 'lib/hubspot/task.rb', line 15 def properties @properties end |
Class Method Details
.create!(params = {}, associations: []) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/hubspot/task.rb', line 23 def create!(params = {}, associations: []) associations_hash = { associations: } properties = { hs_task_status: 'NOT_STARTED', hs_task_type: 'TODO' }.merge(params) post_data = associations_hash.merge(properties:) response = Hubspot::Connection.post_json(TASKS_PATH, params: {}, body: post_data) new(response) end |
.find(task_id, properties = DEFAULT_TASK_FIELDS) ⇒ Object
32 33 34 35 |
# File 'lib/hubspot/task.rb', line 32 def find(task_id, properties = DEFAULT_TASK_FIELDS) response = Hubspot::Connection.get_json(TASK_PATH, task_id: task_id, properties:) new(response) end |