Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion finicity-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 4 additions & 0 deletions lib/finicity-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/finicity/fetchers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/finicity/fetchers/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 25 additions & 10 deletions lib/finicity/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@ 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 }

request(:post, endpoint, body: body, headers: headers)
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 }
Expand All @@ -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
6 changes: 3 additions & 3 deletions lib/finicity/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/finicity/resources/institution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/finicity/resources/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion lib/finicity/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Finicity
VERSION = "1.2.0".freeze
VERSION = "1.2.1".freeze
end
2 changes: 1 addition & 1 deletion spec/finicity/fetchers/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Expand Down
2 changes: 1 addition & 1 deletion spec/finicity/fetchers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Expand Down
2 changes: 1 addition & 1 deletion spec/finicity/fetchers/token_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
42 changes: 32 additions & 10 deletions spec/finicity/resources/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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 } }

Expand All @@ -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 }

Expand All @@ -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 } }

Expand All @@ -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) }

Expand All @@ -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 } }

Expand All @@ -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) }

Expand All @@ -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) }

Expand All @@ -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) }

Expand All @@ -107,12 +107,34 @@

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 } }

before { subject.update_credentials(institution_login_id, credentials) }

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
6 changes: 3 additions & 3 deletions spec/finicity/resources/customer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand All @@ -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
Expand All @@ -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 }

Expand Down
Loading