bigbank-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4dca78c7ee8f28b592bbfd1afe2d225c265f7632
4
+ data.tar.gz: ae47f9bba3f308c271fae455d2d6fbba7ff7ad8b
5
+ SHA512:
6
+ metadata.gz: 867d2ef4fbf35380c295b97480f71e7a5a6b0358928ce8d401c8d4f7e47fdd639e1d2a3f9e4d4947c3a0599c2152c150c835d02f321d7c63176861a7fb567a8b
7
+ data.tar.gz: 56081db7547c14452c2bb76c4d31f28f9a3c189a6fcd4b98d5587d7311843d06e20bdc81c362844d472ced433d1456299cf58b89277df6d49605137945fd4e00
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4.1
4
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at martin@digitalkookie.io. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bigbank-client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Martin Samami
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # Bigbank Ruby Client
2
+ [![CircleCI](https://circleci.com/gh/MrTin/bigbank-client.svg?style=svg)](https://circleci.com/gh/MrTin/bigbank-client)
3
+
4
+ ## Installation
5
+ Add it to your Gemfile:
6
+ ```ruby
7
+ gem 'bigbank-client'
8
+ ```
9
+
10
+ ## Bigbank requirements
11
+ - You need to send them an `IP or IP Range` for them to whitelist requests from
12
+ your servers.
13
+ - Request a `partner key` to authorize your requests.
14
+
15
+ ## Configuration
16
+ **Rails:** put this inside an initializer at e.g.
17
+ `config/initializers/bigbank_client.rb`
18
+ ```ruby
19
+ # Available endpoints:
20
+ # - Estonia: https://www.bigbank.ee/
21
+ # - Latvia: https://www.bigbank.lv/
22
+ # - Lithuania: https://www.bigbank.lt/
23
+ # - Finland: https://www.bigbank.fi/
24
+ # - Sweden: https://www.bigbank.se/
25
+ # - Spain: https://www.bigbank.es/
26
+
27
+ Bigbank::Client.configure do |config|
28
+ config.endpoint = "https://ansok.bigbank.se/"
29
+ config.partner_key = "super-secret-partner-key"
30
+ # config.adapter = Faraday.default_adapter
31
+ # config.verify_ssl = true
32
+ # config.enable_proxy = false
33
+ # config.proxy = "https://username:password@proxy.example.com/"
34
+ end
35
+ ```
36
+
37
+ ## Usage
38
+ Endpoint requests will return a `Bigbank::Client::Result` which you can work
39
+ with as if it was an Enumerable.
40
+
41
+ All but the following methods on a will be passed on to the resulting body:
42
+ - `#success?`
43
+ - `#errors?`
44
+ - `#response` access the underlying request object (see [lostisland/faraday](https://github.com/lostisland/faraday) for more info).
45
+
46
+ ### Example result
47
+ ```ruby
48
+ fields = Bigbank::Client::Fields.all
49
+ #=> <Bigbank::Client::Result:0x007fc7698a3b48>
50
+
51
+ fields.each { |field| puts field }
52
+ ```
53
+
54
+ ## Supported endpoints
55
+ ### Fields
56
+ Retrieve all fields to build a loan application form.
57
+ ```ruby
58
+ fields = Bigbank::Client::Fields.all
59
+ # => <Bigbank::Client::Result:0x007fc7698a3b48>
60
+
61
+ fields.each { |field| puts field }
62
+ ```
63
+
64
+ ### Application
65
+ Create a loan application.
66
+ ```ruby
67
+ response = Bigbank::Client::Application.create({
68
+ ...
69
+ })
70
+ # => #<Bigbank::Client::Result:0x007fc7698a3b48>
71
+
72
+ ```
73
+
74
+ ## Using a proxy
75
+ If you are running into SSL issue while making `https://` requests you are
76
+ advised to set `verify_ssl = false`. Just don't do this in production unless
77
+ you really need it e.g. to use a proxy, as this opens up a potential attack
78
+ vector in your software.
79
+
80
+ ## Development
81
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
82
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
83
+ prompt that will allow you to experiment.
84
+
85
+ To install this gem onto your local machine, run `bundle exec rake install`. To
86
+ release a new version, update the version number in `version.rb`, and then run
87
+ `bundle exec rake release`, which will create a git tag for the version, push
88
+ git commits and tags, and push the `.gem` file to
89
+ [rubygems.org](https://rubygems.org).
90
+
91
+ ## Contributing
92
+ Bug reports and pull requests are welcome on GitHub at
93
+ https://github.com/mrtin/bigbank-client. This project is intended to be a safe,
94
+ welcoming space for collaboration, and contributors are expected to adhere to
95
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
96
+
97
+
98
+ ## License
99
+ The gem is available as open source under the terms of the
100
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bigbank/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bigbank-client"
8
+ spec.version = Bigbank::Client::VERSION
9
+ spec.authors = ["Martin Samami"]
10
+ spec.email = ["martin@digitalkookie.io"]
11
+
12
+ spec.summary = %q{A Ruby client for the Bigbank API to request and create loan applications.}
13
+ spec.homepage = "https://github.com/mrtin/bigbank-client"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.11"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 5.0"
24
+ spec.add_development_dependency "pry"
25
+
26
+ spec.add_development_dependency "vcr"
27
+ spec.add_development_dependency "webmock"
28
+
29
+ spec.add_dependency "faraday"
30
+ spec.add_dependency "faraday_middleware"
31
+ spec.add_dependency "json"
32
+ end
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bigbank/client"
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
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.4.1
@@ -0,0 +1,28 @@
1
+ module Bigbank
2
+ module Client
3
+ class Config
4
+ attr_accessor :endpoint,
5
+ :partner_key,
6
+ :open_timeout,
7
+ :timeout,
8
+ :adapter,
9
+ :verify_ssl,
10
+ :enable_proxy,
11
+ :proxy
12
+
13
+ def initialize
14
+ @endpoint = "https://ansok.bigbank.se/"
15
+ @open_timeout = 5
16
+ @timeout = 15
17
+ @adapter = Faraday.default_adapter
18
+ @verify_ssl = true
19
+ @enable_proxy = false
20
+ @proxy = ""
21
+ end
22
+
23
+ def enable_proxy?
24
+ !!enable_proxy
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ module Bigbank
2
+ module Client
3
+ class Endpoint
4
+ def connection
5
+ @connection ||=
6
+ ::Faraday.new(url: config.endpoint) do |builder|
7
+ builder.use ::Faraday::Request::UrlEncoded
8
+ builder.response :json, :content_type => /\bjson$/
9
+ builder.headers["User-Agent"] = user_agent
10
+ builder.options[:open_timeout] = config.open_timeout
11
+ builder.options[:timeout] = config.timeout
12
+ builder.adapter config.adapter
13
+ builder.ssl.verify = config.verify_ssl
14
+ builder.proxy(config.proxy) if config.enable_proxy?
15
+ end
16
+ end
17
+
18
+ def config
19
+ Bigbank::Client.config
20
+ end
21
+
22
+ def user_agent
23
+ "bigbank-client v#{::Bigbank::Client::VERSION} (github.com/mrtin/bigbank-client)"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module Bigbank
2
+ module Client
3
+ class Application < Endpoint
4
+ attr_accessor :post_params
5
+
6
+ def self.create(*args)
7
+ self.new(*args).create
8
+ end
9
+
10
+ def initialize(post_params={})
11
+ @post_params = post_params
12
+ end
13
+
14
+ def create
15
+ response = connection.post do |request|
16
+ request.url "/api/"
17
+ request.params = { post: "data" }
18
+ request.body = { key: config.partner_key }.merge!(post_params)
19
+ end
20
+
21
+ Result.new(response)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Bigbank
2
+ module Client
3
+ class Field < Endpoint
4
+ def self.all
5
+ self.new.all
6
+ end
7
+
8
+ def all
9
+ response = connection.get do |request|
10
+ request.url "/api/"
11
+ request.params = { get: "values", key: config.partner_key }
12
+ end
13
+
14
+ Result.new(response)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Bigbank
2
+ module Client
3
+ Error = Class.new(StandardError)
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ module Bigbank
2
+ module Client
3
+ class Result
4
+ attr_accessor :response
5
+
6
+ def initialize(response)
7
+ @response = response
8
+ end
9
+
10
+ # Public: result is a success
11
+ #
12
+ # return @boolean
13
+ def success?
14
+ response.status == 200
15
+ end
16
+
17
+ # Public: result is a failure
18
+ #
19
+ # return @boolean
20
+ def errors?
21
+ !success?
22
+ end
23
+
24
+ # Allows us to work directly with the result in a more natural way e.g.
25
+ # use enumerator methods, nil check etc.
26
+ def method_missing(name, *args, &block)
27
+ response.body.send(name, *args, &block)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ module Bigbank
2
+ module Client
3
+ # TODO: methods to stub/mock
4
+
5
+
6
+ # Bigbank::Client.enable_testing!
7
+ # Bigbank::Client.disable_testing!
8
+
9
+ # Bigbank::Client::Field.all
10
+ # => {} <Bigbank::Client::Response> (FakeResponse < Response?)
11
+
12
+ # Bigbank::Client::Application.create({})
13
+ # => {} <Bigbank::Client::Response>
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Bigbank
2
+ module Client
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ require_relative "client/version"
5
+ require_relative "client/error"
6
+ require_relative "client/config"
7
+ require_relative "client/endpoint"
8
+ require_relative "client/result"
9
+
10
+ require_relative "client/endpoints/field"
11
+ require_relative "client/endpoints/application"
12
+
13
+ module Bigbank
14
+ module Client
15
+ class << self
16
+ attr_accessor :config
17
+ end
18
+
19
+ def self.configure
20
+ self.config ||= Bigbank::Client::Config.new
21
+ yield(config)
22
+ end
23
+ end
24
+ end
25
+
26
+ Bigbank::Client.configure {}
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bigbank-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Martin Samami
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faraday_middleware
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - martin@digitalkookie.io
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".travis.yml"
148
+ - CODE_OF_CONDUCT.md
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - bigbank-client.gemspec
154
+ - bin/console
155
+ - bin/setup
156
+ - circle.yml
157
+ - lib/bigbank/client.rb
158
+ - lib/bigbank/client/config.rb
159
+ - lib/bigbank/client/endpoint.rb
160
+ - lib/bigbank/client/endpoints/application.rb
161
+ - lib/bigbank/client/endpoints/field.rb
162
+ - lib/bigbank/client/error.rb
163
+ - lib/bigbank/client/result.rb
164
+ - lib/bigbank/client/testing.rb
165
+ - lib/bigbank/client/version.rb
166
+ homepage: https://github.com/mrtin/bigbank-client
167
+ licenses:
168
+ - MIT
169
+ metadata: {}
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubyforge_project:
186
+ rubygems_version: 2.6.11
187
+ signing_key:
188
+ specification_version: 4
189
+ summary: A Ruby client for the Bigbank API to request and create loan applications.
190
+ test_files: []