bunq_rb 0.0.17 → 0.0.18

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
  SHA1:
3
- metadata.gz: 17d533671cb875144a1158b52083774e246e381a
4
- data.tar.gz: e609955903a644a6fe1359d7bb17268983d36117
3
+ metadata.gz: 07155c178c48d25522a0a35a89954255133fdd62
4
+ data.tar.gz: 5e66516fbbd233367b8c30f880899b1ebf624b00
5
5
  SHA512:
6
- metadata.gz: 10d7dd914d9796787bb354cc7cf27133df5128e02baf9231452e8469741ec22a47d4d6815099cbb0a020aeb1f4a0de0b15d4c5dadc087f62ae4cb8b43838bea7
7
- data.tar.gz: fbea5933200bd5a0fe3cf819fda0a8c9eba9b6c1ba469bac0114f5f4a88ea07ffded6400819c02c8341d979add1d0a44049e91ffb9d3cfe276ae606342b0c5c3
6
+ metadata.gz: ed00423dd7b99d1b53a1238112a4d32415040548b3bf922eb81e3242e84139536185a13e67fa97c15b0961f7caa5397230d66a41bec5acf10dc2b4a6293133f6
7
+ data.tar.gz: 2dbe44cb606c51c684b84b142d415fcb4896024aab35e80f1245440d6cfb5dc763bdd8fa2b1929dceea1cdc2d8e49658f51ddbed37fac1daa9d835061db7fa54
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Build Status](https://travis-ci.org/ahtung/bunq_rb.svg?branch=master)](https://travis-ci.org/ahtung/bunq_rb)
2
2
  [![Gem Version](https://badge.fury.io/rb/bunq_rb.svg)](https://badge.fury.io/rb/bunq_rb)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8e9c963093297534c4bb/maintainability)](https://codeclimate.com/github/ahtung/bunq_rb/maintainability)
3
4
 
4
5
  # BunqRb
5
6
 
@@ -27,9 +28,10 @@ First configure the gem
27
28
 
28
29
  ```
29
30
  BunqRb.configure do |config|
30
- config.api_key = ENV.fetch("API_KEY")
31
- config.key = key # OpenSSL::PKey::RSA.new 2048
32
- config.url = "https://sandbox.public.api.bunq.com"
31
+ config.api_key = ENV.fetch("API_KEY")
32
+ config.key = key # OpenSSL::PKey::RSA.new 2048
33
+ config.url = "https://sandbox.public.api.bunq.com"
34
+ config.page_size = 200
33
35
  end
34
36
  ```
35
37
 
@@ -90,7 +92,7 @@ end
90
92
  - GET
91
93
 
92
94
  ```ruby
93
- device_server = BunqRb::DeviceServer.find(1913)
95
+ device_server = BunqRb::DeviceServer.find(1434035)
94
96
  ```
95
97
 
96
98
  - LIST
@@ -143,11 +145,20 @@ end
143
145
  - MONETARY ACCOUNTS
144
146
  - Monetary account
145
147
  - ~~LIST~~
148
+ ```ruby
149
+ user = BunqRb::User.find(1913)
150
+ monetary_accounts = user.monetary_accounts
151
+ ```
146
152
  - GET
147
153
  - Monetary account bank
148
154
  - PAYMENTS
149
155
  - Payment
150
156
  - ~~LIST~~
157
+ ```ruby
158
+ user = BunqRb::User.find(1913)
159
+ monetary_account = user.monetary_accounts.first
160
+ payments = monetary_account.payments
161
+ ```
151
162
  - GET
152
163
  - Draft payment
153
164
  - Payment batch
@@ -176,7 +187,21 @@ end
176
187
  - CARDS
177
188
  - Card
178
189
  - ~~GET~~
190
+ ```ruby
191
+ user_id = 1913
192
+ card_id = 82082
193
+ card = BunqRb::Card.find(user_id, card_id)
194
+ ```
179
195
  - ~~LIST~~
196
+ ```ruby
197
+ user_id = 1913
198
+ cards = BunqRb::Card.all(user_id)
199
+
200
+ # OR
201
+
202
+ user = BunqRb::User.find(1913)
203
+ cards = user.cards
204
+ ```
180
205
  - PUT
181
206
  - Card debit
182
207
  - Card name
@@ -55,7 +55,8 @@ class SignRequest < Faraday::Middleware
55
55
 
56
56
  def request_string
57
57
  uri = Addressable::URI.parse(@env[:url])
58
- "#{@env[:method].upcase} #{uri.path}\n"
58
+ path = uri.query ? "#{uri.path}?#{uri.query}" : uri.path
59
+ "#{@env[:method].upcase} #{path}\n"
59
60
  end
60
61
 
61
62
  def sign?
@@ -24,7 +24,8 @@ module BunqRb
24
24
  end
25
25
  when :list
26
26
  define_singleton_method(:all) do
27
- response = Client.send_method(:get, uri)
27
+ page_size = BunqRb.configuration.page_size
28
+ response = Client.send_method(:get, "#{uri}?count=#{page_size}")
28
29
  response.map { |resp| new(resp.values.first) }
29
30
  end
30
31
  when :post
@@ -1,16 +1,14 @@
1
1
  module BunqRb
2
2
  # Configuration
3
3
  class Configuration
4
- attr_accessor :api_key
5
- attr_accessor :key
6
- attr_accessor :session_token
7
- attr_accessor :url
4
+ attr_accessor :api_key, :key, :session_token, :url, :page_size
8
5
 
9
6
  def initialize
10
7
  @api_key = ""
11
8
  @key = nil
12
9
  @session_token = nil
13
10
  @url = ""
11
+ @page_size = 10
14
12
  end
15
13
  end
16
14
  end
@@ -10,7 +10,8 @@ module BunqRb
10
10
  end
11
11
 
12
12
  def self.all(user_id)
13
- response = Client.send_method(:get, url(user_id))
13
+ page_size = BunqRb.configuration.page_size
14
+ response = Client.send_method(:get, "#{url(user_id)}?count=#{page_size}")
14
15
  response.map { |resp| new(resp["CardDebit"]) }
15
16
  end
16
17
 
@@ -22,5 +22,9 @@ module BunqRb
22
22
  def payments
23
23
  BunqRb::Payment.all(@user_id, @id)
24
24
  end
25
+
26
+ def to_s
27
+ "#{id} => #{description}"
28
+ end
25
29
  end
26
30
  end
@@ -1,12 +1,14 @@
1
1
  module BunqRb
2
2
  # Payment
3
3
  class Payment
4
- attr_reader :id, :description, :amount
4
+ attr_reader :id, :created, :updated, :description, :amount
5
5
 
6
6
  def initialize(hsh = {})
7
7
  @id = hsh["id"]
8
8
  @description = hsh["description"]
9
9
  @amount = Money.new(hsh["amount"]["value"].to_f * 100, hsh["amount"]["currency"])
10
+ @created = Time.parse(hsh["created"])
11
+ @updated = Time.parse(hsh["updated"])
10
12
  end
11
13
 
12
14
  def self.url(user_id, monetary_account_id)
@@ -14,8 +16,13 @@ module BunqRb
14
16
  end
15
17
 
16
18
  def self.all(user_id, monetary_account_id)
17
- response = Client.send_method(:get, url(user_id, monetary_account_id))
19
+ page_size = BunqRb.configuration.page_size
20
+ response = Client.send_method(:get, "#{url(user_id, monetary_account_id)}?count=#{page_size}")
18
21
  response.map { |resp| new(resp["Payment"]) }
19
22
  end
23
+
24
+ def to_s
25
+ "#{id} => €#{amount} on #{created} for #{description}"
26
+ end
20
27
  end
21
28
  end
@@ -1,3 +1,3 @@
1
1
  module BunqRb
2
- VERSION = "0.0.17".freeze
2
+ VERSION = "0.0.18".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunq_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dunya Kirkali
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-03-15 00:00:00.000000000 Z
12
+ date: 2018-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spyke