Class: EasyPost::Beta::EndShipper

Inherits:
Resource show all
Defined in:
lib/easypost/beta/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

Instance Method Summary collapse

Methods inherited from Resource

class_name, #delete, each, #refresh, 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

.all(params = {}, api_key = nil) ⇒ Object

Retrieves a list of EndShipper objects. DEPRECATED: Please use EndShipper in the main namespace instead.



23
24
25
26
27
# File 'lib/easypost/beta/end_shipper.rb', line 23

def self.all(params = {}, api_key = nil)
  warn '[DEPRECATION] Please use `EndShipper.all` in the main namespace instead.'
  response = EasyPost.make_request(:get, '/beta/end_shippers', api_key, params)
  EasyPost::Util.convert_to_easypost_object(response, api_key)
end

.create(params = {}, api_key = nil) ⇒ Object

Create an EndShipper object. DEPRECATED: Please use EndShipper in the main namespace instead.



7
8
9
10
11
# File 'lib/easypost/beta/end_shipper.rb', line 7

def self.create(params = {}, api_key = nil)
  warn '[DEPRECATION] Please use `EndShipper.create` in the main namespace instead.'
  response = EasyPost.make_request(:post, '/beta/end_shippers', api_key, { address: params })
  EasyPost::Util.convert_to_easypost_object(response, api_key)
end

.retrieve(id, params = {}, api_key = nil) ⇒ Object

Retrieves an EndShipper object. DEPRECATED: Please use EndShipper in the main namespace instead.



15
16
17
18
19
# File 'lib/easypost/beta/end_shipper.rb', line 15

def self.retrieve(id, params = {}, api_key = nil)
  warn '[DEPRECATION] Please use `EndShipper.retrieve` in the main namespace instead.'
  response = EasyPost.make_request(:get, "/beta/end_shippers/#{id}", api_key, params)
  EasyPost::Util.convert_to_easypost_object(response, api_key)
end

Instance Method Details

#saveObject

Updates (saves) an EndShipper object. This requires all parameters to be set. DEPRECATED: Please use EndShipper in the main namespace instead.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/easypost/beta/end_shipper.rb', line 31

def save
  warn '[DEPRECATION] Please use `endShipper.save` in the main namespace instead.'
  if @unsaved_values.length.positive?
    values = {}
    @unsaved_values.each { |k| values[k] = @values[k] }

    wrapped_params = { address: values }

    response = EasyPost.make_request(:put, "/beta/end_shippers/#{id}", @api_key, wrapped_params)
    refresh_from(response, api_key)
  end
  self
end