Module: Besepa::ApiCalls::Update

Included in:
BankAccount, BusinessAccount, Customer, Debit, Group, Product, Subscription, User
Defined in:
lib/besepa/api_calls/update.rb

Instance Method Summary collapse

Instance Method Details

#save(filters = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/besepa/api_calls/update.rb', line 4

def save(filters={})
  h = self.to_hash
  # id and status should not be send back to the server
  h.delete(:status)
  h.delete(:id)
  # remove all nil values. Not updated.
  h.delete_if {|key, value| value.nil? unless allowed_nils.include?(key)}
  payload = {}
  payload[self.class.klass_name] = h
  response = put "/#{self.class.api_path(filters)}/#{id}", payload
  process_attributes(response['response'])
  self
end