Class: Amiando::Partner

Inherits:
Resource show all
Defined in:
lib/amiando/partner.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) ⇒ Partner

Creates a partner.

Parameters:

  • attributes (Hash)

Returns:

  • (Partner)

    but will only have the id loaded


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

def self.create(attributes)
  object = new
  post object, '/api/partner/create',
    :params          => attributes,
    :populate_method => :populate_create

  object
end

.find(id) ⇒ Partner

Find a partner

Parameters:

  • id

    id of the partner

Returns:

  • (Partner)

    the partner with that id


41
42
43
44
45
46
# File 'lib/amiando/partner.rb', line 41

def self.find(id)
  object = new
  get object, "/api/partner/#{id}"

  object
end

.update(id, attributes) ⇒ Result

Updates the partner.

Parameters:

  • id

    the internal id of the partner to update.

  • attributes (Hash)

Returns:

  • (Result)

    saying if the update was successful


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

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

  object
end