Module: FreshdeskAPI::Create::ClassMethods

Defined in:
lib/freshdesk_api/actions.rb

Instance Method Summary collapse

Instance Method Details

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

Create a resource, returning nil if it fails



99
100
101
102
103
# File 'lib/freshdesk_api/actions.rb', line 99

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

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

Create a resource given the attributes passed in.

Parameters:

  • client (Client)

    The FreshdeskAPI::Client object to be used

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

    The attributes to create.



89
90
91
92
93
94
95
96
# File 'lib/freshdesk_api/actions.rb', line 89

def create!(client, attributes = {}, &block)
  response = nil
  new(client, attributes).tap do |resource|
    response = resource.save!(&block)
  end

  response
end