Class: HelpScout::Mailbox

Inherits:
Base
  • Object
show all
Extended by:
Getable, Listable
Defined in:
lib/help_scout/mailbox.rb

Constant Summary collapse

BASIC_ATTRIBUTES =
%i[
  id
  name
  slug
  email
  created_at
  updated_at
].freeze

Instance Attribute 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

#initialize(params) ⇒ Mailbox

Returns a new instance of Mailbox.



19
20
21
22
23
24
25
26
27
# File 'lib/help_scout/mailbox.rb', line 19

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[:_links])
end

Instance Attribute Details

#hrefsObject (readonly)

Returns the value of attribute hrefs.



17
18
19
# File 'lib/help_scout/mailbox.rb', line 17

def hrefs
  @hrefs
end

Instance Method Details

#fieldsObject



29
30
31
# File 'lib/help_scout/mailbox.rb', line 29

def fields
  @_fields ||= HelpScout.api.get(fields_path).embedded[:fields]
end

#foldersObject



33
34
35
# File 'lib/help_scout/mailbox.rb', line 33

def folders
  @_folders ||= HelpScout::Folder.list(id: id)
end