Class: Amiando::ApiKey

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

Overview

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #request, #response, #success

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Resource

#==, #[], #extract_attributes_from, #id, #initialize, map, map_params, mapping, #method_missing, method_missing, #populate_create, reverse_map_params, typecasting

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::Resource

Class Method Details

+ (Object) create(attributes)

Creates an Amiando::ApiKey.

Parameters:

  • possible (Hash)

    attributes that can be set on creation.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
# File 'lib/amiando/api_key.rb', line 11

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

+ (Object) update(id, attributes)

Updates an Amiando::ApiKey.

Parameters:

  • possible (Hash)

    attributes that can be updated.



24
25
26
27
28
29
# File 'lib/amiando/api_key.rb', line 24

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

  object
end

Instance Method Details

- (Object) populate(response_body)



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

def populate(response_body)
  extract_attributes_from(response_body, 'apiKey')
end