bankin-api-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +40 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +63 -0
- data/README.md +9 -0
- data/Rakefile +6 -0
- data/bankin.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/bankin.rb +12 -0
- data/lib/bankin/base.rb +77 -0
- data/lib/bankin/collection.rb +54 -0
- data/lib/bankin/configuration.rb +5 -0
- data/lib/bankin/error.rb +10 -0
- data/lib/bankin/resource.rb +101 -0
- data/lib/bankin/resources/account.rb +20 -0
- data/lib/bankin/resources/bank.rb +29 -0
- data/lib/bankin/resources/item.rb +68 -0
- data/lib/bankin/resources/transaction.rb +25 -0
- data/lib/bankin/resources/user.rb +57 -0
- data/lib/bankin/version.rb +3 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db78af9475eadffd4121bc1abf54c950df99b9be
|
4
|
+
data.tar.gz: 6bf8d6f6791b6361e8d2e2d76f3aacb4308ba0b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a41d3d670a410dde6873ccb8f348ef3dfc5c3056d0f80408360fb3b88465c3a34a810f24c413182d9aebce2959e7933467dacc2b4fc9de8ef13435e486e721b4
|
7
|
+
data.tar.gz: e51b1c9b4549c9acb978c36c2a502f2280e251cbbed02f3a2d24b5e7b0511083a886b888dbd1d1739b0ff2c62dffbcd4d23cd6e1d3c92fe9c4613ae04d5826bb
|
@@ -0,0 +1,40 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
executors:
|
4
|
+
gem-executor:
|
5
|
+
working_directory: ~/tmp/gem
|
6
|
+
docker:
|
7
|
+
- image: circleci/ruby:2.4.1
|
8
|
+
environment:
|
9
|
+
TZ: "Europe/Madrid"
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build-test-gem:
|
13
|
+
executor: gem-executor
|
14
|
+
steps:
|
15
|
+
- checkout
|
16
|
+
|
17
|
+
- run:
|
18
|
+
name: Update bundler
|
19
|
+
command: gem install bundler
|
20
|
+
|
21
|
+
- restore_cache:
|
22
|
+
keys:
|
23
|
+
- bankin-api-ruby-bundle-v2-{{ checksum "Gemfile.lock" }}
|
24
|
+
- bankin-api-ruby-bundle-v2-
|
25
|
+
|
26
|
+
- run: bundle install
|
27
|
+
|
28
|
+
- save_cache:
|
29
|
+
key: bankin-api-ruby-bundle-v2-{{ checksum "Gemfile.lock" }}
|
30
|
+
paths:
|
31
|
+
- vendor/bundle
|
32
|
+
|
33
|
+
- run:
|
34
|
+
name: Run rspec
|
35
|
+
command: RAILS_ENV=test bundle exec rspec spec/
|
36
|
+
|
37
|
+
workflows:
|
38
|
+
build-test-gem:
|
39
|
+
jobs:
|
40
|
+
- build-test-gem
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bankin-api-ruby (1.0.0)
|
5
|
+
rest-client (~> 2.0.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
crack (0.4.3)
|
13
|
+
safe_yaml (~> 1.0.0)
|
14
|
+
diff-lcs (1.3)
|
15
|
+
domain_name (0.5.20190701)
|
16
|
+
unf (>= 0.0.5, < 1.0.0)
|
17
|
+
hashdiff (1.0.0)
|
18
|
+
http-cookie (1.0.3)
|
19
|
+
domain_name (~> 0.5)
|
20
|
+
mime-types (3.3)
|
21
|
+
mime-types-data (~> 3.2015)
|
22
|
+
mime-types-data (3.2019.1009)
|
23
|
+
netrc (0.11.0)
|
24
|
+
public_suffix (4.0.1)
|
25
|
+
rake (10.5.0)
|
26
|
+
rest-client (2.0.2)
|
27
|
+
http-cookie (>= 1.0.2, < 2.0)
|
28
|
+
mime-types (>= 1.16, < 4.0)
|
29
|
+
netrc (~> 0.8)
|
30
|
+
rspec (3.9.0)
|
31
|
+
rspec-core (~> 3.9.0)
|
32
|
+
rspec-expectations (~> 3.9.0)
|
33
|
+
rspec-mocks (~> 3.9.0)
|
34
|
+
rspec-core (3.9.0)
|
35
|
+
rspec-support (~> 3.9.0)
|
36
|
+
rspec-expectations (3.9.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.9.0)
|
39
|
+
rspec-mocks (3.9.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-support (3.9.0)
|
43
|
+
safe_yaml (1.0.5)
|
44
|
+
unf (0.1.4)
|
45
|
+
unf_ext
|
46
|
+
unf_ext (0.0.7.6)
|
47
|
+
webmock (2.3.2)
|
48
|
+
addressable (>= 2.3.6)
|
49
|
+
crack (>= 0.3.2)
|
50
|
+
hashdiff
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bankin-api-ruby!
|
57
|
+
bundler
|
58
|
+
rake (~> 10.0)
|
59
|
+
rspec (~> 3.0)
|
60
|
+
webmock (~> 2.3.1)
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
1.17.3
|
data/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Bankin
|
2
|
+
|
3
|
+
Ruby client for the Bankin' API (aka Bridge API)
|
4
|
+
|
5
|
+
Changelog
|
6
|
+
---------
|
7
|
+
|
8
|
+
* v.1.0.0 Updated for API 2018-06-15 (with breaking changes) & added opt-in request logging
|
9
|
+
* v.0.1.2 Working Ruby wrapper for API 2018-06-15 with support for the `Account`, `Bank`, `Item`, `Transaction` and `User` resources
|
data/Rakefile
ADDED
data/bankin.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bankin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bankin-api-ruby"
|
8
|
+
spec.version = Bankin::VERSION
|
9
|
+
spec.authors = ["Maxim Novichenko", "Albert Bellonch"]
|
10
|
+
spec.email = ["maxim@getquipu.com"]
|
11
|
+
|
12
|
+
spec.summary = "Ruby client for the Bankin' API"
|
13
|
+
spec.homepage = "https://getquipu.com"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "rest-client", "~> 2.0.2"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "webmock", "~> 2.3.1"
|
28
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bankin"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/bankin.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bankin/version'
|
2
|
+
require 'bankin/configuration'
|
3
|
+
require 'bankin/base'
|
4
|
+
require 'bankin/error'
|
5
|
+
require 'bankin/resource'
|
6
|
+
require 'bankin/collection'
|
7
|
+
|
8
|
+
require 'bankin/resources/bank'
|
9
|
+
require 'bankin/resources/user'
|
10
|
+
require 'bankin/resources/item'
|
11
|
+
require 'bankin/resources/account'
|
12
|
+
require 'bankin/resources/transaction'
|
data/lib/bankin/base.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Bankin
|
5
|
+
BASE_URL = 'https://sync.bankin.com'
|
6
|
+
API_VERSION = '2018-06-15'
|
7
|
+
RATELIMIT_FIELDS = %w(limit remaining reset)
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :configuration
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def rate_limits
|
17
|
+
@rate_limits ||= Hash[RATELIMIT_FIELDS.map { |f| [f, nil] }]
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure
|
21
|
+
yield(configuration)
|
22
|
+
end
|
23
|
+
|
24
|
+
def api_call(method, path, params = {}, token = nil)
|
25
|
+
url = Bankin.const_get(:BASE_URL) + path
|
26
|
+
|
27
|
+
log_message("#{method.upcase} #{url}")
|
28
|
+
params.each do |k, v|
|
29
|
+
next if k =~ /password/
|
30
|
+
|
31
|
+
log_message("* #{k}: #{v}")
|
32
|
+
end
|
33
|
+
|
34
|
+
request_params = {
|
35
|
+
method: method,
|
36
|
+
url: url,
|
37
|
+
headers: {
|
38
|
+
'Bankin-Version': Bankin.const_get(:API_VERSION),
|
39
|
+
params: {
|
40
|
+
client_id: Bankin.configuration.client_id,
|
41
|
+
client_secret: Bankin.configuration.client_secret
|
42
|
+
}.merge(params)
|
43
|
+
}
|
44
|
+
}
|
45
|
+
request_params[:headers][:Authorization] = "Bearer #{token}" if token
|
46
|
+
|
47
|
+
begin
|
48
|
+
response = RestClient::Request.execute(request_params)
|
49
|
+
set_rate_limits(response.headers)
|
50
|
+
|
51
|
+
return {} if response.empty?
|
52
|
+
data = JSON.parse(response)
|
53
|
+
return data
|
54
|
+
rescue StandardError => e
|
55
|
+
response = JSON.parse(e.response)
|
56
|
+
raise Error.new(response['type'], response['message'])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_rate_limits(headers)
|
61
|
+
@rate_limits ||= {}
|
62
|
+
|
63
|
+
RATELIMIT_FIELDS.each do |field|
|
64
|
+
@rate_limits[field] = headers["ratelimit_#{field}".to_sym]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def log_message(msg)
|
69
|
+
return if msg.nil? || msg.empty?
|
70
|
+
|
71
|
+
logger = Bankin.configuration.logger
|
72
|
+
return if logger.nil?
|
73
|
+
|
74
|
+
logger.info(msg)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Bankin
|
2
|
+
class Collection < Array
|
3
|
+
def initialize(response, item_class, token = nil)
|
4
|
+
@item_class = item_class
|
5
|
+
@token = token
|
6
|
+
populate!(response, item_class)
|
7
|
+
end
|
8
|
+
|
9
|
+
def next_page?
|
10
|
+
!@next_page_uri.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def previous_page?
|
14
|
+
!@previous_page_uri.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def next_page!
|
18
|
+
return unless next_page?
|
19
|
+
|
20
|
+
uri = URI.parse(@next_page_uri)
|
21
|
+
params = if uri.query
|
22
|
+
Hash[URI::decode_www_form(uri.query)]
|
23
|
+
else
|
24
|
+
{}
|
25
|
+
end
|
26
|
+
|
27
|
+
response = Bankin.api_call(:get, uri.path, params, @token)
|
28
|
+
populate!(response, @item_class)
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_all!
|
33
|
+
while next_page? do
|
34
|
+
next_page!
|
35
|
+
end
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def populate!(response, item_klass)
|
42
|
+
response['resources'].each do |item|
|
43
|
+
self << item_klass.new(item, @token)
|
44
|
+
end
|
45
|
+
|
46
|
+
set_pagination(response['pagination'])
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_pagination(pagination_data)
|
50
|
+
@next_page_uri = pagination_data['next_uri']
|
51
|
+
@previous_page_uri = pagination_data['previous_uri']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/bankin/error.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
module Bankin
|
2
|
+
class Resource
|
3
|
+
def initialize(data, token = nil)
|
4
|
+
@token = token
|
5
|
+
generate_attr_readers
|
6
|
+
set_data(data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def fields
|
10
|
+
self.class.fields
|
11
|
+
end
|
12
|
+
|
13
|
+
def resources
|
14
|
+
self.class.resources
|
15
|
+
end
|
16
|
+
|
17
|
+
def collections
|
18
|
+
self.class.collections
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def generate_attr_readers
|
24
|
+
fields.each do |field|
|
25
|
+
define_singleton_method(field) do
|
26
|
+
load_data! if instance_variable_get("@#{field}").nil?
|
27
|
+
instance_variable_get("@#{field}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
(resources + collections).each do |resource|
|
32
|
+
define_singleton_method(resource[:name]) do
|
33
|
+
load_data! if instance_variable_get("@#{resource[:name]}").nil?
|
34
|
+
instance_variable_get("@#{resource[:name]}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_data(data)
|
40
|
+
fields.each do |field|
|
41
|
+
next unless data.key?(field.to_s)
|
42
|
+
instance_variable_set("@#{field}", data[field.to_s])
|
43
|
+
end
|
44
|
+
|
45
|
+
resources.each do |resource|
|
46
|
+
next unless data.key?(resource[:name].to_s)
|
47
|
+
klass = Object.const_get("Bankin::#{resource[:klass]}")
|
48
|
+
instance_variable_set("@#{resource[:name]}", klass.new(data[resource[:name].to_s], @token))
|
49
|
+
end
|
50
|
+
|
51
|
+
collections.each do |collection|
|
52
|
+
next unless data[collection[:name].to_s]
|
53
|
+
klass = Object.const_get("Bankin::#{collection[:klass]}")
|
54
|
+
arr = data[collection[:name].to_s].map { |item | klass.new(item, @token) }
|
55
|
+
instance_variable_set("@#{collection[:name]}", arr)
|
56
|
+
instance_variable_set("@#{collection[:name]}_ids", arr.map(&:id))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_data!
|
61
|
+
return if @loaded
|
62
|
+
response = Bankin.api_call(:get, @resource_uri, {}, @token)
|
63
|
+
set_data(response)
|
64
|
+
@loaded = true
|
65
|
+
end
|
66
|
+
|
67
|
+
class << self
|
68
|
+
def fields
|
69
|
+
@fields || [:resource_type, :resource_uri]
|
70
|
+
end
|
71
|
+
|
72
|
+
def resources
|
73
|
+
@resources || []
|
74
|
+
end
|
75
|
+
|
76
|
+
def collections
|
77
|
+
@collections || []
|
78
|
+
end
|
79
|
+
|
80
|
+
def auth_delegate(name, options)
|
81
|
+
define_method(name) do |*args|
|
82
|
+
klass = Object.const_get("Bankin::#{options[:class]}")
|
83
|
+
klass.send(options[:method], self.token, *args)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def has_fields(*new_fields)
|
88
|
+
@fields = (fields + new_fields).uniq
|
89
|
+
end
|
90
|
+
|
91
|
+
def has_resource(name, klass)
|
92
|
+
@resources = resources << { name: name, klass: klass }
|
93
|
+
end
|
94
|
+
|
95
|
+
def has_collection(name, klass)
|
96
|
+
@collections = collections << { name: name, klass: klass }
|
97
|
+
attr_reader :"#{name}_ids"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Bankin
|
2
|
+
class Account < Resource
|
3
|
+
RESOURCE_PATH = '/v2/accounts'
|
4
|
+
|
5
|
+
has_fields :id, :name, :balance, :currency_code, :status, :type, :last_refresh_date
|
6
|
+
|
7
|
+
has_resource :bank, 'Bank'
|
8
|
+
has_resource :item, 'Item'
|
9
|
+
|
10
|
+
def self.list(token, options = {})
|
11
|
+
response = Bankin.api_call(:get, RESOURCE_PATH, options, token)
|
12
|
+
Collection.new(response, self, token)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get(token, id)
|
16
|
+
response = Bankin.api_call(:get, "#{RESOURCE_PATH}/#{id}", {}, token)
|
17
|
+
new(response, token)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Bankin
|
2
|
+
class Bank < Resource
|
3
|
+
RESOURCE_PATH = '/v2/banks'
|
4
|
+
|
5
|
+
has_fields :id, :name, :automatic_refresh, :country_code
|
6
|
+
|
7
|
+
def self.list(options = {})
|
8
|
+
response = Bankin.api_call(:get, RESOURCE_PATH, options)
|
9
|
+
Collection.new(flatten_list(response), self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get(id)
|
13
|
+
response = Bankin.api_call(:get, "#{RESOURCE_PATH}/#{id}")
|
14
|
+
new(response)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.flatten_list(response)
|
20
|
+
response["resources"] = response["resources"].map do |country_banks|
|
21
|
+
country_banks["parent_banks"].map do |entity_banks|
|
22
|
+
entity_banks["banks"]
|
23
|
+
end.flatten
|
24
|
+
end.flatten
|
25
|
+
|
26
|
+
response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Bankin
|
2
|
+
class Item < Resource
|
3
|
+
RESOURCE_PATH = '/v2/items'
|
4
|
+
|
5
|
+
has_fields :id, :status
|
6
|
+
|
7
|
+
has_resource :bank, 'Bank'
|
8
|
+
has_collection :accounts, 'Account'
|
9
|
+
|
10
|
+
def delete
|
11
|
+
Bankin.api_call(:delete, resource_uri, {}, @token)
|
12
|
+
end
|
13
|
+
|
14
|
+
def refresh
|
15
|
+
Bankin.api_call(:post, "#{resource_uri}/refresh", {}, @token)
|
16
|
+
end
|
17
|
+
|
18
|
+
def refresh_status
|
19
|
+
Bankin.api_call(:get, "#{resource_uri}/refresh/status", {}, @token)
|
20
|
+
end
|
21
|
+
|
22
|
+
def edit_url
|
23
|
+
Bankin.api_call(
|
24
|
+
:get,
|
25
|
+
"/v2/connect/items/edit/url",
|
26
|
+
{ item_id: id },
|
27
|
+
@token
|
28
|
+
)['redirect_url']
|
29
|
+
end
|
30
|
+
|
31
|
+
def fill_in_otp_url
|
32
|
+
Bankin.api_call(
|
33
|
+
:get,
|
34
|
+
"/v2/connect/items/sync?item_id=#{id}",
|
35
|
+
{},
|
36
|
+
@token
|
37
|
+
)['redirect_url']
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.add_url(token, redirect_url, params)
|
41
|
+
Bankin.api_call(
|
42
|
+
:get,
|
43
|
+
"/v2/connect/items/add/url",
|
44
|
+
params.merge(redirect_url: redirect_url),
|
45
|
+
token
|
46
|
+
)['redirect_url']
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.pro_confirmation_url(token)
|
50
|
+
Bankin.api_call(
|
51
|
+
:get,
|
52
|
+
"/v2/connect/items/pro/confirmation/url",
|
53
|
+
{},
|
54
|
+
token
|
55
|
+
)['redirect_url']
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.list(token, options = {})
|
59
|
+
response = Bankin.api_call(:get, RESOURCE_PATH, options, token)
|
60
|
+
Collection.new(response, self, token)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.get(token, id)
|
64
|
+
response = Bankin.api_call(:get, "#{RESOURCE_PATH}/#{id}", {}, token)
|
65
|
+
new(response, token)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Bankin
|
2
|
+
class Transaction < Resource
|
3
|
+
RESOURCE_PATH = '/v2/transactions'
|
4
|
+
|
5
|
+
has_fields :id, :description, :raw_description, :amount, :date,
|
6
|
+
:updated_at, :currency_code, :is_deleted
|
7
|
+
|
8
|
+
has_resource :account, 'Account'
|
9
|
+
|
10
|
+
def self.list(token, options = {})
|
11
|
+
response = Bankin.api_call(:get, RESOURCE_PATH, options, token)
|
12
|
+
Collection.new(response, self, token)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.list_updated(token, options = {})
|
16
|
+
response = Bankin.api_call(:get, "#{RESOURCE_PATH}/updated", options, token)
|
17
|
+
Collection.new(response, self, token)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get(token, id)
|
21
|
+
response = Bankin.api_call(:get, "#{RESOURCE_PATH}/#{id}", {}, token)
|
22
|
+
new(response, token)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Bankin
|
2
|
+
class User < Resource
|
3
|
+
attr_accessor :token
|
4
|
+
|
5
|
+
RESOURCE_PATH = '/v2/users'
|
6
|
+
|
7
|
+
has_fields :uuid, :email
|
8
|
+
|
9
|
+
auth_delegate :items, class: 'Item', method: :list
|
10
|
+
auth_delegate :item, class: 'Item', method: :get
|
11
|
+
auth_delegate :accounts, class: 'Account', method: :list
|
12
|
+
auth_delegate :account, class: 'Account', method: :get
|
13
|
+
auth_delegate :updated_transactions, class: 'Transaction', method: :list_updated
|
14
|
+
auth_delegate :transactions, class: 'Transaction', method: :list
|
15
|
+
auth_delegate :transaction, class: 'Transaction', method: :get
|
16
|
+
|
17
|
+
def delete(password)
|
18
|
+
Bankin.api_call(:delete, resource_uri, { password: password })
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_item_url(redirect_url = nil, params = {})
|
22
|
+
authenticate if token.nil?
|
23
|
+
Item.add_url(token, redirect_url, params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def item_connect_url(bank_id, redirect_url = nil)
|
27
|
+
Item.connect_url(token, bank_id, redirect_url)
|
28
|
+
end
|
29
|
+
|
30
|
+
def pro_confirmation_url
|
31
|
+
Item.pro_confirmation_url(token)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.list(options = {})
|
35
|
+
response = Bankin.api_call(:get, RESOURCE_PATH, options)
|
36
|
+
Collection.new(response, self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.delete_all
|
40
|
+
Bankin.api_call(:delete, RESOURCE_PATH)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.create(email, password)
|
44
|
+
response = Bankin.api_call(:post, RESOURCE_PATH,
|
45
|
+
{ email: email, password: password })
|
46
|
+
new(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.authenticate(email, password)
|
50
|
+
response = Bankin.api_call(:post, '/v2/authenticate',
|
51
|
+
{ email: email, password: password })
|
52
|
+
user = new(response['user'])
|
53
|
+
user.token = response['access_token']
|
54
|
+
user
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bankin-api-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maxim Novichenko
|
8
|
+
- Albert Bellonch
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.0.2
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.0.2
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: webmock
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.3.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.3.1
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- maxim@getquipu.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".circleci/config.yml"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".ruby-version"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bankin.gemspec
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- lib/bankin.rb
|
103
|
+
- lib/bankin/base.rb
|
104
|
+
- lib/bankin/collection.rb
|
105
|
+
- lib/bankin/configuration.rb
|
106
|
+
- lib/bankin/error.rb
|
107
|
+
- lib/bankin/resource.rb
|
108
|
+
- lib/bankin/resources/account.rb
|
109
|
+
- lib/bankin/resources/bank.rb
|
110
|
+
- lib/bankin/resources/item.rb
|
111
|
+
- lib/bankin/resources/transaction.rb
|
112
|
+
- lib/bankin/resources/user.rb
|
113
|
+
- lib/bankin/version.rb
|
114
|
+
homepage: https://getquipu.com
|
115
|
+
licenses: []
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.6.11
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Ruby client for the Bankin' API
|
137
|
+
test_files: []
|