Class: UspsApi::PaymentAccounts

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

Overview

A list of payment accounts which have been authorized by the USPS customer for use by the third-party application for payment of USPS goods and services. An EPS payment account or a permit may be used for payment.

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(accounts: SKIP, permits: SKIP) ⇒ PaymentAccounts

Returns a new instance of PaymentAccounts.



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

def initialize(accounts: SKIP, permits: SKIP)
  @accounts = accounts unless accounts == SKIP
  @permits = permits unless permits == SKIP
end

Instance Attribute Details

#accountsString

A list of EPS payment account identifiers.

Returns:

  • (String)


16
17
18
# File 'lib/usps_api/models/payment_accounts.rb', line 16

def accounts
  @accounts
end

#permitsArray[PermitNumber]

A list of permit numbers, each assigned to a ZIP code.

Returns:



20
21
22
# File 'lib/usps_api/models/payment_accounts.rb', line 20

def permits
  @permits
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/usps_api/models/payment_accounts.rb', line 49

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  accounts = hash.key?('accounts') ? hash['accounts'] : SKIP
  # Parameter is an array, so we need to iterate through it
  permits = nil
  unless hash['permits'].nil?
    permits = []
    hash['permits'].each do |structure|
      permits << (PermitNumber.from_hash(structure) if structure)
    end
  end

  permits = SKIP unless hash.key?('permits')

  # Create object from extracted values.
  PaymentAccounts.new(accounts: accounts,
                      permits: permits)
end

.namesObject

A mapping from model property names to API property names.



23
24
25
26
27
28
# File 'lib/usps_api/models/payment_accounts.rb', line 23

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['accounts'] = 'accounts'
  @_hash['permits'] = 'permits'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



31
32
33
34
35
36
# File 'lib/usps_api/models/payment_accounts.rb', line 31

def self.optionals
  %w[
    accounts
    permits
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



77
78
79
80
# File 'lib/usps_api/models/payment_accounts.rb', line 77

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} accounts: #{@accounts.inspect}, permits: #{@permits.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



71
72
73
74
# File 'lib/usps_api/models/payment_accounts.rb', line 71

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} accounts: #{@accounts}, permits: #{@permits}>"
end