Class: UspsApi::CancellationResponse

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

Overview

Cancellation Response 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', cancel_number: SKIP, additional_properties: nil) ⇒ CancellationResponse

Returns a new instance of CancellationResponse.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/usps_api/models/cancellation_response.rb', line 75

def initialize(consignee_appointment_id:, shipper_appointment_request_id:,
               crid:, destination_entry:, cancel_reason_code:,
               cancel_comments:, system_id: 'FastAPI', cancel_number: SKIP,
               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
  @cancel_number = cancel_number unless cancel_number == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#cancel_commentsString

Comments the user enters upon appointment cancellation

Returns:

  • (String)


42
43
44
# File 'lib/usps_api/models/cancellation_response.rb', line 42

def cancel_comments
  @cancel_comments
end

#cancel_numberString

The cancellation number of an appointment. Used in response only.

Returns:

  • (String)


46
47
48
# File 'lib/usps_api/models/cancellation_response.rb', line 46

def cancel_number
  @cancel_number
end

#cancel_reason_codeCancelReasonCode1

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:



38
39
40
# File 'lib/usps_api/models/cancellation_response.rb', line 38

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_response.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_response.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_response.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_response.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_response.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.



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
123
124
125
126
127
128
129
# File 'lib/usps_api/models/cancellation_response.rb', line 94

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'
  cancel_number = hash.key?('cancelNumber') ? hash['cancelNumber'] : SKIP

  # 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.
  CancellationResponse.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,
                           cancel_number: cancel_number,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/usps_api/models/cancellation_response.rb', line 49

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['cancel_number'] = 'cancelNumber'
  @_hash
end

.nullablesObject

An array for nullable fields



71
72
73
# File 'lib/usps_api/models/cancellation_response.rb', line 71

def self.nullables
  []
end

.optionalsObject

An array for optional fields



63
64
65
66
67
68
# File 'lib/usps_api/models/cancellation_response.rb', line 63

def self.optionals
  %w[
    system_id
    cancel_number
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
147
148
149
150
# File 'lib/usps_api/models/cancellation_response.rb', line 142

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}, cancel_number: #{@cancel_number.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



132
133
134
135
136
137
138
139
# File 'lib/usps_api/models/cancellation_response.rb', line 132

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}, cancel_number:"\
  " #{@cancel_number}, additional_properties: #{@additional_properties}>"
end