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 = {}, token = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/iugu/api_create.rb', line 6

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

#search(options = {}) ⇒ Object



6
7
8
# File 'lib/iugu/api_search.rb', line 6

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