Project

emailage

0.08
Low commit activity in last 3 years
A long-lived project that still receives updates
Emailage is a Fraud Prevention Solution. This gem implements a client for the Emailage web service.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.6
~> 13.0
~> 3.6
~> 3.13
>= 0.9.37

Runtime

~> 2.9
~> 1.4
 Project Readme

Emailage Ruby API Client

alt text

The Emailageā„¢ API is organized around REST (Representational State Transfer). The API was built to help companies integrate with our highly efficient fraud risk and scoring system. By calling our API endpoints and simply passing us an email and/or IP Address, companies will be provided with real-time risk scoring assessments based around machine learning and proprietary algorithms that evolve with new fraud trends.

Installation

Add this line to your application's Gemfile:

gem 'emailage'

And then execute:

bundle

Or install it yourself as:

gem install emailage

Usage

Instantiate a client

# For a production server
emailage = Emailage::Client.new('Consumer Key', 'Consumer Secret')
# Consumer Key can also be referred to as the 'Account SID'
# Consumer Secret can also be referred to as the 'OAuth Token'

# ... or for a sandbox
emailage = Emailage::Client.new('Consumer Key', 'Consumer Secret', sandbox: true)

Query risk score information for the provided email address, IP address, or a combination

# For an email address
emailage.query 'test@example.com'
# For an IP address
emailage.query '127.0.0.1'
# For a combination. Please note the order
emailage.query ['test@example.com', '127.0.0.1']
# Pass a User Defined Record ID.
# Can be used when you want to add an identifier for a query.
# The identifier will be displayed in the result.
emailage.query 'test@example.com', urid: 'My record ID for test@example.com'

Explicit methods produce the same request while validating format of the arguments passed

# For an email address
emailage.query_email 'test@example.com'
# For an IP address
emailage.query_ip_address '127.0.0.1'
# For a combination. Please note the order
emailage.query_email_and_ip_address 'test@example.com', '127.0.0.1'
# Pass a User Defined Record ID
emailage.query_email_and_ip_address 'test@example.com', '127.0.0.1', urid: 'My record ID for test@example.com and 127.0.0.1'

Mark an email address as fraud, good, or neutral. All the listed forms are possible.

When you mark an email as fraud, you must pass the fraudCodeId: 1 - "Card Not Present Fraud" 2 - "Customer Dispute (Chargeback)" 3 - "First Party Fraud" 4 - "First Payment Default" 5 - "Identify Theft (Fraud Application)" 6 - "Identify Theft (Account Take Over)" 7 - "Suspected Fraud (Not Confirmed)" 8 - "Synthetic ID" 9 - "Other"

# Mark an email address as fraud.
emailage.flag 'fraud',   'test@example.com', 8
emailage.flag_as_fraud   'test@example.com', 8
# Mark an email address as good.
emailage.flag 'good',    'test@example.com'
emailage.flag_as_good    'test@example.com'
# Unflag an email address that was previously marked as good or fraud.
emailage.flag 'neutral', 'test@example.com'
emailage.remove_flag     'test@example.com'

Usage with Docker

Add your credentials to thesampleRequest.rb script

require './lib/emailage'
client = Emailage::Client.new('Consumer Key', 'Consumer Secret')
puts client.query('test@example.com')

Run the script inside your docker container and pass it a target email

docker run -it -v $(pwd):/app containerName ruby sample_request.rb test@test.com

Exceptions

This gem can throw exceptions for any of the following issues:

  1. When Curl has an issue and it's not possible to connect to the Emailage API
  2. When improperly formatted JSON is received
  3. When an incorrect email or IP address is passed to a flagging or explicitly querying method.