Module: ZendeskAPI::Create::ClassMethods

Defined in:
lib/zendesk_api/actions.rb

Instance Method Summary collapse

Instance Method Details

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

Creates, returning nil if it fails

Parameters:

  • client (Client)

    The ZendeskAPI::Client object to be used

  • options (Hash)

    Any additional GET parameters to be added



160
161
162
163
164
# File 'lib/zendesk_api/actions.rb', line 160

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

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

Create a resource given the attributes passed in.

Parameters:

  • client (Client)

    The ZendeskAPI::Client object to be used

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

    The attributes to create.



149
150
151
152
153
154
155
# File 'lib/zendesk_api/actions.rb', line 149

def create!(client, attributes = {}, &block)
  ZendeskAPI::Client.check_deprecated_namespace_usage attributes, singular_resource_name

  new(client, attributes).tap do |resource|
    resource.save!(&block)
  end
end