Class: UspsApi::SchedulePickupRequestPickupLocation

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/schedule_pickup_request_pickup_location.rb

Overview

Details of where to pickup packages.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(package_location:, special_instructions: SKIP, dog_present: false) ⇒ SchedulePickupRequestPickupLocation

Returns a new instance of SchedulePickupRequestPickupLocation.



48
49
50
51
52
53
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 48

def initialize(package_location:, special_instructions: SKIP,
               dog_present: false)
  @package_location = package_location
  @special_instructions = special_instructions unless special_instructions == SKIP
  @dog_present = dog_present unless dog_present == SKIP
end

Instance Attribute Details

#dog_presentTrueClass | FalseClass

Used to notify the carrier if a dog is present at the pickup location.

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 24

def dog_present
  @dog_present
end

#package_locationPackageLocation

This is the location of the packages ready for pick-up at the pickup address.

Returns:



15
16
17
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 15

def package_location
  @package_location
end

#special_instructionsString

Additional details on where the packages can be picked-up. This is required when the package location is ‘OTHER’.

Returns:

  • (String)


20
21
22
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 20

def special_instructions
  @special_instructions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  package_location =
    hash.key?('packageLocation') ? hash['packageLocation'] : nil
  special_instructions =
    hash.key?('specialInstructions') ? hash['specialInstructions'] : SKIP
  dog_present = hash['dogPresent'] ||= false

  # Create object from extracted values.
  SchedulePickupRequestPickupLocation.new(package_location: package_location,
                                          special_instructions: special_instructions,
                                          dog_present: dog_present)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['package_location'] = 'packageLocation'
  @_hash['special_instructions'] = 'specialInstructions'
  @_hash['dog_present'] = 'dogPresent'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 36

def self.optionals
  %w[
    special_instructions
    dog_present
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



80
81
82
83
84
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 80

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} package_location: #{@package_location.inspect}, special_instructions:"\
  " #{@special_instructions.inspect}, dog_present: #{@dog_present.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



73
74
75
76
77
# File 'lib/usps_api/models/schedule_pickup_request_pickup_location.rb', line 73

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} package_location: #{@package_location}, special_instructions:"\
  " #{@special_instructions}, dog_present: #{@dog_present}>"
end