diff --git a/finicity-ruby.gemspec b/finicity-ruby.gemspec index f4ba68d..996e4bd 100644 --- a/finicity-ruby.gemspec +++ b/finicity-ruby.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |spec| spec.required_rubygems_version = ">= 2.0.0" spec.add_runtime_dependency "hashie", "~> 3.4.4" - spec.add_runtime_dependency "httparty", "~> 0.14.0" + spec.add_runtime_dependency "httparty", "~> 0.18.0" spec.add_runtime_dependency "redis", "~> 3.3.1" spec.add_runtime_dependency "activesupport" diff --git a/lib/finicity-ruby.rb b/lib/finicity-ruby.rb index 560e16c..67d152e 100644 --- a/lib/finicity-ruby.rb +++ b/lib/finicity-ruby.rb @@ -38,4 +38,8 @@ class LoadHistoricTxnError < StandardError; end # Description: Missing Parameter # Required Action: A required field was left blank, Submit the request again, with valid text MISSING_PARAMS_CODES = [10_005].freeze + + # Description: Account details not found + # Required Action: Nothing. This is an informational message. + ACCOUNT_DETAILS_NOT_FOUND = [38_008].freeze end diff --git a/lib/finicity/fetchers/base.rb b/lib/finicity/fetchers/base.rb index b2472b8..eefe680 100644 --- a/lib/finicity/fetchers/base.rb +++ b/lib/finicity/fetchers/base.rb @@ -5,7 +5,7 @@ module Fetchers class Base include HTTParty - base_uri "https://api.finicity.com/aggregation" + base_uri "https://api.finicity.com/" headers "Content-Type" => "application/json" headers "Accept" => "application/json" headers "Finicity-App-Key" => Finicity.configs.app_key @@ -69,7 +69,7 @@ def server_error?(response) def other_content_type?(response) content_type = response.headers["Content-Type"]&.downcase - content_type.present? && content_type != "application/json" + content_type.present? && !content_type.include?("application/json") end def default_headers diff --git a/lib/finicity/fetchers/token.rb b/lib/finicity/fetchers/token.rb index fd8275d..f7f6ff3 100644 --- a/lib/finicity/fetchers/token.rb +++ b/lib/finicity/fetchers/token.rb @@ -21,7 +21,7 @@ def refresh protected def fetch_new_one - endpoint = "/v2/partners/authentication" + endpoint = "/aggregation/v2/partners/authentication" body = { partner_id: Finicity.configs.partner_id, partner_secret: Finicity.configs.partner_secret diff --git a/lib/finicity/resources/account.rb b/lib/finicity/resources/account.rb index 96deb11..1a74114 100644 --- a/lib/finicity/resources/account.rb +++ b/lib/finicity/resources/account.rb @@ -2,14 +2,14 @@ module Finicity module Resources class Account < Base def add_all(institution_id, credentials) - endpoint = "/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall" + endpoint = "/aggregation/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall" body = { credentials: credentials } request(:post, endpoint, body: body) end def add_all_mfa(institution_id, mfa_session, questions) - endpoint = "/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall/mfa" + endpoint = "/aggregation/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall/mfa" body = { mfa_challenges: { questions: questions } } headers = { "MFA-Session" => mfa_session } @@ -17,25 +17,25 @@ def add_all_mfa(institution_id, mfa_session, questions) end def list - endpoint = "/v1/customers/#{customer_id}/accounts" + endpoint = "/aggregation/v1/customers/#{customer_id}/accounts" request(:get, endpoint) end def activate(institution_id, accounts) - endpoint = "/v2/customers/#{customer_id}/institutions/#{institution_id}/accounts" + endpoint = "/aggregation/v2/customers/#{customer_id}/institutions/#{institution_id}/accounts" request(:put, endpoint, body: { accounts: accounts }) end def refresh(institution_login_id) - endpoint = "/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts" + endpoint = "/aggregation/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts" request(:post, endpoint) end def refresh_mfa(institution_login_id, mfa_session, questions) - endpoint = "/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts/mfa" + endpoint = "/aggregation/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts/mfa" body = { questions: questions } headers = { "MFA-Session" => mfa_session } @@ -44,29 +44,44 @@ def refresh_mfa(institution_login_id, mfa_session, questions) end def get(account_id) - endpoint = "/v1/customers/#{customer_id}/accounts/#{account_id}" + endpoint = "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}" request(:get, endpoint) end def delete(account_id) - endpoint = "/v1/customers/#{customer_id}/accounts/#{account_id}" + endpoint = "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}" request(:delete, endpoint) end def credentials(account_id) - endpoint = "/v1/customers/#{customer_id}/accounts/#{account_id}/loginForm" + endpoint = "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}/loginForm" request(:get, endpoint) end def update_credentials(institution_login_id, credentials) - endpoint = "/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}" + endpoint = "/aggregation/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}" body = { login_form: credentials } request(:put, endpoint, body: body) end + + def owner_verification(account_id) + endpoint = "/decisioning/v1/customers/#{customer_id}/accounts/#{account_id}/owner" + + request(:get, endpoint) + end + + def owner_verification_mfa(account_id, mfa_session, questions) + endpoint = "/decisioning/v1/customers/#{customer_id}/accounts/#{account_id}/owner/mfa" + + body = { questions: questions } + headers = { "MFA-Session" => mfa_session } + + request(:post, endpoint, body: body, headers: headers) + end end end end diff --git a/lib/finicity/resources/customer.rb b/lib/finicity/resources/customer.rb index ba3057d..5be3e52 100644 --- a/lib/finicity/resources/customer.rb +++ b/lib/finicity/resources/customer.rb @@ -2,21 +2,21 @@ module Finicity module Resources class Customer < Base def self.add(username) - endpoint = "/v1/customers/#{Finicity.configs.app_type}" + endpoint = "/aggregation/v1/customers/#{Finicity.configs.app_type}" body = { username: username } request(:post, endpoint, body: body) end def self.list(query = {}) - endpoint = "/v1/customers" + endpoint = "/aggregation/v1/customers" query = { query: query } if query.present? request(:get, endpoint, query) end def delete - endpoint = "/v1/customers/#{customer_id}" + endpoint = "/aggregation/v1/customers/#{customer_id}" request(:delete, endpoint) end diff --git a/lib/finicity/resources/institution.rb b/lib/finicity/resources/institution.rb index fd2dac3..1a9cd4e 100644 --- a/lib/finicity/resources/institution.rb +++ b/lib/finicity/resources/institution.rb @@ -2,14 +2,14 @@ module Finicity module Resources class Institution < Base def self.list(query = {}) - endpoint = "/v1/institutions" + endpoint = "/aggregation/v1/institutions" query = { query: query } if query.present? request(:get, endpoint, query) end def self.get(institution_id) - endpoint = "/v1/institutions/#{institution_id}/details" + endpoint = "/aggregation/v1/institutions/#{institution_id}/details" request(:get, endpoint) end diff --git a/lib/finicity/resources/transaction.rb b/lib/finicity/resources/transaction.rb index a41d2fc..2182943 100644 --- a/lib/finicity/resources/transaction.rb +++ b/lib/finicity/resources/transaction.rb @@ -2,27 +2,27 @@ module Finicity module Resources class Transaction < Base def list(from:, to:, params: {}) - endpoint = "/v3/customers/#{customer_id}/transactions" + endpoint = "/aggregation/v3/customers/#{customer_id}/transactions" query = { from_date: from.to_time.to_i, to_date: to.to_time.to_i }.merge(params) request(:get, endpoint, query: query) end def list_for_account(account_id, from:, to:, params: {}) - endpoint = "/v3/customers/#{customer_id}/accounts/#{account_id}/transactions" + endpoint = "/aggregation/v3/customers/#{customer_id}/accounts/#{account_id}/transactions" query = { from_date: from.to_time.to_i, to_date: to.to_time.to_i }.merge(params) request(:get, endpoint, query: query) end def load_historic(account_id) - endpoint = "/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic" + endpoint = "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic" request(:post, endpoint) end def load_historic_mfa(account_id, mfa_session, questions) - endpoint = "/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic/mfa" + endpoint = "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic/mfa" headers = { "MFA-Session" => mfa_session } body = { questions: questions } diff --git a/lib/finicity/version.rb b/lib/finicity/version.rb index b249285..1cc169c 100644 --- a/lib/finicity/version.rb +++ b/lib/finicity/version.rb @@ -1,3 +1,3 @@ module Finicity - VERSION = "1.2.0".freeze + VERSION = "1.2.1".freeze end diff --git a/spec/finicity/fetchers/api_spec.rb b/spec/finicity/fetchers/api_spec.rb index 3a87bbd..b860833 100644 --- a/spec/finicity/fetchers/api_spec.rb +++ b/spec/finicity/fetchers/api_spec.rb @@ -2,7 +2,7 @@ describe Finicity::Fetchers::API do let(:method) { :get } - let(:endpoint) { "/v1/customers/895786124/accounts" } + let(:endpoint) { "/aggregation/v1/customers/895786124/accounts" } let(:response1) { double(:response, body: { code: code }, headers: headers, code: status_code, success?: true) } let(:response2) { response1 } let(:headers) { { "Content-Type" => "application/json" } } diff --git a/spec/finicity/fetchers/base_spec.rb b/spec/finicity/fetchers/base_spec.rb index 00c3752..ea6cb9c 100644 --- a/spec/finicity/fetchers/base_spec.rb +++ b/spec/finicity/fetchers/base_spec.rb @@ -2,7 +2,7 @@ describe Finicity::Fetchers::Base do let(:method) { :post } - let(:endpoint) { "/v1/customers" } + let(:endpoint) { "/aggregation/v1/customers" } let(:opts) { { body: request_body, headers: request_headers, query: query } } let(:request_body) { { customer: { username: "Batman", first_name: "Bruce", last_name: "Wayne" } } } let(:request_headers) { { "Custom-Header" => "1294854" } } diff --git a/spec/finicity/fetchers/token_spec.rb b/spec/finicity/fetchers/token_spec.rb index f2d81a2..19aaf1a 100644 --- a/spec/finicity/fetchers/token_spec.rb +++ b/spec/finicity/fetchers/token_spec.rb @@ -51,7 +51,7 @@ context "successful response" do let(:success) { true } let(:method) { :post } - let(:endpoint) { "/v2/partners/authentication" } + let(:endpoint) { "/aggregation/v2/partners/authentication" } let(:body) { { partner_id: configs.partner_id, partner_secret: configs.partner_secret } } before { subject } diff --git a/spec/finicity/resources/account_spec.rb b/spec/finicity/resources/account_spec.rb index 40b5be6..8c9fa25 100644 --- a/spec/finicity/resources/account_spec.rb +++ b/spec/finicity/resources/account_spec.rb @@ -15,7 +15,7 @@ describe "#add_all" do let(:credentials) { [{ name: "username", value: "house" }, { name: "password", value: "pass" }] } let(:method) { :post } - let(:endpoint) { "/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall" } let(:body) { { credentials: credentials } } before { subject.add_all(institution_id, credentials) } @@ -27,7 +27,7 @@ let(:mfa_session) { "14rEngx9aNpw39Qenf" } let(:questions) { [{ text: "small world?", answer: "sure" }] } let(:method) { :post } - let(:endpoint) { "/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall/mfa" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/institutions/#{institution_id}/accounts/addall/mfa" } let(:body) { { mfa_challenges: { questions: questions } } } let(:headers) { { "MFA-Session" => mfa_session } } @@ -38,7 +38,7 @@ describe "#list" do let(:method) { :get } - let(:endpoint) { "/v1/customers/#{customer_id}/accounts" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/accounts" } before { subject.list } @@ -47,7 +47,7 @@ describe "#activate" do let(:method) { :put } - let(:endpoint) { "/v2/customers/#{customer_id}/institutions/#{institution_id}/accounts" } + let(:endpoint) { "/aggregation/v2/customers/#{customer_id}/institutions/#{institution_id}/accounts" } let(:accounts) { [{ id: 12, type: :loan }] } let(:body) { { accounts: accounts } } @@ -58,7 +58,7 @@ describe "#refresh" do let(:method) { :post } - let(:endpoint) { "/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts" } before { subject.refresh(institution_login_id) } @@ -69,7 +69,7 @@ let(:mfa_session) { "14rEngx9aNpw39Qenf" } let(:questions) { [{ text: "after all this time?", answer: "always" }] } let(:method) { :post } - let(:endpoint) { "/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts/mfa" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}/accounts/mfa" } let(:body) { { questions: questions } } let(:headers) { { "MFA-Session" => mfa_session } } @@ -80,7 +80,7 @@ describe "#get" do let(:method) { :get } - let(:endpoint) { "/v1/customers/#{customer_id}/accounts/#{account_id}" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}" } before { subject.get(account_id) } @@ -89,7 +89,7 @@ describe "#delete" do let(:method) { :delete } - let(:endpoint) { "/v1/customers/#{customer_id}/accounts/#{account_id}" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}" } before { subject.delete(account_id) } @@ -98,7 +98,7 @@ describe "#credentials" do let(:method) { :get } - let(:endpoint) { "/v1/customers/#{customer_id}/accounts/#{account_id}/loginForm" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}/loginForm" } before { subject.credentials(account_id) } @@ -107,7 +107,7 @@ describe "#update_credentials" do let(:method) { :put } - let(:endpoint) { "/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/institutionLogins/#{institution_login_id}" } let(:credentials) { [{ name: "username", value: "house" }, { name: "password", value: "pass" }] } let(:body) { { login_form: credentials } } @@ -115,4 +115,26 @@ it { expect(api_fetcher).to have_received(:request).with(method, endpoint, body: body) } end + + describe "#owner_verification" do + let(:method) { :get } + let(:endpoint) { "/decisioning/v1/customers/#{customer_id}/accounts/#{account_id}/owner" } + + before { subject.owner_verification(account_id) } + + it { expect(api_fetcher).to have_received(:request).with(method, endpoint) } + end + + describe "#owner_verification_mfa" do + let(:method) { :post } + let(:mfa_session) { "14rEngx9aNpw39Qenf" } + let(:questions) { [{ text: "small world?", answer: "sure" }] } + let(:endpoint) { "/decisioning/v1/customers/#{customer_id}/accounts/#{account_id}/owner/mfa" } + let(:body) { { questions: questions } } + let(:headers) { { "MFA-Session" => mfa_session } } + + before { subject.owner_verification_mfa(account_id, mfa_session, questions) } + + it { expect(api_fetcher).to have_received(:request).with(method, endpoint, body: body, headers: headers) } + end end diff --git a/spec/finicity/resources/customer_spec.rb b/spec/finicity/resources/customer_spec.rb index 23674a1..d8ccb39 100644 --- a/spec/finicity/resources/customer_spec.rb +++ b/spec/finicity/resources/customer_spec.rb @@ -8,7 +8,7 @@ describe ".add" do let(:username) { "3137023c8d12" } let(:method) { :post } - let(:endpoint) { "/v1/customers/testing" } + let(:endpoint) { "/aggregation/v1/customers/testing" } let(:body) { { username: username } } let(:configs) { double(:configs, app_type: :testing) } @@ -22,7 +22,7 @@ describe ".list" do let(:method) { :get } - let(:endpoint) { "/v1/customers" } + let(:endpoint) { "/aggregation/v1/customers" } let(:query) { { type: "testing" } } context "with query" do @@ -41,7 +41,7 @@ describe "#delete" do let(:customer_id) { "94857126" } let(:method) { :delete } - let(:endpoint) { "/v1/customers/#{customer_id}" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}" } before { described_class.new(customer_id).delete } diff --git a/spec/finicity/resources/institution_spec.rb b/spec/finicity/resources/institution_spec.rb index beb9f98..5acaffa 100644 --- a/spec/finicity/resources/institution_spec.rb +++ b/spec/finicity/resources/institution_spec.rb @@ -7,7 +7,7 @@ describe ".list" do let(:method) { :get } - let(:endpoint) { "/v1/institutions" } + let(:endpoint) { "/aggregation/v1/institutions" } context "with query" do before { described_class.list(search: "Canada") } @@ -25,7 +25,7 @@ describe ".get" do let(:institution_id) { "128594" } let(:method) { :get } - let(:endpoint) { "/v1/institutions/#{institution_id}/details" } + let(:endpoint) { "/aggregation/v1/institutions/#{institution_id}/details" } before { described_class.get(institution_id) } diff --git a/spec/finicity/resources/transaction_spec.rb b/spec/finicity/resources/transaction_spec.rb index 461c670..0ae4479 100644 --- a/spec/finicity/resources/transaction_spec.rb +++ b/spec/finicity/resources/transaction_spec.rb @@ -14,7 +14,7 @@ describe "#list" do let(:method) { :get } - let(:endpoint) { "/v3/customers/#{customer_id}/transactions" } + let(:endpoint) { "/aggregation/v3/customers/#{customer_id}/transactions" } let(:query) { { from_date: from_date.to_i, to_date: to_date.to_i, page: 2 } } before { subject.list(from: from_date, to: to_date, params: { page: 2 }) } @@ -24,7 +24,7 @@ describe "#list_for_account" do let(:method) { :get } - let(:endpoint) { "/v3/customers/#{customer_id}/accounts/#{account_id}/transactions" } + let(:endpoint) { "/aggregation/v3/customers/#{customer_id}/accounts/#{account_id}/transactions" } let(:query) { { from_date: from_date.to_i, to_date: to_date.to_i, page: 2 } } before { subject.list_for_account(account_id, from: from_date, to: to_date, params: { page: 2 }) } @@ -34,7 +34,7 @@ describe "#load_historic" do let(:method) { :post } - let(:endpoint) { "/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic" } before { subject.load_historic(account_id) } @@ -45,7 +45,7 @@ let(:mfa_session) { "14rEngx9aNpw39Qenf" } let(:questions) { [{ text: "have a bullet?", answer: "in your head" }] } let(:method) { :post } - let(:endpoint) { "/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic/mfa" } + let(:endpoint) { "/aggregation/v1/customers/#{customer_id}/accounts/#{account_id}/transactions/historic/mfa" } let(:body) { { questions: questions } } let(:headers) { { "MFA-Session" => mfa_session } }