Class: UspsApi::PmodCommitment

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

Overview

The commitment and scheduled delivery date of the package.

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(name: SKIP, schedule_delivery_date: SKIP, expected_delivery_date: SKIP) ⇒ PmodCommitment

Returns a new instance of PmodCommitment.



53
54
55
56
57
58
# File 'lib/usps_api/models/pmod_commitment.rb', line 53

def initialize(name: SKIP, schedule_delivery_date: SKIP,
               expected_delivery_date: SKIP)
  @name = name unless name == SKIP
  @schedule_delivery_date = schedule_delivery_date unless schedule_delivery_date == SKIP
  @expected_delivery_date = expected_delivery_date unless expected_delivery_date == SKIP
end

Instance Attribute Details

#expected_delivery_dateString

Date in the YYYY-MM-DD format.

Returns:

  • (String)


28
29
30
# File 'lib/usps_api/models/pmod_commitment.rb', line 28

def expected_delivery_date
  @expected_delivery_date
end

#nameString

Commitment name such as 1-days, 2-days, 3-days, Military, DPO

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/pmod_commitment.rb', line 14

def name
  @name
end

#schedule_delivery_dateString

Date in the ‘YYYY-MM-DD` format. Date USPS expects that the package or mailpiece will be delivered based on the origin, destination, and drop-off time and date in the request. Actual delivery date may vary based on when the package or mailpiece is entered or other conditions. Note: This field has been deprecated in favor of `expectedDeliveryDate` and will be removed in a future release. Please transition to using `expectedDeliveryDate`.

Returns:

  • (String)


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

def schedule_delivery_date
  @schedule_delivery_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/usps_api/models/pmod_commitment.rb', line 61

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  schedule_delivery_date =
    hash.key?('scheduleDeliveryDate') ? hash['scheduleDeliveryDate'] : SKIP
  expected_delivery_date =
    hash.key?('expectedDeliveryDate') ? hash['expectedDeliveryDate'] : SKIP

  # Create object from extracted values.
  PmodCommitment.new(name: name,
                     schedule_delivery_date: schedule_delivery_date,
                     expected_delivery_date: expected_delivery_date)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
# File 'lib/usps_api/models/pmod_commitment.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['schedule_delivery_date'] = 'scheduleDeliveryDate'
  @_hash['expected_delivery_date'] = 'expectedDeliveryDate'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/usps_api/models/pmod_commitment.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
# File 'lib/usps_api/models/pmod_commitment.rb', line 40

def self.optionals
  %w[
    name
    schedule_delivery_date
    expected_delivery_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
90
# File 'lib/usps_api/models/pmod_commitment.rb', line 85

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

#to_sObject

Provides a human-readable string representation of the object.



78
79
80
81
82
# File 'lib/usps_api/models/pmod_commitment.rb', line 78

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