Class: FdxV660Api::PaymentEntityErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb

Overview

Represents a payment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ PaymentEntityErrorException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



79
80
81
82
83
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 79

def initialize(reason, response)
  super(reason, response)
  hash = APIHelper.json_deserialize(@response.raw_body)
  unbox(hash)
end

Instance Attribute Details

#amountFloat

Amount for the payment. Must be positive

Returns:

  • (Float)


28
29
30
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 28

def amount
  @amount
end

#cancelled_timestampDateTime

When the payment was cancelled

Returns:

  • (DateTime)


62
63
64
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 62

def cancelled_timestamp
  @cancelled_timestamp
end

#descriptionString

The purpose of the payment as provided by consumer or payment-requesting app

Returns:

  • (String)


24
25
26
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 24

def description
  @description
end

#due_dateDate

Date that the funds are scheduled to be delivered

Returns:

  • (Date)


36
37
38
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 36

def due_date
  @due_date
end

#failed_timestampDateTime

When the payment failed. Includes when the payment was determined to lack sufficient funds

Returns:

  • (DateTime)


58
59
60
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 58

def failed_timestamp
  @failed_timestamp
end

#from_account_idString

ID of the account used to source funds for payment

Returns:

  • (String)


15
16
17
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 15

def 
  @from_account_id
end

Links to related payment entities

Returns:



74
75
76
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 74

def links
  @links
end

#merchant_account_idString

User's account identifier with the merchant

Returns:

  • (String)


32
33
34
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 32

def 
  @merchant_account_id
end

#payment_idString

Uniquely identifies a payment. Used within the API to reference a payment

Returns:

  • (String)


40
41
42
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 40

def payment_id
  @payment_id
end

#processed_timestampDateTime

When the payment was processed

Returns:

  • (DateTime)


53
54
55
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 53

def processed_timestamp
  @processed_timestamp
end

#recurring_payment_idString

The recurring payment that spawned this payment. Null if payment is not associated with a recurring payment

Returns:

  • (String)


45
46
47
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 45

def recurring_payment_id
  @recurring_payment_id
end

#scheduled_timestampDateTime

When the payment was scheduled

Returns:

  • (DateTime)


49
50
51
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 49

def scheduled_timestamp
  @scheduled_timestamp
end

#started_processing_timestampDateTime

When the payment execution started

Returns:

  • (DateTime)


66
67
68
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 66

def started_processing_timestamp
  @started_processing_timestamp
end

#statusPaymentStatus3

Defines the status of the payment

Returns:



70
71
72
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 70

def status
  @status
end

#to_payee_idString

ID of the payee to receive funds for the payment

Returns:

  • (String)


19
20
21
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 19

def to_payee_id
  @to_payee_id
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 154

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} from_account_id: #{@from_account_id.inspect}, to_payee_id:"\
  " #{@to_payee_id.inspect}, description: #{@description.inspect}, amount: #{@amount.inspect},"\
  " merchant_account_id: #{@merchant_account_id.inspect}, due_date: #{@due_date.inspect},"\
  " payment_id: #{@payment_id.inspect}, recurring_payment_id:"\
  " #{@recurring_payment_id.inspect}, scheduled_timestamp: #{@scheduled_timestamp.inspect},"\
  " processed_timestamp: #{@processed_timestamp.inspect}, failed_timestamp:"\
  " #{@failed_timestamp.inspect}, cancelled_timestamp: #{@cancelled_timestamp.inspect},"\
  " started_processing_timestamp: #{@started_processing_timestamp.inspect}, status:"\
  " #{@status.inspect}, links: #{@links.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 141

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} from_account_id: #{@from_account_id}, to_payee_id: #{@to_payee_id},"\
  " description: #{@description}, amount: #{@amount}, merchant_account_id:"\
  " #{@merchant_account_id}, due_date: #{@due_date}, payment_id: #{@payment_id},"\
  " recurring_payment_id: #{@recurring_payment_id}, scheduled_timestamp:"\
  " #{@scheduled_timestamp}, processed_timestamp: #{@processed_timestamp}, failed_timestamp:"\
  " #{@failed_timestamp}, cancelled_timestamp: #{@cancelled_timestamp},"\
  " started_processing_timestamp: #{@started_processing_timestamp}, status: #{@status}, links:"\
  " #{@links}>"
end

#unbox(hash) ⇒ Object

Populates this object by extracting properties from a hash. response body.

Parameters:

  • hash (Hash)

    The deserialized response sent by the server in the



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
# File 'lib/fdx_v660_api/exceptions/payment_entity_error_exception.rb', line 88

def unbox(hash)
  return nil unless hash

  @from_account_id =
    hash.key?('fromAccountId') ? hash['fromAccountId'] : nil
  @to_payee_id = hash.key?('toPayeeId') ? hash['toPayeeId'] : nil
  @description = hash.key?('description') ? hash['description'] : SKIP
  @amount = hash.key?('amount') ? hash['amount'] : nil
  @merchant_account_id =
    hash.key?('merchantAccountId') ? hash['merchantAccountId'] : SKIP
  @due_date = hash.key?('dueDate') ? hash['dueDate'] : nil
  @payment_id = hash.key?('paymentId') ? hash['paymentId'] : nil
  @recurring_payment_id =
    hash.key?('recurringPaymentId') ? hash['recurringPaymentId'] : SKIP
  @scheduled_timestamp = if hash.key?('scheduledTimestamp')
                           (DateTimeHelper.from_rfc3339(hash['scheduledTimestamp']) if hash['scheduledTimestamp'])
                         else
                           SKIP
                         end
  @processed_timestamp = if hash.key?('processedTimestamp')
                           (DateTimeHelper.from_rfc3339(hash['processedTimestamp']) if hash['processedTimestamp'])
                         else
                           SKIP
                         end
  @failed_timestamp = if hash.key?('failedTimestamp')
                        (DateTimeHelper.from_rfc3339(hash['failedTimestamp']) if hash['failedTimestamp'])
                      else
                        SKIP
                      end
  @cancelled_timestamp = if hash.key?('cancelledTimestamp')
                           (DateTimeHelper.from_rfc3339(hash['cancelledTimestamp']) if hash['cancelledTimestamp'])
                         else
                           SKIP
                         end
  @started_processing_timestamp = if hash.key?('startedProcessingTimestamp')
                                    (DateTimeHelper.from_rfc3339(hash['startedProcessingTimestamp']) if hash['startedProcessingTimestamp'])
                                  else
                                    SKIP
                                  end
  @status = hash.key?('status') ? hash['status'] : nil
  # Parameter is an array, so we need to iterate through it
  @links = nil
  unless hash['links'].nil?
    @links = []
    hash['links'].each do |structure|
      @links << (HateoasLink.from_hash(structure) if structure)
    end
  end

  @links = SKIP unless hash.key?('links')
end