Module: Assistly::Client::Macro

Included in:
Assistly::Client
Defined in:
lib/assistly/client/macro.rb

Overview

Defines methods related to macros

Instance Method Summary collapse

Instance Method Details

#create_macro(name, *args) ⇒ Object

Creates a new macro

@param name [String] A macro name @option options [Hash] @example Creates a new macro Assistly.create_macro("name") Assistly.create_macro("name")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



45
46
47
48
49
50
51
52
53
# File 'lib/assistly/client/macro.rb', line 45

def create_macro(name, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = post("macros",options)
  if response['success']
    return response['results']['macro']
  else
    return response
  end
end

#delete_macro(id) ⇒ Object

Deletes a single macro

@param id [Integer] a macro ID @example Deletes macro 12345 Assistly.update_macro(12345, :subject => "New Subject")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



82
83
84
85
# File 'lib/assistly/client/macro.rb', line 82

def delete_macro(id)
  response = delete("macros/#{id}")
  response
end

#macro(id) ⇒ Object

Returns extended information on a single macro

@param id [Integer] a macro ID @option options [Hash] @example Return extended information for 12345 Assistly.macro(12345)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



30
31
32
33
# File 'lib/assistly/client/macro.rb', line 30

def macro(id)
  response = get("macros/#{id}")
  response.macro
end

#macro_action(id, slug) ⇒ Object

Returns extended information on a single macro

@param id [Integer] a macro ID @option options [Hash] @example Return extended information for 12345 Assistly.macro_action(12345, "set-case-description")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



116
117
118
119
# File 'lib/assistly/client/macro.rb', line 116

def macro_action(id, slug)
  response = get("macros/#{id}/actions/#{slug}")
  response['action']
end

#macro_actions(id, *args) ⇒ Object

Returns extended information of macros

@option options [Boolean, String, Integer] @example Return extended information for 12345 Assistly.macro_actions(1) Assistly.macro_actions(1, :count => 5) Assistly.macro_actions(1, :count => 5, :page => 3)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



101
102
103
104
105
# File 'lib/assistly/client/macro.rb', line 101

def macro_actions(id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get("macros/#{id}/actions",options)
  response['results']
end

#macros(*args) ⇒ Object

Returns extended information of macros

@option options [Boolean, String, Integer] @example Return extended information for 12345 Assistly.macros Assistly.macros(:count => 5) Assistly.macros(:count => 5, :page => 3)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



15
16
17
18
19
# File 'lib/assistly/client/macro.rb', line 15

def macros(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get("macros",options)
  response
end

#update_macro(id, *args) ⇒ Object

Updates a single macro

@param id [Integer] a macro ID @option options [String] @example Updates information for macro 12345 Assistly.update_macro(12345, :subject => "New Subject")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



64
65
66
67
68
69
70
71
72
# File 'lib/assistly/client/macro.rb', line 64

def update_macro(id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = put("macros/#{id}",options)
  if response['success']
    return response['results']['macro']
  else
    return response
  end
end

#update_macro_action(id, slug, *args) ⇒ Object

Updates a single macro action

@param id [Integer] a macro ID @option options [String] @example Updates information for macro 12345 Assistly.update_macro_action(12345, "set-case-description", :value => "New Subject")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



130
131
132
133
134
135
136
137
138
# File 'lib/assistly/client/macro.rb', line 130

def update_macro_action(id, slug, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = put("macros/#{id}/actions/#{slug}",options)
  if response['success']
    return response['results']['action']
  else
    return response
  end
end