GithubHelp home page GithubHelp logo

jimjames99 / mla_active_duty_status Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 104 KB

Calls mla.dmdc.osd.mil Single Record Request page to get active duty status.

License: MIT License

Ruby 99.69% Shell 0.31%

mla_active_duty_status's Introduction

MlaActiveDutyStatus

Travis badge Tested on ruby 2.3.0 and jruby 1.7.

Gem Version

The Military Lending Act requires lenders in certain situations to check the active duty status of the loan applicant. This gem uses Mechanize to screenscrape the MLA website providing the applicant details and returns a coded response for the active duty status and the MLA PDF certificate.

MLA website: https://mla.dmdc.osd.mil

Please note the MLA may change their site at any time, rendering this gem useless. Usage is at your own risk.

Installation

Add this line to your application's Gemfile:

gem 'mla_active_duty_status'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install mla_active_duty_status

Usage

This gem can be run from the console with rake console.

The MLA requires the following details:

  • last_name (required)
  • first_name (optional)
  • middle_name (optional)
  • ssn (required)
  • dob (required)

Create an applicant object:

mla = MlaActiveDutyStatus::Applicant.new('Citizen', 'John', 'Q', '614223456',  '1950-01-25')

Check that the applicant details meet requirements:

mla.valid?

This returns true or false and then you can view any validation errors:

mla.errors
=> ["last_name must be present", "date_of_birth must be within 100 years"]

Get the active duty status of the applicant:

mla.active_duty_status

This returns an array of 2 values:

  • status:

    0 = neither applicant nor spouse are active duty

    1 = applicant or spouse appears active duty

    7 = MLA service timeout or error

    9 = invalid or missing required fields

  • pdf - a binary string of the Certificate

Response times are typically 1.0 - 3.0 seconds. This gem does not maintain a persistent connection across Rails' requests because Mechanize is not threadsafe. A future version will probably drop Mechanize for a pure HTTP::Net::Persistent implementation.

Rubies

Currently tested against MRI 2.3.0 but anything > 1.9.2 should work.

Known issue with jruby but the gem monkeypatches a fix until the issue is available in Mechanize.

Certificates

The MLA site is part of the DoD and uses site certificates that you might not ordinarily have installed.

The MLA has instructions for installing certificates, but you will most likely need to download the cert file to your production server and point to it like this:

MlaActiveDutyStatus.configuration.ca_path = '/path/to/my/ca_cert.crt'

By default, this gem will use the java keystore on jruby.

It is highly recommended that you do NOT disable certificate verification, but if you need to debug a problem then set the configuration like this:

MlaActiveDutyStatus.configuration.ssl_verify = false

Configuration

Set value for configuration:

MlaActiveDutyStatus.configuration.logging = true
  • max_years_for_age_check - Ages older than this will be flagged as invalid.

  • logging - if true or in Rails development environment will log to a local file called mechlog.log

Defaults:

@max_years_for_age_check = 100
@mla_host = 'mla.dmdc.osd.mil'
@mla_path = '/mla/single_record.xhtml'
@ssl_verify = true
@ca_path = nil
@logging = false
@open_timeout = 10
@read_timeout = 10

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jimjames99/mla_active_duty_status. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

mla_active_duty_status's People

Contributors

jimjames99 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.