Module: ZendeskAPI::UpdateMany

Included in:
Ticket, User
Defined in:
lib/zendesk_api/actions.rb

Instance Method Summary collapse

Instance Method Details

#update_many!(client, ids_or_attributes, attributes = {}) ⇒ JobStatus

Updates multiple resources using the update_many endpoint.

Parameters:

  • client (Client)

    The Client object to be used

  • ids_or_attributes (Array)

    An array of ids or arributes including ids to update

  • attributes (Hash) (defaults to: {})

    The attributes to update resources with

Returns:



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/zendesk_api/actions.rb', line 317

def update_many!(client, ids_or_attributes, attributes = {})
  association = attributes.delete(:association) || Association.new(:class => self)

  response = client.connection.put("#{association.generate_path}/update_many") do |req|
    if attributes == {}
      req.body = { resource_name => ids_or_attributes }
    else
      req.params = { :ids => ids_or_attributes.join(',') }
      req.body = { singular_resource_name => attributes }
    end

    yield req if block_given?
  end

  JobStatus.new_from_response(client, response)
end