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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dca78c7ee8f28b592bbfd1afe2d225c265f7632
4
- data.tar.gz: ae47f9bba3f308c271fae455d2d6fbba7ff7ad8b
3
+ metadata.gz: 40642e6630e688ddbdfc7cbeaae1e67d8f25b838
4
+ data.tar.gz: a5a4e248e58df8152fe972ec345433bf39426e93
5
5
  SHA512:
6
- metadata.gz: 867d2ef4fbf35380c295b97480f71e7a5a6b0358928ce8d401c8d4f7e47fdd639e1d2a3f9e4d4947c3a0599c2152c150c835d02f321d7c63176861a7fb567a8b
7
- data.tar.gz: 56081db7547c14452c2bb76c4d31f28f9a3c189a6fcd4b98d5587d7311843d06e20bdc81c362844d472ced433d1456299cf58b89277df6d49605137945fd4e00
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` 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:
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
- Result.new(response)
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
@@ -1,5 +1,5 @@
1
1
  module Bigbank
2
2
  module Client
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.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-21 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler