Module: FreshdeskAPI::Update::ClassMethods

Defined in:
lib/freshdesk_api/actions.rb

Instance Method Summary collapse

Instance Method Details

#update(client, attributes = {}, &block) ⇒ Object

Updates a resource, returning nil if it fails



140
141
142
143
144
# File 'lib/freshdesk_api/actions.rb', line 140

def update(client, attributes = {}, &block)
  update!(client, attributes, &block)
rescue FreshdeskAPI::Error::ClientError
  false
end

#update!(client, attributes = {}, &block) ⇒ Object

Updates a resource given the id passed in

Parameters:

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

    The attributes to update. Default to {}



129
130
131
132
133
134
135
136
137
# File 'lib/freshdesk_api/actions.rb', line 129

def update!(client, attributes = {}, &block)
  response = nil
  new(client, id: attributes.delete(:id)).tap do |resource|
    resource.attributes.merge!(attributes)
    response = resource.save!(&block)
  end

  response
end