Class: Minfraud::Components::Email
- Defined in:
- lib/minfraud/components/email.rb
Overview
Email corresponds to the email object of a minFraud request.
Instance Attribute Summary collapse
-
#address ⇒ String?
This field must be either be a valid email address or an MD5 of the lowercased email used in the transaction.
-
#domain ⇒ String?
The domain of the email address used in the transaction.
-
#hash_address ⇒ Boolean?
By default, the address will be sent in plain text.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Email
constructor
A new instance of Email.
-
#to_json(*_args) ⇒ Hash
A JSON representation of Minfraud::Components::Email.
Constructor Details
#initialize(params = {}) ⇒ Email
Returns a new instance of Email.
36 37 38 39 40 41 42 |
# File 'lib/minfraud/components/email.rb', line 36 def initialize(params = {}) @address = params[:address] @domain = params[:domain] @hash_address = params[:hash_address] validate end |
Instance Attribute Details
#address ⇒ String?
This field must be either be a valid email address or an MD5 of the lowercased email used in the transaction. Important: if using the MD5 hash, please be sure to convert the email address to lowercase before calculating its MD5 hash. Instead of converting an address to an MD5 hash yourself, please use the hash_address attribute in this class.
21 22 23 |
# File 'lib/minfraud/components/email.rb', line 21 def address @address end |
#domain ⇒ String?
The domain of the email address used in the transaction.
26 27 28 |
# File 'lib/minfraud/components/email.rb', line 26 def domain @domain end |
#hash_address ⇒ Boolean?
By default, the address will be sent in plain text. If this is set true, the address will instead be sent as an MD5 hash.
32 33 34 |
# File 'lib/minfraud/components/email.rb', line 32 def hash_address @hash_address end |
Instance Method Details
#to_json(*_args) ⇒ Hash
A JSON representation of Minfraud::Components::Email.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/minfraud/components/email.rb', line 47 def to_json(*_args) json = super if json['address'] && !json['domain'] _, domain = address.split('@', 2) if domain domain = clean_domain(domain) json['domain'] = domain if domain end end if json.delete('hash_address') && json['address'] hash = hash_email_address(json['address']) # We could consider clearing the key if !hash. json['address'] = hash if hash end json end |