Class: UspsApi::ChangeOfAddressSearchRequest

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

Overview

User information to search for old and new address records

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(crid:, license_id:, request_type:, mailer_list_id: SKIP, mailer_list: SKIP, name_addresses: SKIP, number_of_months: SKIP) ⇒ ChangeOfAddressSearchRequest

Returns a new instance of ChangeOfAddressSearchRequest.



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 76

def initialize(crid:, license_id:, request_type:, mailer_list_id: SKIP,
               mailer_list: SKIP, name_addresses: SKIP,
               number_of_months: SKIP)
  @crid = crid
  @license_id = license_id
  @request_type = request_type
  @mailer_list_id = mailer_list_id unless mailer_list_id == SKIP
  @mailer_list = mailer_list unless mailer_list == SKIP
  @name_addresses = name_addresses unless name_addresses == SKIP
  @number_of_months = number_of_months unless number_of_months == SKIP
end

Instance Attribute Details

#cridString

ID used to identify Customers registered to use Web Service. It represents a business at a location.

Returns:

  • (String)


15
16
17
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 15

def crid
  @crid
end

#license_idString

License ID used to identify Customers with an NCOA+ license.

Returns:

  • (String)


19
20
21
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 19

def license_id
  @license_id
end

#mailer_listTheMailerListInformation

The object that hold all the properties for Mailer List information.



33
34
35
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 33

def mailer_list
  @mailer_list
end

#mailer_list_idString

Mailer List ID signifies the Customer/BALA/End User (List Owner) for whom the request is made. BALA is a broker, agent, or list administrator.

Returns:

  • (String)


29
30
31
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 29

def mailer_list_id
  @mailer_list_id
end

#name_addressesArray[NcoaDataServicesTheAddresseeInformation]

List of Name Addresses to search in the batch



37
38
39
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 37

def name_addresses
  @name_addresses
end

#number_of_monthsInteger

Number of Months for the request 1 THROUGH 48. Minimum of 1 month & Maximum of 48 months.

Returns:

  • (Integer)


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

def number_of_months
  @number_of_months
end

#request_typeString

RequestType indicates which action you want performed a MailerInsert or Search

Returns:

  • (String)


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

def request_type
  @request_type
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
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 89

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  crid = hash.key?('CRID') ? hash['CRID'] : nil
  license_id = hash.key?('licenseID') ? hash['licenseID'] : nil
  request_type = hash.key?('requestType') ? hash['requestType'] : nil
  mailer_list_id = hash.key?('mailerListID') ? hash['mailerListID'] : SKIP
  mailer_list = TheMailerListInformation.from_hash(hash['mailerList']) if hash['mailerList']
  # Parameter is an array, so we need to iterate through it
  name_addresses = nil
  unless hash['nameAddresses'].nil?
    name_addresses = []
    hash['nameAddresses'].each do |structure|
      name_addresses << (NcoaDataServicesTheAddresseeInformation.from_hash(structure) if structure)
    end
  end

  name_addresses = SKIP unless hash.key?('nameAddresses')
  number_of_months =
    hash.key?('numberOfMonths') ? hash['numberOfMonths'] : SKIP

  # Create object from extracted values.
  ChangeOfAddressSearchRequest.new(crid: crid,
                                   license_id: license_id,
                                   request_type: request_type,
                                   mailer_list_id: mailer_list_id,
                                   mailer_list: mailer_list,
                                   name_addresses: name_addresses,
                                   number_of_months: number_of_months)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['crid'] = 'CRID'
  @_hash['license_id'] = 'licenseID'
  @_hash['request_type'] = 'requestType'
  @_hash['mailer_list_id'] = 'mailerListID'
  @_hash['mailer_list'] = 'mailerList'
  @_hash['name_addresses'] = 'nameAddresses'
  @_hash['number_of_months'] = 'numberOfMonths'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
71
72
73
74
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 68

def self.nullables
  %w[
    crid
    license_id
    request_type
  ]
end

.optionalsObject

An array for optional fields



58
59
60
61
62
63
64
65
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 58

def self.optionals
  %w[
    mailer_list_id
    mailer_list
    name_addresses
    number_of_months
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



130
131
132
133
134
135
136
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 130

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} crid: #{@crid.inspect}, license_id: #{@license_id.inspect}, request_type:"\
  " #{@request_type.inspect}, mailer_list_id: #{@mailer_list_id.inspect}, mailer_list:"\
  " #{@mailer_list.inspect}, name_addresses: #{@name_addresses.inspect}, number_of_months:"\
  " #{@number_of_months.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
127
# File 'lib/usps_api/models/change_of_address_search_request.rb', line 122

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} crid: #{@crid}, license_id: #{@license_id}, request_type: #{@request_type},"\
  " mailer_list_id: #{@mailer_list_id}, mailer_list: #{@mailer_list}, name_addresses:"\
  " #{@name_addresses}, number_of_months: #{@number_of_months}>"
end