Class: ZendeskAPI::Macro

Inherits:
Rule show all
Includes:
Actions
Defined in:
lib/zendesk_api/resources.rb

Instance Attribute Summary

Attributes inherited from DataResource

#error, #error_message

Attributes inherited from Data

#association, #attributes, #errors, #response

Instance Method Summary collapse

Methods included from Actions

#add_action

Methods included from Destroy

#destroy, #destroy!, #destroyed?, included

Methods included from Update

included

Methods included from Save

#clear_associations, #save, #save!, #save_associations

Methods included from ResponseHandler

#handle_response

Methods included from Create

included

Methods included from Read

included, #reload!

Methods included from Sideloading

included, #set_includes

Methods included from Verbs

#any, #delete, #post, #put

Methods inherited from Data

#==, #id, inherited, #initialize, #loaded_associations, #method_missing, namespace, new_from_response, #new_record?, #path, resource_name, resource_path, #respond_to_missing?, singular_resource_name, subclasses, #to_json, #to_s

Methods included from Associations

included, #wrap_resource

Constructor Details

This class inherits a constructor from ZendeskAPI::Data

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ZendeskAPI::Data

Instance Method Details

#apply(ticket = nil) ⇒ Object

Returns the update to a ticket that happens when a macro will be applied.

Parameters:

  • ticket (Ticket) (defaults to: nil)

    Optional Ticket to apply this macro to



579
580
581
582
583
# File 'lib/zendesk_api/resources.rb', line 579

def apply(ticket = nil)
  apply!(ticket)
rescue Faraday::ClientError
  SilentMash.new
end

#apply!(ticket = nil) ⇒ Object

Returns the update to a ticket that happens when a macro will be applied.

Parameters:

  • ticket (Ticket) (defaults to: nil)

    Optional Ticket to apply this macro to.

Raises:

  • (Faraday::ClientError)

    Raised for any non-200 response.



566
567
568
569
570
571
572
573
574
575
# File 'lib/zendesk_api/resources.rb', line 566

def apply!(ticket = nil)
  path = "#{self.path}/apply"

  if ticket
    path = "#{ticket.path}/#{path}"
  end

  response = @client.connection.get(path)
  SilentMash.new(response.body.fetch("result", {}))
end