Class: ZendeskAppsSupport::Location

Inherits:
Object
  • Object
show all
Extended by:
Finders
Defined in:
lib/zendesk_apps_support/location.rb

Constant Summary collapse

LOCATIONS_AVAILABLE =

the ids below match the enum values on the database, do not change them!

[
  Location.new(id: 1, orderable: true, name: 'top_bar', product_code: Product::SUPPORT.code),
  Location.new(id: 2, orderable: true, name: 'nav_bar', product_code: Product::SUPPORT.code),
  Location.new(id: 3, orderable: true, collapsible: true, name: 'ticket_sidebar',
               product_code: Product::SUPPORT.code),
  Location.new(id: 4, orderable: true, collapsible: true, name: 'new_ticket_sidebar',
               product_code: Product::SUPPORT.code),
  Location.new(id: 5, orderable: true, collapsible: true, name: 'user_sidebar',
               product_code: Product::SUPPORT.code),
  Location.new(id: 6, orderable: true, collapsible: true, name: 'organization_sidebar',
               product_code: Product::SUPPORT.code),
  Location.new(id: 7, name: 'background', product_code: Product::SUPPORT.code),
  Location.new(id: 8, orderable: true, collapsible: true, name: 'chat_sidebar', product_code: Product::CHAT.code),
  Location.new(id: 9, name: 'modal', product_code: Product::SUPPORT.code, v2_only: true),
  Location.new(id: 10, name: 'ticket_editor', product_code: Product::SUPPORT.code, v2_only: true),
  Location.new(id: 11, name: 'nav_bar', product_code: Product::STANDALONE_CHAT.code, v2_only: false),
  Location.new(id: 12, name: 'system_top_bar', product_code: Product::SUPPORT.code),
  Location.new(id: 13, name: 'system_top_bar',
               product_code: Product::STANDALONE_CHAT.code, v2_only: false),
  Location.new(id: 14, name: 'background',
               product_code: Product::CHAT.code)
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finders

find_by, find_by!, where

Constructor Details

#initialize(attrs) ⇒ Location

Returns a new instance of Location.



11
12
13
14
15
16
17
18
19
20
# File 'lib/zendesk_apps_support/location.rb', line 11

def initialize(attrs)
  @id = attrs.fetch(:id)
  raise 'Duplicate id' if Location.unique_ids.include? @id
  Location.unique_ids.add @id
  @name = attrs.fetch(:name)
  @orderable = attrs.fetch(:orderable, false)
  @collapsible = attrs.fetch(:collapsible, false)
  @product_code = attrs.fetch(:product_code)
  @v2_only = attrs.fetch(:v2_only, product != Product::SUPPORT)
end

Instance Attribute Details

#collapsibleObject (readonly)

Returns the value of attribute collapsible.



5
6
7
# File 'lib/zendesk_apps_support/location.rb', line 5

def collapsible
  @collapsible
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/zendesk_apps_support/location.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/zendesk_apps_support/location.rb', line 5

def name
  @name
end

#orderableObject (readonly)

Returns the value of attribute orderable.



5
6
7
# File 'lib/zendesk_apps_support/location.rb', line 5

def orderable
  @orderable
end

#product_codeObject (readonly)

Returns the value of attribute product_code.



5
6
7
# File 'lib/zendesk_apps_support/location.rb', line 5

def product_code
  @product_code
end

#v2_onlyObject (readonly)

Returns the value of attribute v2_only.



5
6
7
# File 'lib/zendesk_apps_support/location.rb', line 5

def v2_only
  @v2_only
end

Class Method Details

.allObject



26
27
28
# File 'lib/zendesk_apps_support/location.rb', line 26

def self.all
  LOCATIONS_AVAILABLE
end

.unique_idsObject



7
8
9
# File 'lib/zendesk_apps_support/location.rb', line 7

def self.unique_ids
  @ids ||= Set.new
end

Instance Method Details

#productObject



22
23
24
# File 'lib/zendesk_apps_support/location.rb', line 22

def product
  Product.find_by(code: product_code)
end