class HelpScout::Conversation

Constants

BASIC_ATTRIBUTES

Attributes

hrefs[R]

Public Class Methods

create(params) click to toggle source
# 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
new(params) click to toggle source
# 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

Private Class Methods

create_path() click to toggle source
# File lib/help_scout/conversation.rb, line 16
def create_path
  base_path
end
list_path(mailbox_id) click to toggle source
# File lib/help_scout/conversation.rb, line 20
def list_path(mailbox_id)
  "#{base_path}?mailbox=#{mailbox_id}"
end

Public Instance Methods

populated_threads() click to toggle source
# File lib/help_scout/conversation.rb, line 63
def populated_threads
  @_populated_threads ||= HelpScout::Thread.list(id)
end
update(operation, path, value = nil) click to toggle source
# 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
update_tags(new_tags = nil) click to toggle source
# 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