Class: Hubspot::Task
- Inherits:
-
Object
- Object
- Hubspot::Task
- Defined in:
- lib/hubspot/task.rb
Overview
Constant Summary collapse
- TASKS_PATH =
'/crm/v3/objects/tasks'
- SEARCH_PATH =
'/crm/v3/objects/tasks/search'
- TASK_PATH =
'/crm/v3/objects/tasks/:task_id'
- DEFAULT_TASK_FIELDS =
%w[hs_timestamp hs_task_body hubspot_owner_id hs_task_subject hs_task_status hs_task_priority hs_task_type hs_task_reminders].freeze
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
- .search(properties = DEFAULT_TASK_FIELDS, body: {}) ⇒ Object
- .update!(task_id, properties = {}) ⇒ 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.
18 19 20 21 |
# File 'lib/hubspot/task.rb', line 18 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.
16 17 18 |
# File 'lib/hubspot/task.rb', line 16 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
16 17 18 |
# File 'lib/hubspot/task.rb', line 16 def properties @properties end |
Class Method Details
.create!(params = {}, associations: []) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/hubspot/task.rb', line 24 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
33 34 35 36 |
# File 'lib/hubspot/task.rb', line 33 def find(task_id, properties = DEFAULT_TASK_FIELDS) response = Hubspot::Connection.get_json(TASK_PATH, task_id: task_id, properties:) new(response) end |
.search(properties = DEFAULT_TASK_FIELDS, body: {}) ⇒ Object
38 39 40 |
# File 'lib/hubspot/task.rb', line 38 def search(properties = DEFAULT_TASK_FIELDS, body: {}) Hubspot::Connection.post_json(SEARCH_PATH, params: {}, body: { properties: }.merge(body)) end |
.update!(task_id, properties = {}) ⇒ Object
42 43 44 45 |
# File 'lib/hubspot/task.rb', line 42 def update!(task_id, properties = {}) response = Hubspot::Connection.patch_json(TASK_PATH, params: { task_id: }, body: { properties: }) new(response) end |