Class: EasyPost::EndShipper
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::EndShipper
- Defined in:
- lib/easypost/end_shipper.rb
Overview
EndShipper objects are fully-qualified Address objects that require all parameters and get verified upon creation.
Instance Attribute Summary
Attributes inherited from EasyPostObject
#api_key, #name, #parent, #unsaved_values
Class Method Summary collapse
-
.create(params = {}, api_key = nil) ⇒ Object
Create an EndShipper object.
Instance Method Summary collapse
-
#save ⇒ Object
Updates (saves) an EndShipper object.
Methods inherited from Resource
all, class_name, #delete, each, #refresh, retrieve, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #deconstruct_keys, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Class Method Details
.create(params = {}, api_key = nil) ⇒ Object
Create an EndShipper object.
6 7 8 9 |
# File 'lib/easypost/end_shipper.rb', line 6 def self.create(params = {}, api_key = nil) response = EasyPost.make_request(:post, url, api_key, { address: params }) EasyPost::Util.convert_to_easypost_object(response, api_key) end |
Instance Method Details
#save ⇒ Object
Updates (saves) an EndShipper object. This requires all parameters to be set.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/easypost/end_shipper.rb', line 12 def save if @unsaved_values.length.positive? values = {} @unsaved_values.each { |k| values[k] = @values[k] } wrapped_params = { address: values } response = EasyPost.make_request(:put, url, @api_key, wrapped_params) refresh_from(response, api_key) end self end |