bigbank-client 0.1.0 → 0.2.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 +4 -4
- data/README.md +13 -6
- data/lib/bigbank/client/endpoints/application.rb +33 -1
- data/lib/bigbank/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40642e6630e688ddbdfc7cbeaae1e67d8f25b838
|
4
|
+
data.tar.gz: a5a4e248e58df8152fe972ec345433bf39426e93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b36569a7310c0a7e0e96b64998b887cfbdc2eddcacfdd02c36705742ddb82449f32b8caff8d3370033046ea619aba5a21f1cdd80a7794ca95698c5ffd5bde3c4
|
7
|
+
data.tar.gz: 3c02a49dbd0aeeabe573de207249be61387e3bc43a4329d50ef575fbe2cf1d1400326e79d0eec295380c62e934a994f31f8f82b5598c9e377f64dad1bbefc1a4
|
data/README.md
CHANGED
@@ -35,10 +35,14 @@ end
|
|
35
35
|
```
|
36
36
|
|
37
37
|
## Usage
|
38
|
-
Endpoint requests will return a `Bigbank::Client::Result`
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
Endpoint requests will return a `Bigbank::Client::Result` or a child of this
|
39
|
+
class e.g. `Bigbank::Client::ApplicationResult` which you can then work with as
|
40
|
+
if it was an Enumerable.
|
41
|
+
|
42
|
+
Any method that you call and is not defined on the result class will be
|
43
|
+
forwarded to the resulting body which is a JSON hash. This means that you can
|
44
|
+
work directly with the result as an `Enumarable` calling e.g. `#each` or
|
45
|
+
`#count`. The following methods are however available on all results:
|
42
46
|
- `#success?`
|
43
47
|
- `#errors?`
|
44
48
|
- `#response` access the underlying request object (see [lostisland/faraday](https://github.com/lostisland/faraday) for more info).
|
@@ -62,15 +66,18 @@ fields.each { |field| puts field }
|
|
62
66
|
```
|
63
67
|
|
64
68
|
### Application
|
65
|
-
Create a loan application.
|
69
|
+
Create a loan application. You pass in the fields, they are however specific to
|
70
|
+
your application so you need to look up what fields you are expected to POST.
|
66
71
|
```ruby
|
67
72
|
response = Bigbank::Client::Application.create({
|
68
73
|
...
|
69
74
|
})
|
70
75
|
# => #<Bigbank::Client::Result:0x007fc7698a3b48>
|
71
|
-
|
72
76
|
```
|
73
77
|
|
78
|
+
#### Extra methods the result of this endpoint:
|
79
|
+
- `#contract` downloads the contract and returns a `StringIO` or `nil`
|
80
|
+
|
74
81
|
## Using a proxy
|
75
82
|
If you are running into SSL issue while making `https://` requests you are
|
76
83
|
advised to set `verify_ssl = false`. Just don't do this in production unless
|
@@ -18,7 +18,39 @@ module Bigbank
|
|
18
18
|
request.body = { key: config.partner_key }.merge!(post_params)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
ApplicationResult.new(response, connection)
|
22
|
+
end
|
23
|
+
|
24
|
+
class ApplicationResult < Result
|
25
|
+
attr_reader :connection
|
26
|
+
|
27
|
+
def initialize(result, connection)
|
28
|
+
# TODO: Better make the connection statically available?
|
29
|
+
@connection = connection
|
30
|
+
super(result)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Public: Returns the downloaded contract
|
34
|
+
#
|
35
|
+
# Returns a @StringIO with the contract buffer or nil
|
36
|
+
def contract
|
37
|
+
@contract ||= download_contract
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# Internal: Downloads the contract
|
43
|
+
#
|
44
|
+
# Returns a @StringIO with the contract buffer or nil
|
45
|
+
def download_contract
|
46
|
+
response = connection.get(response["contract_file"])
|
47
|
+
if response.success?
|
48
|
+
buffer = StringIO.new(response.body)
|
49
|
+
buffer.set_encoding("ASCII-8BIT")
|
50
|
+
end
|
51
|
+
|
52
|
+
buffer
|
53
|
+
end
|
22
54
|
end
|
23
55
|
end
|
24
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigbank-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Samami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|