Class: CyberSourceMergedSpec::BuyerHistory

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/buyer_history.rb

Overview

BuyerHistory Model.

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(customer_account: SKIP, account_history: SKIP, account_purchases: SKIP, add_card_attempts: SKIP, prior_suspicious_activity: SKIP, payment_account_history: SKIP, payment_account_date: SKIP, transaction_count_day: SKIP, transaction_count_year: SKIP, additional_properties: nil) ⇒ BuyerHistory

Returns a new instance of BuyerHistory.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 95

def initialize(customer_account: SKIP, account_history: SKIP,
               account_purchases: SKIP, add_card_attempts: SKIP,
               prior_suspicious_activity: SKIP,
               payment_account_history: SKIP, payment_account_date: SKIP,
               transaction_count_day: SKIP, transaction_count_year: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @customer_account =  unless  == SKIP
  @account_history =  unless  == SKIP
  @account_purchases =  unless  == SKIP
  @add_card_attempts = add_card_attempts unless add_card_attempts == SKIP
  unless prior_suspicious_activity == SKIP
    @prior_suspicious_activity =
      prior_suspicious_activity
  end
  @payment_account_history =  unless  == SKIP
  @payment_account_date =  unless  == SKIP
  @transaction_count_day = transaction_count_day unless transaction_count_day == SKIP
  @transaction_count_year = transaction_count_year unless transaction_count_year == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_historyAccountHistory

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 18

def 
  @account_history
end

#account_purchasesInteger

Number of purchases with this cardholder account during the previous six months. Recommended for Discover ProtectBuy.

Returns:

  • (Integer)


24
25
26
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 24

def 
  @account_purchases
end

#add_card_attemptsInteger

Number of add card attempts in the last 24 hours. Recommended for Discover ProtectBuy.

Returns:

  • (Integer)


29
30
31
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 29

def add_card_attempts
  @add_card_attempts
end

#customer_accountCustomerAccount

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 14

def 
  @customer_account
end

#payment_account_dateInteger

Date applicable only for PAYMENT_ACCOUNT_EXISTS in paymentAccountHistory

Returns:

  • (Integer)


46
47
48
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 46

def 
  @payment_account_date
end

#payment_account_historyString

This only applies for NEW_ACCOUNT and EXISTING_ACCOUNT in creationHistory. Possible values are:

  • PAYMENT_ACCOUNT_EXISTS
  • PAYMENT_ACCOUNT_ADDED_NOW

Returns:

  • (String)


42
43
44
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 42

def 
  @payment_account_history
end

#prior_suspicious_activityTrueClass | FalseClass

Indicates whether the merchant experienced suspicious activity (including previous fraud) on the account. Recommended for Discover ProtectBuy.

Returns:

  • (TrueClass | FalseClass)


35
36
37
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 35

def prior_suspicious_activity
  @prior_suspicious_activity
end

#transaction_count_dayInteger

Number of transaction (successful or abandoned) for this cardholder account within the last 24 hours. Recommended for Discover ProtectBuy.

Returns:

  • (Integer)


52
53
54
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 52

def transaction_count_day
  @transaction_count_day
end

#transaction_count_yearInteger

Number of transaction (successful or abandoned) for this cardholder account within the last year. Recommended for Discover ProtectBuy.

Returns:

  • (Integer)


58
59
60
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 58

def transaction_count_year
  @transaction_count_year
end

Class Method Details

.from_element(root) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 162

def self.from_element(root)
   = XmlUtilities.from_element(root, 'CustomerAccount',
                                               CustomerAccount)
   = XmlUtilities.from_element(root, 'AccountHistory',
                                              AccountHistory)
   = XmlUtilities.from_element(root, 'accountPurchases',
                                                Integer)
  add_card_attempts = XmlUtilities.from_element(root, 'addCardAttempts',
                                                Integer)
  prior_suspicious_activity = XmlUtilities.from_element(
    root, 'priorSuspiciousActivity', TrueClass
  )
   = XmlUtilities.from_element(
    root, 'paymentAccountHistory', String
  )
   = XmlUtilities.from_element(root,
                                                   'paymentAccountDate',
                                                   Integer)
  transaction_count_day = XmlUtilities.from_element(root,
                                                    'transactionCountDay',
                                                    Integer)
  transaction_count_year = XmlUtilities.from_element(root,
                                                     'transactionCountYear',
                                                     Integer)

  new(customer_account: ,
      account_history: ,
      account_purchases: ,
      add_card_attempts: add_card_attempts,
      prior_suspicious_activity: prior_suspicious_activity,
      payment_account_history: ,
      payment_account_date: ,
      transaction_count_day: transaction_count_day,
      transaction_count_year: transaction_count_year,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 120

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = CustomerAccount.from_hash(hash['customerAccount']) if
    hash['customerAccount']
   = AccountHistory.from_hash(hash['accountHistory']) if hash['accountHistory']
   =
    hash.key?('accountPurchases') ? hash['accountPurchases'] : SKIP
  add_card_attempts =
    hash.key?('addCardAttempts') ? hash['addCardAttempts'] : SKIP
  prior_suspicious_activity =
    hash.key?('priorSuspiciousActivity') ? hash['priorSuspiciousActivity'] : SKIP
   =
    hash.key?('paymentAccountHistory') ? hash['paymentAccountHistory'] : SKIP
   =
    hash.key?('paymentAccountDate') ? hash['paymentAccountDate'] : SKIP
  transaction_count_day =
    hash.key?('transactionCountDay') ? hash['transactionCountDay'] : SKIP
  transaction_count_year =
    hash.key?('transactionCountYear') ? hash['transactionCountYear'] : 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.
  BuyerHistory.new(customer_account: ,
                   account_history: ,
                   account_purchases: ,
                   add_card_attempts: add_card_attempts,
                   prior_suspicious_activity: prior_suspicious_activity,
                   payment_account_history: ,
                   payment_account_date: ,
                   transaction_count_day: transaction_count_day,
                   transaction_count_year: transaction_count_year,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 61

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['customer_account'] = 'customerAccount'
  @_hash['account_history'] = 'accountHistory'
  @_hash['account_purchases'] = 'accountPurchases'
  @_hash['add_card_attempts'] = 'addCardAttempts'
  @_hash['prior_suspicious_activity'] = 'priorSuspiciousActivity'
  @_hash['payment_account_history'] = 'paymentAccountHistory'
  @_hash['payment_account_date'] = 'paymentAccountDate'
  @_hash['transaction_count_day'] = 'transactionCountDay'
  @_hash['transaction_count_year'] = 'transactionCountYear'
  @_hash
end

.nullablesObject

An array for nullable fields



91
92
93
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 91

def self.nullables
  []
end

.optionalsObject

An array for optional fields



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 76

def self.optionals
  %w[
    customer_account
    account_history
    account_purchases
    add_card_attempts
    prior_suspicious_activity
    payment_account_history
    payment_account_date
    transaction_count_day
    transaction_count_year
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 239

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} customer_account: #{@customer_account.inspect}, account_history:"\
  " #{@account_history.inspect}, account_purchases: #{@account_purchases.inspect},"\
  " add_card_attempts: #{@add_card_attempts.inspect}, prior_suspicious_activity:"\
  " #{@prior_suspicious_activity.inspect}, payment_account_history:"\
  " #{@payment_account_history.inspect}, payment_account_date:"\
  " #{@payment_account_date.inspect}, transaction_count_day:"\
  " #{@transaction_count_day.inspect}, transaction_count_year:"\
  " #{@transaction_count_year.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



227
228
229
230
231
232
233
234
235
236
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 227

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} customer_account: #{@customer_account}, account_history:"\
  " #{@account_history}, account_purchases: #{@account_purchases}, add_card_attempts:"\
  " #{@add_card_attempts}, prior_suspicious_activity: #{@prior_suspicious_activity},"\
  " payment_account_history: #{@payment_account_history}, payment_account_date:"\
  " #{@payment_account_date}, transaction_count_day: #{@transaction_count_day},"\
  " transaction_count_year: #{@transaction_count_year}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/cyber_source_merged_spec/models/buyer_history.rb', line 199

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'CustomerAccount',
                                 )
  XmlUtilities.add_as_subelement(doc, root, 'AccountHistory',
                                 )
  XmlUtilities.add_as_subelement(doc, root, 'accountPurchases',
                                 )
  XmlUtilities.add_as_subelement(doc, root, 'addCardAttempts',
                                 add_card_attempts)
  XmlUtilities.add_as_subelement(doc, root, 'priorSuspiciousActivity',
                                 prior_suspicious_activity)
  XmlUtilities.add_as_subelement(doc, root, 'paymentAccountHistory',
                                 )
  XmlUtilities.add_as_subelement(doc, root, 'paymentAccountDate',
                                 )
  XmlUtilities.add_as_subelement(doc, root, 'transactionCountDay',
                                 transaction_count_day)
  XmlUtilities.add_as_subelement(doc, root, 'transactionCountYear',
                                 transaction_count_year)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end