Class: UspsApi::PickupErrorMessageErrorErrors

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

Overview

PickupErrorMessageErrorErrors Model.

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(status: SKIP, code: SKIP, title: SKIP, detail: SKIP, source: SKIP, additional_properties: nil) ⇒ PickupErrorMessageErrorErrors

Returns a new instance of PickupErrorMessageErrorErrors.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 60

def initialize(status: SKIP, code: SKIP, title: SKIP, detail: SKIP,
               source: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @status = status unless status == SKIP
  @code = code unless code == SKIP
  @title = title unless title == SKIP
  @detail = detail unless detail == SKIP
  @source = source unless source == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#codeString

An internal subordinate code used for error diagnosis.

Returns:

  • (String)


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

def code
  @code
end

#detailString

A human-readable description of the error that occurred.

Returns:

  • (String)


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

def detail
  @detail
end

#sourceSource

The element that is suspected of originating the error. Helps to pinpoint the problem.

Returns:



31
32
33
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 31

def source
  @source
end

#statusString

The status code response returned to the client.

Returns:

  • (String)


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

def status
  @status
end

#titleString

A human-readable title that identifies the error.

Returns:

  • (String)


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

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  status = hash.key?('status') ? hash['status'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP
  detail = hash.key?('detail') ? hash['detail'] : SKIP
  source = Source.from_hash(hash['source']) if hash['source']

  # 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.
  PickupErrorMessageErrorErrors.new(status: status,
                                    code: code,
                                    title: title,
                                    detail: detail,
                                    source: source,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['status'] = 'status'
  @_hash['code'] = 'code'
  @_hash['title'] = 'title'
  @_hash['detail'] = 'detail'
  @_hash['source'] = 'source'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
53
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 45

def self.optionals
  %w[
    status
    code
    title
    detail
    source
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



108
109
110
111
112
113
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 108

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} status: #{@status.inspect}, code: #{@code.inspect}, title:"\
  " #{@title.inspect}, detail: #{@detail.inspect}, source: #{@source.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
# File 'lib/usps_api/models/pickup_error_message_error_errors.rb', line 101

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} status: #{@status}, code: #{@code}, title: #{@title}, detail: #{@detail},"\
  " source: #{@source}, additional_properties: #{@additional_properties}>"
end