Method: Frodo::Concerns::API#update!
- Defined in:
- lib/frodo/concerns/api.rb
#update!(entity_set_name, primary_key, attrs, additional_headers = {}) ⇒ Object
Public: Update a record.
entity_set - The set the entity belongs to attrs - Hash of attributes to set on the record.
Examples
# Update the leads with id '073ca9c8-2a41-e911-a81d-000d3a1d5a0b'
client.update!('leads', 'leadid' => '073ca9c8-2a41-e911-a81d-000d3a1d5a0b', "firstname" => 'Whizbang Corp')
Returns true if the entity was successfully updated. Raises an exception if an error is returned from Dynamics.
152 153 154 155 156 157 158 159 160 |
# File 'lib/frodo/concerns/api.rb', line 152 def update!(entity_set_name, primary_key, attrs, additional_headers={}) raise ArgumentError, 'ID field missing from provided attributes' unless attrs.has_key?(primary_key) url_chunk = "#{entity_set_name}(#{attrs[primary_key]})" api_patch url_chunk, attrs do |req| req.headers.merge!(additional_headers) end true end |