Module: Iugu::APISave

Included in:
Customer, Invoice, PaymentMethod, Plan, Subscription
Defined in:
lib/iugu/api_save.rb

Instance Method Summary collapse

Instance Method Details

#saveObject



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

def save
  method = is_new? ? "POST" : "PUT"
  copy Iugu::Factory.create_from_response(self.class.object_type,
                                          APIRequest.request(method,
                                                             self.class.url(attributes),
                                                             modified_attributes))
  self.errors = nil
  true
rescue Iugu::RequestWithErrors => e
  self.errors = e.errors
  false
end