Class: UspsApi::CancellationRequest

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

Overview

Cancellation Request details.

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(consignee_appointment_id:, shipper_appointment_request_id:, crid:, destination_entry:, cancel_reason_code:, cancel_comments:, system_id: 'FastAPI', additional_properties: nil) ⇒ CancellationRequest

Returns a new instance of CancellationRequest.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/usps_api/models/cancellation_request.rb', line 71

def initialize(consignee_appointment_id:, shipper_appointment_request_id:,
               crid:, destination_entry:, cancel_reason_code:,
               cancel_comments:, system_id: 'FastAPI',
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @consignee_appointment_id = consignee_appointment_id
  @shipper_appointment_request_id = shipper_appointment_request_id
  @crid = crid
  @system_id = system_id unless system_id == SKIP
  @destination_entry = destination_entry
  @cancel_reason_code = cancel_reason_code
  @cancel_comments = cancel_comments
  @additional_properties = additional_properties
end

Instance Attribute Details

#cancel_commentsString

Comments the user enters upon appointment cancellation

Returns:

  • (String)


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

def cancel_comments
  @cancel_comments
end

#cancel_reason_codeCancelReasonCode

The reason the appointment was cancelled. Only set when the appointment is cancelled.

  • ‘A` - Appointment made in error

  • ‘D` - Delivery appointment Cancelled per request of consignee

  • ‘E` - Product combined into another existing appointment

  • ‘M` - Major change in expected delivery window

  • ‘P` - Product not available

Returns:



40
41
42
# File 'lib/usps_api/models/cancellation_request.rb', line 40

def cancel_reason_code
  @cancel_reason_code
end

#consignee_appointment_idString

FAST appointment ID.

Returns:

  • (String)


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

def consignee_appointment_id
  @consignee_appointment_id
end

#cridString

The CRID of the appointment scheduler.

Returns:

  • (String)


22
23
24
# File 'lib/usps_api/models/cancellation_request.rb', line 22

def crid
  @crid
end

#destination_entryDestinationEntry

Dropship is YES. Origin Entry is NO.

Returns:



30
31
32
# File 'lib/usps_api/models/cancellation_request.rb', line 30

def destination_entry
  @destination_entry
end

#shipper_appointment_request_idString

Mailer assigned ID.

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/cancellation_request.rb', line 18

def shipper_appointment_request_id
  @shipper_appointment_request_id
end

#system_idString

Identifies the submitting application.

Returns:

  • (String)


26
27
28
# File 'lib/usps_api/models/cancellation_request.rb', line 26

def system_id
  @system_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/usps_api/models/cancellation_request.rb', line 89

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  consignee_appointment_id =
    hash.key?('consigneeAppointmentID') ? hash['consigneeAppointmentID'] : nil
  shipper_appointment_request_id =
    hash.key?('shipperAppointmentRequestID') ? hash['shipperAppointmentRequestID'] : nil
  crid = hash.key?('CRID') ? hash['CRID'] : nil
  destination_entry =
    hash.key?('destinationEntry') ? hash['destinationEntry'] : nil
  cancel_reason_code =
    hash.key?('cancelReasonCode') ? hash['cancelReasonCode'] : nil
  cancel_comments =
    hash.key?('cancelComments') ? hash['cancelComments'] : nil
  system_id = hash['systemID'] ||= 'FastAPI'

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CancellationRequest.new(consignee_appointment_id: consignee_appointment_id,
                          shipper_appointment_request_id: shipper_appointment_request_id,
                          crid: crid,
                          destination_entry: destination_entry,
                          cancel_reason_code: cancel_reason_code,
                          cancel_comments: cancel_comments,
                          system_id: system_id,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/usps_api/models/cancellation_request.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['consignee_appointment_id'] = 'consigneeAppointmentID'
  @_hash['shipper_appointment_request_id'] = 'shipperAppointmentRequestID'
  @_hash['crid'] = 'CRID'
  @_hash['system_id'] = 'systemID'
  @_hash['destination_entry'] = 'destinationEntry'
  @_hash['cancel_reason_code'] = 'cancelReasonCode'
  @_hash['cancel_comments'] = 'cancelComments'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/usps_api/models/cancellation_request.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



60
61
62
63
64
# File 'lib/usps_api/models/cancellation_request.rb', line 60

def self.optionals
  %w[
    system_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



135
136
137
138
139
140
141
142
143
# File 'lib/usps_api/models/cancellation_request.rb', line 135

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} consignee_appointment_id: #{@consignee_appointment_id.inspect},"\
  " shipper_appointment_request_id: #{@shipper_appointment_request_id.inspect}, crid:"\
  " #{@crid.inspect}, system_id: #{@system_id.inspect}, destination_entry:"\
  " #{@destination_entry.inspect}, cancel_reason_code: #{@cancel_reason_code.inspect},"\
  " cancel_comments: #{@cancel_comments.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



125
126
127
128
129
130
131
132
# File 'lib/usps_api/models/cancellation_request.rb', line 125

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} consignee_appointment_id: #{@consignee_appointment_id},"\
  " shipper_appointment_request_id: #{@shipper_appointment_request_id}, crid: #{@crid},"\
  " system_id: #{@system_id}, destination_entry: #{@destination_entry}, cancel_reason_code:"\
  " #{@cancel_reason_code}, cancel_comments: #{@cancel_comments}, additional_properties:"\
  " #{@additional_properties}>"
end