Class: UspsApi::ShipmentsPaymentAccount

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

Overview

Payment account information. Used only if ‘priceType` is `CONTRACT`.

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, additional_properties: nil) ⇒ ShipmentsPaymentAccount

Returns a new instance of ShipmentsPaymentAccount.



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

def initialize(account_type: SKIP, account_number: 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
  @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/shipments_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/shipments_payment_account.rb', line 19

def 
  @account_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/usps_api/models/shipments_payment_account.rb', line 58

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

  # 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.
  ShipmentsPaymentAccount.new(account_type: ,
                              account_number: ,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
# File 'lib/usps_api/models/shipments_payment_account.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_type'] = 'accountType'
  @_hash['account_number'] = 'accountNumber'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
40
# File 'lib/usps_api/models/shipments_payment_account.rb', line 35

def self.optionals
  %w[
    account_type
    account_number
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



80
81
82
83
84
85
86
# File 'lib/usps_api/models/shipments_payment_account.rb', line 80

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.



96
97
98
99
100
# File 'lib/usps_api/models/shipments_payment_account.rb', line 96

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_type: #{@account_type.inspect}, account_number:"\
  " #{@account_number.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
# File 'lib/usps_api/models/shipments_payment_account.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_type: #{@account_type}, account_number: #{@account_number},"\
  " additional_properties: #{@additional_properties}>"
end