Class: UspsApi::ScheduleCarrierPickupRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::ScheduleCarrierPickupRequest
- Defined in:
- lib/usps_api/models/schedule_carrier_pickup_request.rb
Overview
The Schedule Carrier Pickup Request includes all of the necessary information to schedule a package pickup from your carrier.
Instance Attribute Summary collapse
-
#estimated_weight ⇒ Float
Estimated aggregate weight (in pounds) of all packages ready for pick-up.
-
#next_available_pickup ⇒ TrueClass | FalseClass
If you specify a pickup on a date when pickup service is not available.
-
#packages ⇒ Array[SchedulePickupRequestPackages]
The details on the types and amounts of packages ready for pick-up.
-
#pickup_address ⇒ PickupAddress
This is the point of contact information for a potential pickup.
-
#pickup_date ⇒ Date
This is the requested pickup date.
-
#pickup_location ⇒ SchedulePickupRequestPickupLocation
Details of where to pickup packages.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(pickup_date:, pickup_address:, packages:, estimated_weight:, pickup_location:, next_available_pickup: false) ⇒ ScheduleCarrierPickupRequest
constructor
A new instance of ScheduleCarrierPickupRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(pickup_date:, pickup_address:, packages:, estimated_weight:, pickup_location:, next_available_pickup: false) ⇒ ScheduleCarrierPickupRequest
Returns a new instance of ScheduleCarrierPickupRequest.
65 66 67 68 69 70 71 72 73 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 65 def initialize(pickup_date:, pickup_address:, packages:, estimated_weight:, pickup_location:, next_available_pickup: false) @pickup_date = pickup_date @pickup_address = pickup_address @packages = packages @estimated_weight = estimated_weight @pickup_location = pickup_location @next_available_pickup = next_available_pickup unless next_available_pickup == SKIP end |
Instance Attribute Details
#estimated_weight ⇒ Float
Estimated aggregate weight (in pounds) of all packages ready for pick-up.
29 30 31 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 29 def estimated_weight @estimated_weight end |
#next_available_pickup ⇒ TrueClass | FalseClass
If you specify a pickup on a date when pickup service is not available. The API will automatically schedule your pickup for the next available day when pickup is available.
39 40 41 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 39 def next_available_pickup @next_available_pickup end |
#packages ⇒ Array[SchedulePickupRequestPackages]
The details on the types and amounts of packages ready for pick-up.
25 26 27 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 25 def packages @packages end |
#pickup_address ⇒ PickupAddress
This is the point of contact information for a potential pickup.
21 22 23 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 21 def pickup_address @pickup_address end |
#pickup_date ⇒ Date
This is the requested pickup date. You can schedule pickups Monday - Saturday until 2:00 AM CT on the day of the pickup. After 2:00 AM CT, same-day pickup is not available.
17 18 19 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 17 def pickup_date @pickup_date end |
#pickup_location ⇒ SchedulePickupRequestPickupLocation
Details of where to pickup packages.
33 34 35 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 33 def pickup_location @pickup_location end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 76 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. pickup_date = hash.key?('pickupDate') ? hash['pickupDate'] : nil pickup_address = PickupAddress.from_hash(hash['pickupAddress']) if hash['pickupAddress'] # Parameter is an array, so we need to iterate through it packages = nil unless hash['packages'].nil? packages = [] hash['packages'].each do |structure| packages << (SchedulePickupRequestPackages.from_hash(structure) if structure) end end packages = nil unless hash.key?('packages') estimated_weight = hash.key?('estimatedWeight') ? hash['estimatedWeight'] : nil pickup_location = SchedulePickupRequestPickupLocation.from_hash(hash['pickupLocation']) if hash['pickupLocation'] next_available_pickup = hash['nextAvailablePickup'] ||= false # Create object from extracted values. ScheduleCarrierPickupRequest.new(pickup_date: pickup_date, pickup_address: pickup_address, packages: packages, estimated_weight: estimated_weight, pickup_location: pickup_location, next_available_pickup: next_available_pickup) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['pickup_date'] = 'pickupDate' @_hash['pickup_address'] = 'pickupAddress' @_hash['packages'] = 'packages' @_hash['estimated_weight'] = 'estimatedWeight' @_hash['pickup_location'] = 'pickupLocation' @_hash['next_available_pickup'] = 'nextAvailablePickup' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 54 def self.optionals %w[ next_available_pickup ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
116 117 118 119 120 121 122 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 116 def inspect class_name = self.class.name.split('::').last "<#{class_name} pickup_date: #{@pickup_date.inspect}, pickup_address:"\ " #{@pickup_address.inspect}, packages: #{@packages.inspect}, estimated_weight:"\ " #{@estimated_weight.inspect}, pickup_location: #{@pickup_location.inspect},"\ " next_available_pickup: #{@next_available_pickup.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
108 109 110 111 112 113 |
# File 'lib/usps_api/models/schedule_carrier_pickup_request.rb', line 108 def to_s class_name = self.class.name.split('::').last "<#{class_name} pickup_date: #{@pickup_date}, pickup_address: #{@pickup_address}, packages:"\ " #{@packages}, estimated_weight: #{@estimated_weight}, pickup_location:"\ " #{@pickup_location}, next_available_pickup: #{@next_available_pickup}>" end |