Class: WhiplashApi::ShipnoticeItem
- Defined in:
- lib/whiplash_api/shipnotice_item.rb
Class Method Summary collapse
- .delete(*args) ⇒ Object
-
.find(*args) ⇒ Object
Finders for ShipnoticeItem require ‘shipnotice_id` key to be present.
- .update(id, args = {}) ⇒ Object
Instance Method Summary collapse
-
#destroy ⇒ Object
instance methods.
Methods inherited from Base
connection, headers, reset_headers!, testing!
Class Method Details
.delete(*args) ⇒ Object
27 28 29 30 31 |
# File 'lib/whiplash_api/shipnotice_item.rb', line 27 def delete(*args) super rescue WhiplashApi::RecordNotFound raise RecordNotFound, "No shipnotice item found with given ID." end |
.find(*args) ⇒ Object
Finders for ShipnoticeItem require ‘shipnotice_id` key to be present. The following routine enforces this condition.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/whiplash_api/shipnotice_item.rb', line 8 def find(*args) scope = args.slice!(0) = args.slice!(0) || {} if [:all, :first, :last, :one].include?(scope) invalid = [:params].to_s.empty? || [:params][:shipnotice_id].to_s.empty? raise Error, "You must supply a Shipment Notice ID (as parameter) to retrieve shipnotice items for." if invalid end super(scope, ) end |
.update(id, args = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/whiplash_api/shipnotice_item.rb', line 20 def update(id, args={}) response = self.put(id, {}, args.to_json) response.code.to_i >= 200 && response.code.to_i < 300 rescue WhiplashApi::RecordNotFound raise RecordNotFound, "No shipnotice item found with given ID." end |
Instance Method Details
#destroy ⇒ Object
instance methods
35 36 37 |
# File 'lib/whiplash_api/shipnotice_item.rb', line 35 def destroy self.class.delete(self.id) end |