fractal_api 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff9de86ce971b3c40aefed88d6e77ca424eaafe40398464c48419846f4b5868b
4
- data.tar.gz: f46953463f071c7c92c55ce7f0b2b2f41f1a03e5d1b73ea9cf01d0ffa3dd434a
3
+ metadata.gz: 83b8fbaf1c2dc16331bc43504fc5b9748f2f1947998081c890376dae66198b93
4
+ data.tar.gz: 98cea142b107367f31f439b3fffc17f4e22913fe27d8c32cafdf1ebc957a18b8
5
5
  SHA512:
6
- metadata.gz: daa456d15d21972278cb559ada7bfe98c9ef69039c54a99b42c66a28dba38ad866d79e953c2a9786cdbe4287a79050e5712149c5cc1bb791db9c3e8a013a99a7
7
- data.tar.gz: 99a49eb766f98d98acdf9267a3f14f6d216625d6c6c33e1b9c129ef4f9ecc5255d5d148781ecef5e5e955e1bdf017b5934e9bf807d5895e56c120d955e24659f
6
+ metadata.gz: 253f7357eb116e28ed42a41cb9378368a83feefb5c8646a4958f85419672397ec5eb2da8bc6567a8b5908922ee51e235237467a1c1b6de2812d5c1767503a878
7
+ data.tar.gz: 93d66f69913bed7385bd8603067619b3dca01c71421c105375f323a8c94beb4f4afb4d9e5e4d1bed6b768ade1911b20e03cfc8e2d0d4ba58c96f316215247cc6
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /.rspec_status
10
+ .DS_Store
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fractal_api (0.1.0)
4
+ fractal_api (0.1.4)
5
5
  faraday
6
6
  faraday_middleware
7
7
  faraday_middleware-multi_json
@@ -17,11 +17,19 @@ GEM
17
17
  rexml
18
18
  diff-lcs (1.4.4)
19
19
  dotenv (2.7.6)
20
- faraday (1.3.0)
20
+ faraday (1.4.2)
21
+ faraday-em_http (~> 1.0)
22
+ faraday-em_synchrony (~> 1.0)
23
+ faraday-excon (~> 1.1)
21
24
  faraday-net_http (~> 1.0)
25
+ faraday-net_http_persistent (~> 1.1)
22
26
  multipart-post (>= 1.2, < 3)
23
- ruby2_keywords
27
+ ruby2_keywords (>= 0.0.4)
28
+ faraday-em_http (1.0.0)
29
+ faraday-em_synchrony (1.0.0)
30
+ faraday-excon (1.1.0)
24
31
  faraday-net_http (1.0.1)
32
+ faraday-net_http_persistent (1.1.0)
25
33
  faraday_middleware (1.0.0)
26
34
  faraday (~> 1.0)
27
35
  faraday_middleware-multi_json (0.0.6)
@@ -5,7 +5,7 @@ require 'fractal_api/paginator'
5
5
 
6
6
  module FractalApi
7
7
  class Bank < BaseModel
8
- attributes :id, :name, :logo, :logo_url
8
+ attributes :id, :name, :pnglogo
9
9
 
10
10
  def self.all(filters = {})
11
11
  Paginator.new('/banking/v2/banks', self) do |url|
@@ -49,13 +49,15 @@ module FractalApi
49
49
 
50
50
  case response.status
51
51
  when 400
52
- raise InvalidRequestError, response.body
52
+ raise InvalidRequestError, response.body.inspect
53
53
  when 401
54
- raise APIKeyError, response.body
54
+ raise APIKeyError, response.body.inspect
55
55
  when 403
56
- raise UnauthorizedError, response.body
56
+ raise UnauthorizedError, response.body.inspect
57
+ when 404
58
+ raise NotFoundError, response.body.inspect
57
59
  else
58
- raise GenericError, response.body
60
+ raise GenericError, "#{response.status}: #{response.body.inspect}"
59
61
  end
60
62
  end
61
63
  end
@@ -3,19 +3,20 @@
3
3
  module FractalApi
4
4
  class Configuration
5
5
  BASE_URLS = {
6
- production: '',
6
+ production: 'https://apis.askfractal.com',
7
7
  sandbox: 'https://apis.julia-laces.co.uk'
8
8
  }.freeze
9
9
  AUTH_URLS = {
10
- production: '',
10
+ production: 'https://auth.askfractal.com',
11
11
  sandbox: 'https://auth.julia-laces.co.uk'
12
12
  }.freeze
13
13
 
14
- attr_accessor :api_key, :partner_id, :environment, :debug
14
+ attr_accessor :api_key, :partner_id, :webhook_secret, :environment, :debug
15
15
 
16
16
  def initialize
17
17
  @api_key = ''
18
18
  @partner_id = ''
19
+ @webhook_secret = ''
19
20
  @environment = :sandbox # can be either :sandbox or :production
20
21
  @debug = false
21
22
  end
@@ -8,15 +8,11 @@ require 'fractal_api/base_model'
8
8
  module FractalApi
9
9
  class Consent < BaseModel
10
10
  attributes :consent_id, :company_id, :bank_id, :permission,
11
- :date_created, :consent_type, :status, :type, :signin_url
11
+ :date_created, :consent_type, :status, :sign_in_url
12
12
 
13
13
  def self.create(bank_id, company_id, redirect_url)
14
- params = { redirect: redirect_url, permission: 'ReadAllBankData' }
15
- url = format_url(
16
- '/banking/v2/banks/:bank_id/consents',
17
- bank_id: bank_id.to_s
18
- )
19
- result = post(url, params: params, headers: { 'X-Company-Id' => company_id })
14
+ params = { bankId: bank_id.to_s, redirect: redirect_url, permissions: 'READALLBANKDATA' }
15
+ result = post('/banking/v2/consents', params: params, headers: { 'X-Company-Id' => company_id })
20
16
 
21
17
  build(json: result.body)
22
18
  end
@@ -41,14 +37,13 @@ module FractalApi
41
37
 
42
38
  def update(code:, id_token:, state:)
43
39
  url = format_url(
44
- '/banking/v2/banks/:bank_id/consents/:consent_id',
45
- bank_id: bank_id.to_s,
40
+ '/banking/v2/consents/:consent_id',
46
41
  consent_id: consent_id
47
42
  )
48
43
 
49
44
  result = put(
50
45
  url,
51
- params: { code: code, id_token: id_token, state: state },
46
+ params: { bankId: bank_id, code: code, id_token: id_token, state: state },
52
47
  headers: { 'X-Company-Id' => company_id }
53
48
  )
54
49
 
@@ -7,5 +7,7 @@ module FractalApi
7
7
 
8
8
  class GenericError < StandardError; end
9
9
 
10
+ class NotFoundError < StandardError; end
11
+
10
12
  class InvalidRequestError < StandardError; end
11
13
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+ require 'fractal_api/base_model'
5
+ require 'fractal_api/paginator'
6
+
7
+ module FractalApi
8
+ module Forecasting
9
+ class Balance < BaseModel
10
+ attributes :id, :bank_id, :forecast_id, :account_id,
11
+ :amount, :currency, :date, :type, :source
12
+
13
+ def self.all(company_id, filters = {})
14
+ filters = filters.transform_keys { |key| key_transformer.transform(key) }
15
+
16
+ Paginator.new('/forecasting/v2/balances', self) do |url|
17
+ get(
18
+ url,
19
+ params: filters,
20
+ headers: { 'X-Company-Id' => company_id }
21
+ )
22
+ end
23
+ end
24
+
25
+ def self.build(json:)
26
+ super.tap do |record|
27
+ record.date = Time.parse(record.date) if record.date
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+ require 'fractal_api/base_model'
5
+ require 'fractal_api/paginator'
6
+
7
+ module FractalApi
8
+ module Forecasting
9
+ class Forecast < BaseModel
10
+ attributes :id, :bank_id, :account_id,
11
+ :name, :date, :type, :source
12
+
13
+ def self.all(company_id, filters = {})
14
+ filters = filters.transform_keys { |key| key_transformer.transform(key) }
15
+
16
+ Paginator.new('/forecasting/v2/forecasts', self) do |url|
17
+ get(
18
+ url,
19
+ params: filters,
20
+ headers: { 'X-Company-Id' => company_id }
21
+ )
22
+ end
23
+ end
24
+
25
+ def self.build(json:)
26
+ super.tap do |record|
27
+ record.date = Time.parse(record.date) if record.date
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+ require 'fractal_api/base_model'
5
+ require 'fractal_api/paginator'
6
+
7
+ module FractalApi
8
+ module Forecasting
9
+ class Transaction < BaseModel
10
+ attributes :id, :bank_id, :forecast_id, :account_id,
11
+ :value_date, :amount, :currency,
12
+ :type, :merchant, :category, :reasons, :source
13
+
14
+ def self.all(company_id, filters = {})
15
+ filters = filters.transform_keys { |key| key_transformer.transform(key) }
16
+
17
+ Paginator.new('/forecasting/v2/transactions', self) do |url|
18
+ get(
19
+ url,
20
+ params: filters,
21
+ headers: { 'X-Company-Id' => company_id }
22
+ )
23
+ end
24
+ end
25
+
26
+ def self.build(json:)
27
+ super.tap do |record|
28
+ record.value_date = Time.parse(record.value_date) if record.value_date
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FractalApi
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fractal_api/base_model'
4
+
5
+ module FractalApi
6
+ class WebhookNotification < BaseModel
7
+ attributes :notification_id, :company_id, :bank_id,
8
+ :account_id, :partner_id,
9
+ :event, :status,
10
+ :error_message, :error_code, :creation_date
11
+
12
+ def success?
13
+ status == 'SUCCESS'
14
+ end
15
+ end
16
+ end
data/lib/fractal_api.rb CHANGED
@@ -10,6 +10,10 @@ require 'fractal_api/consent'
10
10
  require 'fractal_api/bank_account'
11
11
  require 'fractal_api/balance'
12
12
  require 'fractal_api/transaction'
13
+ require 'fractal_api/forecasting/forecast'
14
+ require 'fractal_api/forecasting/balance'
15
+ require 'fractal_api/forecasting/transaction'
16
+ require 'fractal_api/webhook_notification'
13
17
 
14
18
  module FractalApi
15
19
  module_function
@@ -37,7 +41,7 @@ module FractalApi
37
41
  )
38
42
 
39
43
  yield
40
-
44
+ ensure
41
45
  Thread.current[:fractal_api_token] = nil
42
46
  end
43
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fractal_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Finpoint
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -197,11 +197,15 @@ files:
197
197
  - lib/fractal_api/consent.rb
198
198
  - lib/fractal_api/errors.rb
199
199
  - lib/fractal_api/faraday_auth.rb
200
+ - lib/fractal_api/forecasting/balance.rb
201
+ - lib/fractal_api/forecasting/forecast.rb
202
+ - lib/fractal_api/forecasting/transaction.rb
200
203
  - lib/fractal_api/merchant.rb
201
204
  - lib/fractal_api/paged_response.rb
202
205
  - lib/fractal_api/paginator.rb
203
206
  - lib/fractal_api/transaction.rb
204
207
  - lib/fractal_api/version.rb
208
+ - lib/fractal_api/webhook_notification.rb
205
209
  homepage: https://www.finpoint.co.uk
206
210
  licenses: []
207
211
  metadata: {}