Class: UspsApi::PaymentAccount

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

Overview

The total amount to be charged for the shipment

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(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 =  unless  == SKIP
  @account_number =  unless  == SKIP
  @crid = crid unless crid == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_numberString

The Enterprise Payment Account, Permit number, Mailer ID (MID), or PC Postage meter number associated with a contract.

Returns:

  • (String)


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

def 
  @account_number
end

#account_typeAccountType

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.

Returns:



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

def 
  @account_type
end

#cridString

Customer Registration ID (CRID) associated with the business or mailer. Used to retrieve any contract-specific service standards.

Returns:

  • (String)


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.
   = hash.key?('accountType') ? hash['accountType'] : SKIP
   = 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_number: ,
                     crid: crid,
                     additional_properties: additional_properties)
end

.namesObject

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

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

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.

Parameters:

  • The (PaymentAccount | Hash)

    value against the validation is performed.



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

#inspectObject

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_sObject

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