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)
].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.



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

def initialize(attrs)
  @id = attrs.fetch(:id)
  @name = attrs.fetch(:name)
  @orderable = attrs.fetch(:orderable)
  @product_code = attrs.fetch(:product_code)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#orderableObject (readonly)

Returns the value of attribute orderable.



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

def orderable
  @orderable
end

#product_codeObject (readonly)

Returns the value of attribute product_code.



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

def product_code
  @product_code
end

Class Method Details

.allObject



17
18
19
# File 'lib/zendesk_apps_support/location.rb', line 17

def self.all
  LOCATIONS_AVAILABLE
end

Instance Method Details

#productObject



13
14
15
# File 'lib/zendesk_apps_support/location.rb', line 13

def product
  Product.find_by(code: product_code)
end