{
  safe: (v) => (v != null ? '' + v : ''),

  base: (tenant) => 'https://' + tenant + '.haloitsm.com/api',

  tickets_url: (tenant) => 'https://' + tenant + '.haloitsm.com/api/Tickets',
  ticket_url: (tenant, id) => 'https://' + tenant + '.haloitsm.com/api/Tickets/' + id,
  actions_url: (tenant) => 'https://' + tenant + '.haloitsm.com/api/Actions',
  users_url: (tenant) => 'https://' + tenant + '.haloitsm.com/api/Users',
  assets_url: (tenant) => 'https://' + tenant + '.haloitsm.com/api/Asset',
  asset_url: (tenant, id) => 'https://' + tenant + '.haloitsm.com/api/Asset/' + id,
  kb_url: (tenant) => 'https://' + tenant + '.haloitsm.com/api/KBArticle',
  report_url: (tenant, id) => 'https://' + tenant + '.haloitsm.com/api/Report/' + id,

  config_path: (resource) =>
    ('' + resource).toLowerCase() == 'priority' ? 'Priority' :
    (('' + resource).toLowerCase() == 'tickettype' ? 'TicketType' :
    (('' + resource).toLowerCase() == 'team' ? 'Team' :
    (('' + resource).toLowerCase() == 'agent' ? 'Agent' :
    (('' + resource).toLowerCase() == 'client' ? 'Client' :
    (('' + resource).toLowerCase() == 'site' ? 'Site' :
    'Status'))))),

  config_url: (tenant, resource) => 'https://' + tenant + '.haloitsm.com/api/' + lib.halo.config_path(resource),

  num: (v) => (v != null && ('' + v).trim() != '' ? parseInt('' + v) : null),
  str: (v) => (v != null && ('' + v).trim() != '' ? '' + v : null),
  bool: (v) => (v != null && ('' + v).trim() != '' ? ('' + v).toLowerCase() == 'true' : null),

  clean: (o) => o.filter((v, k) => v != null),

  body_array: (o) => [o.filter((v, k) => v != null)],

  format_ticket: (t) => 'Ticket #' + (t.id != null ? t.id : '?') + ' - ' + (t.summary != null ? t.summary : '(no summary)') + ' [status_id ' + (t.status_id != null ? t.status_id : '?') + ', agent_id ' + (t.agent_id != null ? t.agent_id : '?') + ']'
}
