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, name: 'ticket_sidebar', product_code: Product::SUPPORT.code),
  Location.new(id: 4, orderable: true, name: 'new_ticket_sidebar', product_code: Product::SUPPORT.code),
  Location.new(id: 5, orderable: true, name: 'user_sidebar', product_code: Product::SUPPORT.code),
  Location.new(id: 6, orderable: true, name: 'organization_sidebar', product_code: Product::SUPPORT.code),
  Location.new(id: 7, orderable: false, name: 'background', product_code: Product::SUPPORT.code),
  Location.new(id: 8, orderable: true, name: 'chat_sidebar', product_code: Product::CHAT.code),
  Location.new(id: 9, orderable: false, name: 'modal', product_code: Product::SUPPORT.code,
               v2_only: true),
  Location.new(id: 10, orderable: false, name: 'ticket_editor', product_code: Product::SUPPORT.code,
               v2_only: true),
  Location.new(id: 11, orderable: false, name: 'nav_bar', product_code: Product::STANDALONE_CHAT.code,
               v2_only: false),
  Location.new(id: 12, orderable: false, name: 'system_top_bar', product_code: Product::SUPPORT.code),
  Location.new(id: 13, orderable: false, name: 'system_top_bar', product_code: Product::STANDALONE_CHAT.code,
               v2_only: false)
].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
# 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)
  @product_code = attrs.fetch(:product_code)
  @v2_only = attrs.fetch(:v2_only, product != Product::SUPPORT)
end

Instance Attribute Details

#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



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

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



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

def product
  Product.find_by(code: product_code)
end