Module: Onfleet::Actions::Save

Included in:
Onfleet::Admin, Destination, Recipient, Task, Worker
Defined in:
lib/onfleet-ruby/actions/save.rb

Instance Method Summary collapse

Instance Method Details

#saveObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/onfleet-ruby/actions/save.rb', line 4

def save
  if respond_to?('id') && self.id
    request_type = :put
    url = "#{self.url}/#{self.id}"
  else
    request_type  = :post
    url = self.url
  end
  response = Onfleet.request(url, request_type, self.attributes)
  self.parse_response(response)
end