Class: UspsApi::InterestedPartiesIdentityInformation

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

Overview

This block identifies all interested parties involved in 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(roles:, payment_authorization_token: SKIP, additional_properties: nil) ⇒ InterestedPartiesIdentityInformation

Returns a new instance of InterestedPartiesIdentityInformation.



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

def initialize(roles:, payment_authorization_token: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  unless payment_authorization_token == SKIP
    @payment_authorization_token =
      payment_authorization_token
  end
  @roles = roles
  @additional_properties = additional_properties
end

Instance Attribute Details

#payment_authorization_tokenString

The Payment Authorization Token is used in the labels and international-labels API calls to authorize payment, NSA contract Rates, and label MID ranges.

Returns:

  • (String)


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

def payment_authorization_token
  @payment_authorization_token
end

#rolesArray[TransactionRoles]

Each Role represents a participant in the transaction and must only be used once. The ‘LABEL_OWNER` Role must be specified. The `PAYER` role must be specified, unless following the PC Postage flow.

Returns:



22
23
24
# File 'lib/usps_api/models/interested_parties_identity_information.rb', line 22

def roles
  @roles
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
77
78
79
80
81
82
83
84
85
86
# File 'lib/usps_api/models/interested_parties_identity_information.rb', line 58

def self.from_hash(hash)
  return nil unless hash

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

  roles = nil unless hash.key?('roles')
  payment_authorization_token =
    hash.key?('paymentAuthorizationToken') ? hash['paymentAuthorizationToken'] : 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.
  InterestedPartiesIdentityInformation.new(roles: roles,
                                           payment_authorization_token: payment_authorization_token,
                                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
# File 'lib/usps_api/models/interested_parties_identity_information.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_authorization_token'] = 'paymentAuthorizationToken'
  @_hash['roles'] = 'roles'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/usps_api/models/interested_parties_identity_information.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
36
37
# File 'lib/usps_api/models/interested_parties_identity_information.rb', line 33

def self.optionals
  %w[
    payment_authorization_token
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} payment_authorization_token: #{@payment_authorization_token.inspect},"\
  " roles: #{@roles.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/interested_parties_identity_information.rb', line 89

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