Class: UspsApi::NonLabelFeeDetails

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

Overview

Details on package transaction details that will be or have been issued to a customer account. Fields will only be provided if they differed from the original manifested data.

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(description: 'Non-label account-level fee (IMPB noncompliance, postage adjustment, ad-hoc, etc), can include three types listed below', idempotency_key: SKIP, transaction_type: SKIP, payment_transaction_type: SKIP, fee_type: SKIP, account_number: SKIP, transmission_date: SKIP, transaction_date_time: SKIP, transaction_amount: SKIP) ⇒ NonLabelFeeDetails

Returns a new instance of NonLabelFeeDetails.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/usps_api/models/non_label_fee_details.rb', line 86

def initialize(
  description: 'Non-label account-level fee (IMPB noncompliance, postage adjustment, ad-hoc, etc), can include three types listed below',
  idempotency_key: SKIP, transaction_type: SKIP,
  payment_transaction_type: SKIP, fee_type: SKIP, account_number: SKIP,
  transmission_date: SKIP, transaction_date_time: SKIP,
  transaction_amount: SKIP
)
  @description = description unless description == SKIP
  @idempotency_key = idempotency_key unless idempotency_key == SKIP
  @transaction_type = transaction_type unless transaction_type == SKIP
  @payment_transaction_type = payment_transaction_type unless payment_transaction_type == SKIP
  @fee_type = fee_type unless fee_type == SKIP
  @account_number =  unless  == SKIP
  @transmission_date = transmission_date unless transmission_date == SKIP
  @transaction_date_time = transaction_date_time unless transaction_date_time == SKIP
  @transaction_amount = transaction_amount unless transaction_amount == SKIP
end

Instance Attribute Details

#account_numberString

The Enterprise Payment Account the adjustment was charged to.

Returns:

  • (String)


37
38
39
# File 'lib/usps_api/models/non_label_fee_details.rb', line 37

def 
  @account_number
end

#descriptionString

Description of the non-label fee assessed to the package.

Returns:

  • (String)


17
18
19
# File 'lib/usps_api/models/non_label_fee_details.rb', line 17

def description
  @description
end

#fee_typeString

Fee type for the non-label fee assessed to the package

Returns:

  • (String)


33
34
35
# File 'lib/usps_api/models/non_label_fee_details.rb', line 33

def fee_type
  @fee_type
end

#idempotency_keyString

Unique idempotency key for the non-label fee assessed to the package

Returns:

  • (String)


21
22
23
# File 'lib/usps_api/models/non_label_fee_details.rb', line 21

def idempotency_key
  @idempotency_key
end

#payment_transaction_typePaymentTransactionType

Payment transaction type for the non-label fee assessed to the package



29
30
31
# File 'lib/usps_api/models/non_label_fee_details.rb', line 29

def payment_transaction_type
  @payment_transaction_type
end

#transaction_amountFloat

Transaction amount for the non-label fee

Returns:

  • (Float)


49
50
51
# File 'lib/usps_api/models/non_label_fee_details.rb', line 49

def transaction_amount
  @transaction_amount
end

#transaction_date_timeDateTime

Combination of Date Of Mailing and Time Of Mailing YYYYMMDD + HHMMSS

Returns:

  • (DateTime)


45
46
47
# File 'lib/usps_api/models/non_label_fee_details.rb', line 45

def transaction_date_time
  @transaction_date_time
end

#transaction_typeTransactionType

Type of transaction for the non-label fee assessed to the package

Returns:



25
26
27
# File 'lib/usps_api/models/non_label_fee_details.rb', line 25

def transaction_type
  @transaction_type
end

#transmission_dateDateTime

Earliest Datetime USPS scanned the package.

Returns:

  • (DateTime)


41
42
43
# File 'lib/usps_api/models/non_label_fee_details.rb', line 41

def transmission_date
  @transmission_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/usps_api/models/non_label_fee_details.rb', line 105

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  description =
    hash['description'] ||= 'Non-label account-level fee (IMPB noncompliance, postage adjustment, ad-hoc, etc), can include three types listed below'
  idempotency_key =
    hash.key?('idempotencyKey') ? hash['idempotencyKey'] : SKIP
  transaction_type =
    hash.key?('transactionType') ? hash['transactionType'] : SKIP
  payment_transaction_type =
    hash.key?('paymentTransactionType') ? hash['paymentTransactionType'] : SKIP
  fee_type = hash.key?('feeType') ? hash['feeType'] : SKIP
   = hash.key?('accountNumber') ? hash['accountNumber'] : SKIP
  transmission_date = if hash.key?('transmissionDate')
                        (DateTimeHelper.from_rfc3339(hash['transmissionDate']) if hash['transmissionDate'])
                      else
                        SKIP
                      end
  transaction_date_time = if hash.key?('transactionDateTime')
                            (DateTimeHelper.from_rfc3339(hash['transactionDateTime']) if hash['transactionDateTime'])
                          else
                            SKIP
                          end
  transaction_amount =
    hash.key?('transactionAmount') ? hash['transactionAmount'] : SKIP

  # Create object from extracted values.
  NonLabelFeeDetails.new(description: description,
                         idempotency_key: idempotency_key,
                         transaction_type: transaction_type,
                         payment_transaction_type: payment_transaction_type,
                         fee_type: fee_type,
                         account_number: ,
                         transmission_date: transmission_date,
                         transaction_date_time: transaction_date_time,
                         transaction_amount: transaction_amount)
end

.namesObject

A mapping from model property names to API property names.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/usps_api/models/non_label_fee_details.rb', line 52

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['description'] = 'description'
  @_hash['idempotency_key'] = 'idempotencyKey'
  @_hash['transaction_type'] = 'transactionType'
  @_hash['payment_transaction_type'] = 'paymentTransactionType'
  @_hash['fee_type'] = 'feeType'
  @_hash['account_number'] = 'accountNumber'
  @_hash['transmission_date'] = 'transmissionDate'
  @_hash['transaction_date_time'] = 'transactionDateTime'
  @_hash['transaction_amount'] = 'transactionAmount'
  @_hash
end

.nullablesObject

An array for nullable fields



82
83
84
# File 'lib/usps_api/models/non_label_fee_details.rb', line 82

def self.nullables
  []
end

.optionalsObject

An array for optional fields



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/usps_api/models/non_label_fee_details.rb', line 67

def self.optionals
  %w[
    description
    idempotency_key
    transaction_type
    payment_transaction_type
    fee_type
    account_number
    transmission_date
    transaction_date_time
    transaction_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



163
164
165
166
167
168
169
170
171
# File 'lib/usps_api/models/non_label_fee_details.rb', line 163

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description.inspect}, idempotency_key:"\
  " #{@idempotency_key.inspect}, transaction_type: #{@transaction_type.inspect},"\
  " payment_transaction_type: #{@payment_transaction_type.inspect}, fee_type:"\
  " #{@fee_type.inspect}, account_number: #{@account_number.inspect}, transmission_date:"\
  " #{@transmission_date.inspect}, transaction_date_time: #{@transaction_date_time.inspect},"\
  " transaction_amount: #{@transaction_amount.inspect}>"
end

#to_custom_transaction_date_timeObject



148
149
150
# File 'lib/usps_api/models/non_label_fee_details.rb', line 148

def to_custom_transaction_date_time
  DateTimeHelper.to_rfc3339(transaction_date_time)
end

#to_custom_transmission_dateObject



144
145
146
# File 'lib/usps_api/models/non_label_fee_details.rb', line 144

def to_custom_transmission_date
  DateTimeHelper.to_rfc3339(transmission_date)
end

#to_sObject

Provides a human-readable string representation of the object.



153
154
155
156
157
158
159
160
# File 'lib/usps_api/models/non_label_fee_details.rb', line 153

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description}, idempotency_key: #{@idempotency_key},"\
  " transaction_type: #{@transaction_type}, payment_transaction_type:"\
  " #{@payment_transaction_type}, fee_type: #{@fee_type}, account_number: #{@account_number},"\
  " transmission_date: #{@transmission_date}, transaction_date_time:"\
  " #{@transaction_date_time}, transaction_amount: #{@transaction_amount}>"
end