Class: Amiando::ApiKey

Inherits:
Resource show all
Defined in:
lib/amiando/api_key.rb

Overview

Instance Attribute Summary

Attributes inherited from Resource

#request, #response, #success

Class Method Summary collapse

Methods inherited from Resource

#==, #extract_attributes_from, #initialize, method_missing, #populate_create

Methods included from Attributes

#[], #id, included, #method_missing, #respond_to?, #type

Methods included from Autorun

included

Constructor Details

This class inherits a constructor from Amiando::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Amiando::Attributes

Class Method Details

.create(attributes) ⇒ ApiKey

Creates an Amiando::ApiKey.

Parameters:

  • attributes (Hash)

    possible attributes that can be set on creation.

Returns:

Raises:

  • (ArgumentError)

    if no name provided in attributes


14
15
16
17
18
19
20
21
# File 'lib/amiando/api_key.rb', line 14

def self.create(attributes)
  raise ArgumentError.new('ApiKey name field is mandatory') unless attributes[:name]

  object = new
  post object, '/api/apiKey/create', :params => attributes

  object
end

.update(id, attributes) ⇒ Boolean

Updates an Amiando::ApiKey.

Parameters:

  • attributes (Hash)

    possible attributes that can be updated.

Returns:


28
29
30
31
32
33
# File 'lib/amiando/api_key.rb', line 28

def self.update(id, attributes)
  object = Boolean.new(:success)
  post object, "/api/apiKey/#{id}", :params => attributes

  object
end