This gem integrates your ruby app with Dow Jones Risk & Compliance API
dockerdocker-compose
Add this line to your application's Gemfile:
gem 'factiva-api-client', git: "[email protected]:sequra/factiva-api-client.git"And then execute:
$ bundle installA configuration is required. Add this to your app config with your credentials and the global timeout you want to set for each request:
Factiva.configure do |config|
config.auth_url = "https://accounts.dowjones.com/oauth2/v1/token"
config.base_url = "https://api.dowjones.com"
config.timeout = 5
config.client_id = "your_client_id"
config.password = "your_password"
config.username = "your_username"
config.device = "testdevice"
end
Factiva.configure(Factiva::MONITORING_API_ACCOUNT) do |config|
config.auth_url = "https://accounts.dowjones.com/oauth2/v1/token"
config.base_url = "https://api.dowjones.com"
config.timeout = 5
config.client_id = "your_monitoring_client_id"
config.password = "your_monitoring_password"
config.username = "your_monitoring_username"
config.device = "testdevice"
endAuthentication is performed automatically on your first request, as well as token handling and expiration.
Then, there are two requests available that can be made through Factiva::Request.
Search the Dow Jones RiskCenter database for risk entities.
The response will return an array of json formatted RiskEntities.
Method parameters:
| parameter | type | required |
|---|---|---|
| first_name | string | true |
| last_name | string | true |
| birth_date | Date | false |
| birth_year | string | false |
| birth_month | string | false |
| birth_day | string | false |
| offset | integer | false |
| limit | integer | false |
The parameter birth_date takes priority over year, month and day.
Examples:
Factiva::Request.search(first_name: "Jhon", last_name: "Smith", birth_date: Date.new(1995, 8, 22))
=> {"meta"=>{"count"=>32, "first"=>0, "last"=>0, "total_count"=>32, "screen...Factiva::Request.search(first_name: "Jhon", last_name: "Smith", birth_year: "1992")
=> {"meta"=>{"count"=>47, "first"=>0, "last"=>0, "total_count"=>47, "screen...View risk profiles in the Dow Jones RiskCenter database. The method requires as a param the RiskEntity id that is returned in search request.
Example:
Factiva::Request.profile("11266381")
=> {"data"=>{"attributes"=>{"basic"=>{"type"=>"Person", "name_details"=>{"primary_...Both methods search and profile can be mocked using Factiva::Response class method stub!. Once it is used, it will ignore the configuration and return always given fixed responses passed to it. Example:
Factiva::Request.stub!(
search: { "data" => ["Jhon", "Smith"] },
profile: { "data" => "Jhon Smith" }
)
=> true
Factiva::Request.search(first_name: "Jhon", last_name: "Smith")
=> {"data"=>["Jhon", "Smith"]}
Factiva::Request.profile("1234")
=> {"data"=>"Jhon Smith"}If a method response is not given to stub!, it will be mocked with empty response. Example:
Factiva::Request.stub!(
profile: { "data" => "Jhon Smith" }
)
=> true
Factiva::Request.search(first_name: "Jhon", last_name: "Smith")
=> {}Use unstub! to go back to use real requests with given configuration. Example:
Factiva::Request.unstub!
=> true
Factiva::Request.profile("11266381")
=> {"data"=>{"attributes"=>{"basic"=>{"type"=>"Person", "name_details"=>{"primary_...You can start the development environment with:
docker-compose run dev sh
And run specs with:
docker-compose run dev bundle exec rspec
All contributions are welcome, feel free to create a Pull request.
In case you want to use the gem in our of our application from your local code, you can do the following:
- Add a new volume in the Rails application's docker-compose with
~/${PATH_TO_THE_GEM}:/app/vendor/gems/factiva-api-client - Update the Gemfile to use the gem from
path:with linegem "factiva-api-client", path: '/app/vendor/gems/factiva-api-client'
A new version is released when the code is merged to master branch if you have conventional commits:
- Use fix: for patches.
- Use feat: for minor releases.
- Use feat!: or BREAKING CHANGE: for major releases.
- Other types (chore:, docs:, test:) will not trigger a release.