Class: AlogramPayRisk::Identity

Inherits:
ApiModelBase show all
Defined in:
lib/alogram_payrisk/models/identity.rb

Overview

Optional raw identity details for the account associated with the purchase. These fields (email, phone, addresses) are used for normalization, hashing, and risk feature extraction (e.g., email/phone/domain scoring, address risk), and are not stored in raw form by Alogram. When provided, Alogram will derive and/or cross-check: - emailHash / phoneHash / shippingAddressHash / billingAddressHash in the internal entity model - email/phone/domain risk signals - address consistency and geo-distance checks

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Identity

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
139
140
141
142
143
144
145
# File 'lib/alogram_payrisk/models/identity.rb', line 104

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `AlogramPayRisk::Identity` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `AlogramPayRisk::Identity`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'email')
    self.email = attributes[:'email']
  end

  if attributes.key?(:'email_domain')
    self.email_domain = attributes[:'email_domain']
  end

  if attributes.key?(:'phone')
    self.phone = attributes[:'phone']
  end

  if attributes.key?(:'shipping_address')
    self.shipping_address = attributes[:'shipping_address']
  end

  if attributes.key?(:'billing_address')
    self.billing_address = attributes[:'billing_address']
  end

  if attributes.key?(:'is_bot')
    self.is_bot = attributes[:'is_bot']
  end

  if attributes.key?(:'email_reputation')
    self.email_reputation = attributes[:'email_reputation']
  end
end

Instance Attribute Details

#billing_addressObject

Returns the value of attribute billing_address.



30
31
32
# File 'lib/alogram_payrisk/models/identity.rb', line 30

def billing_address
  @billing_address
end

#emailObject

Email address of the customer.



20
21
22
# File 'lib/alogram_payrisk/models/identity.rb', line 20

def email
  @email
end

#email_domainObject

Email domain only (no local part). Useful for domain-level risk and allow/deny lists without sending full email PII. Example: "gmail.com", "merchant-example.co.uk"



23
24
25
# File 'lib/alogram_payrisk/models/identity.rb', line 23

def email_domain
  @email_domain
end

#email_reputationObject

Optional: Client-side assessment of email reputation.



36
37
38
# File 'lib/alogram_payrisk/models/identity.rb', line 36

def email_reputation
  @email_reputation
end

#is_botObject

Optional: Set to true if client-side bot detection (e.g. reCAPTCHA) triggered.



33
34
35
# File 'lib/alogram_payrisk/models/identity.rb', line 33

def is_bot
  @is_bot
end

#phoneObject

Phone number that supports international E.164 format, as well as spaces, dashes, and parentheses. Examples: "+1 (415) 555-2671", "415-555-2671", "+14155552671"



26
27
28
# File 'lib/alogram_payrisk/models/identity.rb', line 26

def phone
  @phone
end

#shipping_addressObject

Returns the value of attribute shipping_address.



28
29
30
# File 'lib/alogram_payrisk/models/identity.rb', line 28

def shipping_address
  @shipping_address
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



74
75
76
# File 'lib/alogram_payrisk/models/identity.rb', line 74

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



79
80
81
# File 'lib/alogram_payrisk/models/identity.rb', line 79

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/alogram_payrisk/models/identity.rb', line 61

def self.attribute_map
  {
    :'email' => :'email',
    :'email_domain' => :'emailDomain',
    :'phone' => :'phone',
    :'shipping_address' => :'shippingAddress',
    :'billing_address' => :'billingAddress',
    :'is_bot' => :'isBot',
    :'email_reputation' => :'emailReputation'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/alogram_payrisk/models/identity.rb', line 299

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



97
98
99
100
# File 'lib/alogram_payrisk/models/identity.rb', line 97

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/alogram_payrisk/models/identity.rb', line 84

def self.openapi_types
  {
    :'email' => :'String',
    :'email_domain' => :'String',
    :'phone' => :'String',
    :'shipping_address' => :'PostalAddress',
    :'billing_address' => :'PostalAddress',
    :'is_bot' => :'Boolean',
    :'email_reputation' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



272
273
274
275
276
277
278
279
280
281
282
# File 'lib/alogram_payrisk/models/identity.rb', line 272

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      email == o.email &&
      email_domain == o.email_domain &&
      phone == o.phone &&
      shipping_address == o.shipping_address &&
      billing_address == o.billing_address &&
      is_bot == o.is_bot &&
      email_reputation == o.email_reputation
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


286
287
288
# File 'lib/alogram_payrisk/models/identity.rb', line 286

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



292
293
294
# File 'lib/alogram_payrisk/models/identity.rb', line 292

def hash
  [email, email_domain, phone, shipping_address, billing_address, is_bot, email_reputation].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



149
150
151
152
153
154
155
156
157
158
159
160
161
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
# File 'lib/alogram_payrisk/models/identity.rb', line 149

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@email.nil? && @email.to_s.length > 320
    invalid_properties.push('invalid value for "email", the character length must be smaller than or equal to 320.')
  end

  if !@email.nil? && @email.to_s.length < 3
    invalid_properties.push('invalid value for "email", the character length must be greater than or equal to 3.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/)
  if !@email.nil? && @email !~ pattern
    invalid_properties.push("invalid value for \"email\", must conform to the pattern #{pattern}.")
  end

  if !@email_domain.nil? && @email_domain.to_s.length > 255
    invalid_properties.push('invalid value for "email_domain", the character length must be smaller than or equal to 255.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)
  if !@email_domain.nil? && @email_domain !~ pattern
    invalid_properties.push("invalid value for \"email_domain\", must conform to the pattern #{pattern}.")
  end

  if !@phone.nil? && @phone.to_s.length > 20
    invalid_properties.push('invalid value for "phone", the character length must be smaller than or equal to 20.')
  end

  if !@phone.nil? && @phone.to_s.length < 7
    invalid_properties.push('invalid value for "phone", the character length must be greater than or equal to 7.')
  end

  pattern = Regexp.new(/^\+?[1-9][0-9 .\-()]{6,14}[0-9]$/)
  if !@phone.nil? && @phone !~ pattern
    invalid_properties.push("invalid value for \"phone\", must conform to the pattern #{pattern}.")
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/alogram_payrisk/models/identity.rb', line 321

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/alogram_payrisk/models/identity.rb', line 192

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@email.nil? && @email.to_s.length > 320
  return false if !@email.nil? && @email.to_s.length < 3
  return false if !@email.nil? && @email !~ Regexp.new(/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/)
  return false if !@email_domain.nil? && @email_domain.to_s.length > 255
  return false if !@email_domain.nil? && @email_domain !~ Regexp.new(/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)
  return false if !@phone.nil? && @phone.to_s.length > 20
  return false if !@phone.nil? && @phone.to_s.length < 7
  return false if !@phone.nil? && @phone !~ Regexp.new(/^\+?[1-9][0-9 .\-()]{6,14}[0-9]$/)
  email_reputation_validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
  return false unless email_reputation_validator.valid?(@email_reputation)
  true
end