Class: UspsApi::TransactionRoles

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

Overview

Role each party plays in the transaction

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(role_name: SKIP, crid: SKIP, mid: SKIP, manifest_mid: SKIP, account_type: SKIP, account_number: SKIP, permit_number: SKIP, permit_zip: SKIP, non_profit_status: SKIP, sufficient_funds: SKIP, additional_properties: nil) ⇒ TransactionRoles

Returns a new instance of TransactionRoles.



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/usps_api/models/transaction_roles.rb', line 124

def initialize(role_name: SKIP, crid: SKIP, mid: SKIP, manifest_mid: SKIP,
               account_type: SKIP, account_number: SKIP,
               permit_number: SKIP, permit_zip: SKIP,
               non_profit_status: SKIP, sufficient_funds: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @role_name = role_name unless role_name == SKIP
  @crid = crid unless crid == SKIP
  @mid = mid unless mid == SKIP
  @manifest_mid = manifest_mid unless manifest_mid == SKIP
  @account_type =  unless  == SKIP
  @account_number =  unless  == SKIP
  @permit_number = permit_number unless permit_number == SKIP
  @permit_zip = permit_zip unless permit_zip == SKIP
  @non_profit_status = non_profit_status unless non_profit_status == SKIP
  @sufficient_funds = sufficient_funds unless sufficient_funds == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_numberString

The Enterprise Payment Account number or PC Postage meter number to use for payment. Required when ‘accountType` is `EPS` or `METER`.

Returns:

  • (String)


64
65
66
# File 'lib/usps_api/models/transaction_roles.rb', line 64

def 
  @account_number
end

#account_typeAccountType2

The type of payment account. METER pricing is only available to PC Postage providers.

Returns:



59
60
61
# File 'lib/usps_api/models/transaction_roles.rb', line 59

def 
  @account_type
end

#cridString

A Customer Registration Identification number (CRID) is a USPS-generated numeric code that uniquely identifies a business at a location.

Returns:

  • (String)


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

def crid
  @crid
end

#manifest_midString

The unique mailer identifier designated for the manifest.

Returns:

  • (String)


54
55
56
# File 'lib/usps_api/models/transaction_roles.rb', line 54

def manifest_mid
  @manifest_mid
end

#midString

The Mailer Identifier (MID) is a field within the Intelligent Mail barcode that is used to identify mailers. MIDs are assigned by the USPS® to a Mail Owner, Mailing Agent or other service providers who request them.

Returns:

  • (String)


50
51
52
# File 'lib/usps_api/models/transaction_roles.rb', line 50

def mid
  @mid
end

#non_profit_statusTrueClass | FalseClass

This status is applicable only for permits and indicates whether the permit has been issued to a non-profit organization.

Returns:

  • (TrueClass | FalseClass)


79
80
81
# File 'lib/usps_api/models/transaction_roles.rb', line 79

def non_profit_status
  @non_profit_status
end

#permit_numberString

The permit number or Federal Agency Number to use for payment. Required when ‘accountType` is `PERMIT` or `OMAS`.

Returns:

  • (String)


69
70
71
# File 'lib/usps_api/models/transaction_roles.rb', line 69

def permit_number
  @permit_number
end

#permit_zipString

The ZIP Code™ associated to the permit number. Required when ‘accountType` is `PERMIT` or `OMAS`.

Returns:

  • (String)


74
75
76
# File 'lib/usps_api/models/transaction_roles.rb', line 74

def permit_zip
  @permit_zip
end

#role_nameRoleName

  • PAYER - Payer of the Postage

  • RATE_HOLDER - Owner of the Contracted Postage Rates

  • LABEL_OWNER - Party supplying Label MIDs used for generating tracking

numbers printed on physical label

  • SHIPPER - Party entering package into the mailstream

  • PLATFORM - Platform used

  • RETURN_LABEL_PAYER - Payer of the Postage for the return label in a

combined outbound/return request. Optional if outbound and return label payer are the same.

  • RETURN_LABEL_RATE_HOLDER - Owner of the Contracted Postage Rates for the

return label in a combined outbound/return request. Optional if outbound and return label rate holder are the same.

  • RETURN_LABEL_OWNER - Party supplying Label MIDs used for generating

tracking numbers printed on physical label for the return label in a combined outbound/return request. Optional if outbound and return label owner are the same.

  • MAIL_OWNER - This role is used to specify who owns the package contents.

When using the MAIL_OWNER role, the CRID must be specified. This does not populate the mail owner field in the D1 record of the Shipping Service File (SSF). Please use the ‘packageDescription.mailerOwnerMID` field to populate the D1 field.

  • LABEL_PROVIDER - This role is used to specify the label provider for the

transaction. When using the LABEL_PROVIDER role, the CRID, accountNumber, and accountType must be specified and the only supported accountType is ‘EPS’. The accountNumber must be active in the Enterprise Payment System (EPS).

Returns:



39
40
41
# File 'lib/usps_api/models/transaction_roles.rb', line 39

def role_name
  @role_name
end

#sufficient_fundsTrueClass | FalseClass

This attribute is relevant only when an amount parameter is provided, and it informs the API caller whether the payment account holds sufficient funds to process the payment.

Returns:

  • (TrueClass | FalseClass)


85
86
87
# File 'lib/usps_api/models/transaction_roles.rb', line 85

def sufficient_funds
  @sufficient_funds
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/usps_api/models/transaction_roles.rb', line 146

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  role_name = hash.key?('roleName') ? hash['roleName'] : SKIP
  crid = hash.key?('CRID') ? hash['CRID'] : SKIP
  mid = hash.key?('MID') ? hash['MID'] : SKIP
  manifest_mid = hash.key?('manifestMID') ? hash['manifestMID'] : SKIP
   = hash.key?('accountType') ? hash['accountType'] : SKIP
   = hash.key?('accountNumber') ? hash['accountNumber'] : SKIP
  permit_number = hash.key?('permitNumber') ? hash['permitNumber'] : SKIP
  permit_zip = hash.key?('permitZIP') ? hash['permitZIP'] : SKIP
  non_profit_status =
    hash.key?('nonProfitStatus') ? hash['nonProfitStatus'] : SKIP
  sufficient_funds =
    hash.key?('sufficientFunds') ? hash['sufficientFunds'] : 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.
  TransactionRoles.new(role_name: role_name,
                       crid: crid,
                       mid: mid,
                       manifest_mid: manifest_mid,
                       account_type: ,
                       account_number: ,
                       permit_number: permit_number,
                       permit_zip: permit_zip,
                       non_profit_status: non_profit_status,
                       sufficient_funds: sufficient_funds,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['role_name'] = 'roleName'
  @_hash['crid'] = 'CRID'
  @_hash['mid'] = 'MID'
  @_hash['manifest_mid'] = 'manifestMID'
  @_hash['account_type'] = 'accountType'
  @_hash['account_number'] = 'accountNumber'
  @_hash['permit_number'] = 'permitNumber'
  @_hash['permit_zip'] = 'permitZIP'
  @_hash['non_profit_status'] = 'nonProfitStatus'
  @_hash['sufficient_funds'] = 'sufficientFunds'
  @_hash
end

.nullablesObject

An array for nullable fields



120
121
122
# File 'lib/usps_api/models/transaction_roles.rb', line 120

def self.nullables
  []
end

.optionalsObject

An array for optional fields



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/usps_api/models/transaction_roles.rb', line 104

def self.optionals
  %w[
    role_name
    crid
    mid
    manifest_mid
    account_type
    account_number
    permit_number
    permit_zip
    non_profit_status
    sufficient_funds
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



195
196
197
198
199
200
201
202
203
# File 'lib/usps_api/models/transaction_roles.rb', line 195

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} role_name: #{@role_name.inspect}, crid: #{@crid.inspect}, mid:"\
  " #{@mid.inspect}, manifest_mid: #{@manifest_mid.inspect}, account_type:"\
  " #{@account_type.inspect}, account_number: #{@account_number.inspect}, permit_number:"\
  " #{@permit_number.inspect}, permit_zip: #{@permit_zip.inspect}, non_profit_status:"\
  " #{@non_profit_status.inspect}, sufficient_funds: #{@sufficient_funds.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



185
186
187
188
189
190
191
192
# File 'lib/usps_api/models/transaction_roles.rb', line 185

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} role_name: #{@role_name}, crid: #{@crid}, mid: #{@mid}, manifest_mid:"\
  " #{@manifest_mid}, account_type: #{@account_type}, account_number: #{@account_number},"\
  " permit_number: #{@permit_number}, permit_zip: #{@permit_zip}, non_profit_status:"\
  " #{@non_profit_status}, sufficient_funds: #{@sufficient_funds}, additional_properties:"\
  " #{@additional_properties}>"
end