Class: Readiness::Zendesk::Brands

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/zendesk/brands.rb

Overview

TODO:

find

TODO:

find!

TODO:

Create

TODO:

Update

TODO:

Delete

TODO:

Check Host Mapping Validity

TODO:

Check Host Mapping Validity for an Existing Brand

Defines the class Brands within the module Readiness::Zendesk.

Author:

  • Jason Colyer

Since:

  • 1.0.118

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Constructor Details

#initialize(object = {}) ⇒ Brands

Creates a new Readiness::Zendesk::Brands instance

Examples:

require 'support_readiness'
Readiness::Zendesk::Brands.new

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.118



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/support_readiness/zendesk/brands.rb', line 31

def initialize(object = {})
  @active = object['active']
  @brand_url = object['brand_url']
  @created_at = object['created_at']
  @default = object['default']
  @has_help_center = object['has_help_center']
  @help_center_state = object['help_center_state']
  @host_mapping = object['host_mapping']
  @id = object['id']
  @logo = object['logo']
  @name = object['name']
  @signature_template = object['signature_template']
  @subdomain = object['subdomain']
  @ticket_form_ids = object['ticket_form_ids']
  @updated_at = object['updated_at']
end

Instance Attribute Details

#activeObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def active
  @active
end

#brand_urlObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def brand_url
  @brand_url
end

#created_atObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def created_at
  @created_at
end

#defaultObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def default
  @default
end

#has_help_centerObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def has_help_center
  @has_help_center
end

#help_center_stateObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def help_center_state
  @help_center_state
end

#host_mappingObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def host_mapping
  @host_mapping
end

#idObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def id
  @id
end

#logoObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def 
  @logo
end

#nameObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def name
  @name
end

#signature_templateObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def signature_template
  @signature_template
end

#subdomainObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def subdomain
  @subdomain
end

#ticket_form_idsObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def ticket_form_ids
  @ticket_form_ids
end

#updated_atObject

Since:

  • 1.0.118



20
21
22
# File 'lib/support_readiness/zendesk/brands.rb', line 20

def updated_at
  @updated_at
end

Class Method Details

.find_by_name(client, name, cache = nil) ⇒ Object

Locates a brand within Zendesk by name. Can utilize a cacheh for quicker results

Examples:

require 'support_readiness'
config = Readiness::Zendesk::Configuration.new
config.username = 'alice@example.com'
config.token = 'test123abc'
config.url = 'https://example.zendesk.com/api/v2'
client = Readiness::Zendesk::Client.new(config)
brand = Readiness::Zendesk::Brands.find_by_name(client, 'Brand 1')
pp brand.id
# => 360002783572

Parameters:

  • client (Object)

    An instance of Client

  • name (String)

    The brand name to look for

  • cache (Array) (defaults to: nil)

    The results of #list

Returns:

Author:

  • Jason Colyer

Since:

  • 1.0.118



92
93
94
95
96
97
98
99
# File 'lib/support_readiness/zendesk/brands.rb', line 92

def self.find_by_name(client, name, cache = nil)
  brands = if cache.nil?
             Brands.list(client)
           else
             cache
           end
  brands.detect { |f| f.name == name }
end

.list(client) ⇒ Array

Lists all brands.

Examples:

require 'support_readiness'
config = Readiness::Zendesk::Configuration.new
config.username = 'alice@example.com'
config.token = 'test123abc'
config.url = 'https://example.zendesk.com/api/v2'
client = Readiness::Zendesk::Client.new(config)
brands = Readiness::Zendesk::Brands.list(client)
pp brands.count
# => 2

Parameters:

  • client (Object)

    An instance of Client

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.118



66
67
68
69
70
71
# File 'lib/support_readiness/zendesk/brands.rb', line 66

def self.list(client)
  response = client.connection.get 'brands'
  handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
  body = Oj.load(response.body)
  body['brands'].map { |b| Brands.new(b) }
end