Class: Readiness::Zendesk::Schedules

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

Overview

TODO:

Find methods

TODO:

Create method

TODO:

Update method

TODO:

Delete method

TODO:

Holiday methods

TODO:

Update Intervals method

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

Author:

  • Jason Colyer

Since:

  • 1.0.92

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 = {}) ⇒ Schedules

Creates a new Readiness::Zendesk::Schedules instance

Examples:

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

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.92



30
31
32
33
34
35
# File 'lib/support_readiness/zendesk/schedules.rb', line 30

def initialize(object = {})
  @id = object['id']
  @intervals = object['intervals']
  @name = object['name']
  @time_zone = object['time_zone']
end

Instance Attribute Details

#idObject

Since:

  • 1.0.92



19
20
21
# File 'lib/support_readiness/zendesk/schedules.rb', line 19

def id
  @id
end

#intervalsObject

Since:

  • 1.0.92



19
20
21
# File 'lib/support_readiness/zendesk/schedules.rb', line 19

def intervals
  @intervals
end

#nameObject

Since:

  • 1.0.92



19
20
21
# File 'lib/support_readiness/zendesk/schedules.rb', line 19

def name
  @name
end

#time_zoneObject

Since:

  • 1.0.92



19
20
21
# File 'lib/support_readiness/zendesk/schedules.rb', line 19

def time_zone
  @time_zone
end

Class Method Details

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

Locates a schehdule 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)
schedule = Readiness::Zendesk::Schedules.find_by_name!(client, 'North America')
pp schedule.id
# => 1
list = Readiness::Zendesk::Schedules.list(client)
schedule = Readiness::Zendesk::Schedules.find_by_name!(client, 'North America', list)
pp schedule.id
# => 1

Parameters:

  • client (Object)

    An instance of Client

  • name (String)

    The webhook name to look for

  • cache (Array) (defaults to: nil)

    The results of #list

Returns:

Author:

  • Jason Colyer

Since:

  • 1.0.92



85
86
87
88
89
90
91
92
# File 'lib/support_readiness/zendesk/schedules.rb', line 85

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

.list(client) ⇒ Array

Lists schedules

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)
categories = Readiness::Zendesk::Schedules.list(client)
pp categories.first.id
# => 10001

Parameters:

  • client (Object)

    An instance of Client

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.92



55
56
57
58
59
60
# File 'lib/support_readiness/zendesk/schedules.rb', line 55

def self.list(client)
  response = client.connection.get 'business_hours/schedules'
  handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
  body = Oj.load(response.body)
  body['schedules'].map { |t| Schedules.new(t) }
end