Class: HelpScout::Conversation
Constant Summary
collapse
- BASIC_ATTRIBUTES =
i[
id
number
type
folder_id
status
state
subject
preview
mailbox_id
assignee
created_by
created_at
closed_by
closed_at
user_updated_at
customer_waiting_since
source
tags
cc
bcc
primary_customer
custom_fields
].freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Getable
get
Methods included from Listable
list, list_path
Methods inherited from Base
#as_json, #to_h, #to_json
Constructor Details
Returns a new instance of Conversation.
53
54
55
56
57
58
59
60
61
|
# File 'lib/help_scout/conversation.rb', line 53
def initialize(params)
BASIC_ATTRIBUTES.each do |attribute|
next unless params[attribute]
instance_variable_set("@#{attribute}", params[attribute])
end
@hrefs = HelpScout::Util.map_links(params.fetch(:_links, []))
end
|
Instance Attribute Details
#hrefs ⇒ Object
Returns the value of attribute hrefs.
51
52
53
|
# File 'lib/help_scout/conversation.rb', line 51
def hrefs
@hrefs
end
|
Class Method Details
.create(params) ⇒ Object
9
10
11
12
|
# File 'lib/help_scout/conversation.rb', line 9
def create(params)
response = HelpScout.api.post(create_path, HelpScout::Util.camelize_keys(params))
response.location
end
|
Instance Method Details
#populated_threads ⇒ Object
63
64
65
|
# File 'lib/help_scout/conversation.rb', line 63
def populated_threads
@_populated_threads ||= HelpScout::Thread.list(id)
end
|
#update(operation, path, value = nil) ⇒ Object
67
68
69
70
71
|
# File 'lib/help_scout/conversation.rb', line 67
def update(operation, path, value = nil)
update_path = URI.parse(hrefs[:self]).path
HelpScout.api.patch(update_path, op: operation, path: path, value: value)
true
end
|
73
74
75
76
77
78
|
# File 'lib/help_scout/conversation.rb', line 73
def update_tags(new_tags = nil)
new_tags ||= []
tags_path = URI.parse(hrefs[:self]).path + '/tags'
HelpScout.api.put(tags_path, tags: new_tags)
true
end
|