Module: ZendeskAPI::Create::ClassMethods

Defined in:
lib/zendesk_api/actions.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) create(client, attributes = {})

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.



116
117
118
119
120
121
# File 'lib/zendesk_api/actions.rb', line 116

def create(client, attributes = {})
  ZendeskAPI::Client.check_deprecated_namespace_usage attributes, singular_resource_name
  resource = new(client, attributes)
  return unless resource.save
  resource
end

- (Object) create!(client, attributes = {})

Creates the resource, raising an ArgumentError if it fails

Raises:

  • (ArgumentError)

    if the creation fails



125
126
127
128
# File 'lib/zendesk_api/actions.rb', line 125

def create!(client, attributes={})
  c = create(client, attributes)
  c || raise("Create failed #{self} #{attributes}")
end