Module: Iugu::APICreate::ClassMethods

Defined in:
lib/iugu/api_create.rb,
lib/iugu/api_search.rb

Instance Method Summary collapse

Instance Method Details

#create(attributes = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/iugu/api_create.rb', line 4

def create(attributes = {})
  Iugu::Factory.create_from_response self.object_type,  APIRequest.request("POST", self.url(attributes), attributes)
rescue Iugu::RequestWithErrors => ex
  obj = self.new
  obj.set_attributes attributes, true
  obj.errors = ex.errors
  obj
end

#search(options = {}) ⇒ Object



4
5
6
# File 'lib/iugu/api_search.rb', line 4

def search(options = {})
  Iugu::Factory.create_from_response self.object_type, APIRequest.request("GET", self.url(options), options)
end