Class: UspsApi::MgmtResponse

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

Overview

MgmtResponse 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(company_name: SKIP, address_line1: SKIP, address_line2: SKIP, address_line3: SKIP, city: SKIP, state: SKIP, zip_code: SKIP, urbanization: SKIP, apv_dispute_flag: SKIP, additional_properties: nil) ⇒ MgmtResponse

Returns a new instance of MgmtResponse.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/usps_api/models/mgmt_response.rb', line 84

def initialize(company_name: SKIP, address_line1: SKIP, address_line2: SKIP,
               address_line3: SKIP, city: SKIP, state: SKIP, zip_code: SKIP,
               urbanization: SKIP, apv_dispute_flag: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @company_name = company_name unless company_name == SKIP
  @address_line1 = address_line1 unless address_line1 == SKIP
  @address_line2 = address_line2 unless address_line2 == SKIP
  @address_line3 = address_line3 unless address_line3 == SKIP
  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @zip_code = zip_code unless zip_code == SKIP
  @urbanization = urbanization unless urbanization == SKIP
  @apv_dispute_flag = apv_dispute_flag unless apv_dispute_flag == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address_line1String

Primary address line for the account.

Returns:

  • (String)


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

def address_line1
  @address_line1
end

#address_line2String

Secondary address line for the account, if applicable.

Returns:

  • (String)


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

def address_line2
  @address_line2
end

#address_line3String

Additional address line for the account, if applicable.

Returns:

  • (String)


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

def address_line3
  @address_line3
end

#apv_dispute_flagBusiness

Indicates if an Automated Package Verification (APV) dispute is allowed. ‘Y’ for yes, ‘N’ for no.

Returns:



47
48
49
# File 'lib/usps_api/models/mgmt_response.rb', line 47

def apv_dispute_flag
  @apv_dispute_flag
end

#cityString

City of the account address.

Returns:

  • (String)


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

def city
  @city
end

#company_nameString

Name of the company associated with the account.

Returns:

  • (String)


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

def company_name
  @company_name
end

#stateString

This is the two-character state code of the address.

Returns:

  • (String)


34
35
36
# File 'lib/usps_api/models/mgmt_response.rb', line 34

def state
  @state
end

#urbanizationString

Urbanization information for the address, if applicable.

Returns:

  • (String)


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

def urbanization
  @urbanization
end

#zip_codeString

This is the 9-digit ZIP code in the format ‘12345-6789’.

Returns:

  • (String)


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

def zip_code
  @zip_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
130
131
132
133
134
135
136
137
# File 'lib/usps_api/models/mgmt_response.rb', line 104

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  company_name = hash.key?('companyName') ? hash['companyName'] : SKIP
  address_line1 = hash.key?('addressLine1') ? hash['addressLine1'] : SKIP
  address_line2 = hash.key?('addressLine2') ? hash['addressLine2'] : SKIP
  address_line3 = hash.key?('addressLine3') ? hash['addressLine3'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  zip_code = hash.key?('ZIPCode') ? hash['ZIPCode'] : SKIP
  urbanization = hash.key?('urbanization') ? hash['urbanization'] : SKIP
  apv_dispute_flag =
    hash.key?('APVDisputeFlag') ? hash['APVDisputeFlag'] : 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.
  MgmtResponse.new(company_name: company_name,
                   address_line1: address_line1,
                   address_line2: address_line2,
                   address_line3: address_line3,
                   city: city,
                   state: state,
                   zip_code: zip_code,
                   urbanization: urbanization,
                   apv_dispute_flag: apv_dispute_flag,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['company_name'] = 'companyName'
  @_hash['address_line1'] = 'addressLine1'
  @_hash['address_line2'] = 'addressLine2'
  @_hash['address_line3'] = 'addressLine3'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['zip_code'] = 'ZIPCode'
  @_hash['urbanization'] = 'urbanization'
  @_hash['apv_dispute_flag'] = 'APVDisputeFlag'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
# File 'lib/usps_api/models/mgmt_response.rb', line 80

def self.nullables
  []
end

.optionalsObject

An array for optional fields



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/usps_api/models/mgmt_response.rb', line 65

def self.optionals
  %w[
    company_name
    address_line1
    address_line2
    address_line3
    city
    state
    zip_code
    urbanization
    apv_dispute_flag
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



149
150
151
152
153
154
155
156
# File 'lib/usps_api/models/mgmt_response.rb', line 149

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} company_name: #{@company_name.inspect}, address_line1:"\
  " #{@address_line1.inspect}, address_line2: #{@address_line2.inspect}, address_line3:"\
  " #{@address_line3.inspect}, city: #{@city.inspect}, state: #{@state.inspect}, zip_code:"\
  " #{@zip_code.inspect}, urbanization: #{@urbanization.inspect}, apv_dispute_flag:"\
  " #{@apv_dispute_flag.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



140
141
142
143
144
145
146
# File 'lib/usps_api/models/mgmt_response.rb', line 140

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} company_name: #{@company_name}, address_line1: #{@address_line1},"\
  " address_line2: #{@address_line2}, address_line3: #{@address_line3}, city: #{@city}, state:"\
  " #{@state}, zip_code: #{@zip_code}, urbanization: #{@urbanization}, apv_dispute_flag:"\
  " #{@apv_dispute_flag}, additional_properties: #{@additional_properties}>"
end