Class: UspsApi::PaymentAccount
- Defined in:
- lib/usps_api/models/payment_account.rb
Overview
The total amount to be charged for the shipment
Instance Attribute Summary collapse
-
#account_number ⇒ String
The Enterprise Payment Account, Permit number, Mailer ID (MID), or PC Postage meter number associated with a contract.
-
#account_type ⇒ AccountType
The type of payment account.
-
#crid ⇒ String
Customer Registration ID (CRID) associated with the business or mailer.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(account_type: SKIP, account_number: SKIP, crid: SKIP, additional_properties: nil) ⇒ PaymentAccount
constructor
A new instance of PaymentAccount.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(account_type: SKIP, account_number: SKIP, crid: SKIP, additional_properties: nil) ⇒ PaymentAccount
Returns a new instance of PaymentAccount.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/usps_api/models/payment_account.rb', line 54 def initialize(account_type: SKIP, account_number: SKIP, crid: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @account_type = account_type unless account_type == SKIP @account_number = account_number unless account_number == SKIP @crid = crid unless crid == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#account_number ⇒ String
The Enterprise Payment Account, Permit number, Mailer ID (MID), or PC Postage meter number associated with a contract.
24 25 26 |
# File 'lib/usps_api/models/payment_account.rb', line 24 def account_number @account_number end |
#account_type ⇒ AccountType
The type of payment account. Note:
-
‘EPS`, `PERMIT`, and `METER` are only available for Outbound Mail
Classes.
-
‘METER` is only available to PC Postage Providers.
-
‘MID` is only available for Return Mail Classes.
19 20 21 |
# File 'lib/usps_api/models/payment_account.rb', line 19 def account_type @account_type end |
#crid ⇒ String
Customer Registration ID (CRID) associated with the business or mailer. Used to retrieve any contract-specific service standards.
29 30 31 |
# File 'lib/usps_api/models/payment_account.rb', line 29 def crid @crid end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/usps_api/models/payment_account.rb', line 66 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. account_type = hash.key?('accountType') ? hash['accountType'] : SKIP account_number = hash.key?('accountNumber') ? hash['accountNumber'] : SKIP crid = hash.key?('CRID') ? hash['CRID'] : 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. PaymentAccount.new(account_type: account_type, account_number: account_number, crid: crid, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
32 33 34 35 36 37 38 |
# File 'lib/usps_api/models/payment_account.rb', line 32 def self.names @_hash = {} if @_hash.nil? @_hash['account_type'] = 'accountType' @_hash['account_number'] = 'accountNumber' @_hash['crid'] = 'CRID' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/usps_api/models/payment_account.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
41 42 43 44 45 46 47 |
# File 'lib/usps_api/models/payment_account.rb', line 41 def self.optionals %w[ account_type account_number crid ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
90 91 92 93 94 95 96 |
# File 'lib/usps_api/models/payment_account.rb', line 90 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
106 107 108 109 110 111 |
# File 'lib/usps_api/models/payment_account.rb', line 106 def inspect class_name = self.class.name.split('::').last "<#{class_name} account_type: #{@account_type.inspect}, account_number:"\ " #{@account_number.inspect}, crid: #{@crid.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
99 100 101 102 103 |
# File 'lib/usps_api/models/payment_account.rb', line 99 def to_s class_name = self.class.name.split('::').last "<#{class_name} account_type: #{@account_type}, account_number: #{@account_number}, crid:"\ " #{@crid}, additional_properties: #{@additional_properties}>" end |