tikkie-api 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 10c4a5614f612f5644d20fc71952d57c7104086e8a2ab377183fea972a9f21fd
4
- data.tar.gz: 66e49070354bc7fff4dd78ca1da2b37e404e47ba324502ecf22b7a68f4644a9a
3
+ metadata.gz: 2c74647a459da497c8470c60da1f984fe8e51b127b9109795ea953ba1fe84fe9
4
+ data.tar.gz: e32193a47ad9c1a16baa9be79c783c4463bc940d6bbbd2dbeb9bc89ce4d43065
5
5
  SHA512:
6
- metadata.gz: e0c1ff2ba7627421270620a60a8510d8958261e0239f3650fc7f6e82242d846bf712051b65d3c5c7ede981b91b46fbb8b970e85f5a4d6a870becc18eed77db84
7
- data.tar.gz: b5ca9fed8e11d329c76f3d90ea877f77b3c376e9b7b04897868fb21adc2b007fd00b0681276713f81b81d15948d2311adf12b309059c9be98a27012fa2583400
6
+ metadata.gz: 2b5cc9ea35734bf58fd93e640df6ef514f819b06484dc4628a148124f49b872d449e0e63f619862673aab8c31f067b2a5cc147bf6ac9f22b92c50c4c93799aa3
7
+ data.tar.gz: 7b155ca26948a100d6e595a329b703049365c85e408b30bcd4fe0426cf1cde0ff8abb145c106311a8ba768814dd7eee0742ace64de6ee019a8840a078ff92b75
data/.rubocop.yml CHANGED
@@ -1,8 +1,11 @@
1
+ require: rubocop-rspec
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 2.3
3
5
  DisplayCopNames: true
4
6
  DisplayStyleGuide: true
5
7
 
8
+
6
9
  Metrics/AbcSize:
7
10
  Max: 21
8
11
 
@@ -19,6 +22,20 @@ Metrics/LineLength:
19
22
  Metrics/MethodLength:
20
23
  Enabled: false
21
24
 
25
+
26
+ RSpec/DescribedClass:
27
+ EnforcedStyle: explicit
28
+
29
+ RSpec/ExampleLength:
30
+ Max: 8
31
+
32
+ RSpec/MultipleExpectations:
33
+ Max: 4
34
+
35
+ RSpec/NamedSubject:
36
+ Enabled: false
37
+
38
+
22
39
  Style/Documentation:
23
40
  Exclude:
24
41
  - 'spec/**/*'
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
  # Specify your gem's dependencies in tikkie-api.gemspec
8
8
  gemspec
9
9
 
10
- gem 'rubocop', '~> 0.63.1'
10
+ gem 'rubocop', '~> 0.65.0'
11
+ gem 'rubocop-rspec', '~> 1.32.0'
data/Gemfile.lock CHANGED
@@ -1,51 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tikkie-api (0.2.0)
4
+ tikkie-api (0.2.1)
5
5
  jwt (>= 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.5.2)
10
+ addressable (2.6.0)
11
11
  public_suffix (>= 2.0.2, < 4.0)
12
12
  ast (2.4.0)
13
13
  crack (0.4.3)
14
14
  safe_yaml (~> 1.0.0)
15
15
  diff-lcs (1.3)
16
- hashdiff (0.3.7)
16
+ hashdiff (0.3.8)
17
17
  jaro_winkler (1.5.2)
18
18
  jwt (2.1.0)
19
- parallel (1.13.0)
19
+ parallel (1.14.0)
20
20
  parser (2.6.0.0)
21
21
  ast (~> 2.4.0)
22
22
  powerpack (0.1.2)
23
- public_suffix (3.0.1)
23
+ psych (3.1.0)
24
+ public_suffix (3.0.3)
24
25
  rainbow (3.0.0)
25
26
  rake (10.5.0)
26
- rspec (3.7.0)
27
- rspec-core (~> 3.7.0)
28
- rspec-expectations (~> 3.7.0)
29
- rspec-mocks (~> 3.7.0)
30
- rspec-core (3.7.1)
31
- rspec-support (~> 3.7.0)
32
- rspec-expectations (3.7.0)
27
+ rspec (3.8.0)
28
+ rspec-core (~> 3.8.0)
29
+ rspec-expectations (~> 3.8.0)
30
+ rspec-mocks (~> 3.8.0)
31
+ rspec-core (3.8.0)
32
+ rspec-support (~> 3.8.0)
33
+ rspec-expectations (3.8.2)
33
34
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.7.0)
35
- rspec-mocks (3.7.0)
35
+ rspec-support (~> 3.8.0)
36
+ rspec-mocks (3.8.0)
36
37
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.7.0)
38
- rspec-support (3.7.0)
39
- rubocop (0.63.1)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-support (3.8.0)
40
+ rubocop (0.65.0)
40
41
  jaro_winkler (~> 1.5.1)
41
42
  parallel (~> 1.10)
42
43
  parser (>= 2.5, != 2.5.1.1)
43
44
  powerpack (~> 0.1)
45
+ psych (>= 3.1.0)
44
46
  rainbow (>= 2.2.2, < 4.0)
45
47
  ruby-progressbar (~> 1.7)
46
48
  unicode-display_width (~> 1.4.0)
49
+ rubocop-rspec (1.32.0)
50
+ rubocop (>= 0.60.0)
47
51
  ruby-progressbar (1.10.0)
48
- safe_yaml (1.0.4)
52
+ safe_yaml (1.0.5)
49
53
  timecop (0.9.1)
50
54
  unicode-display_width (1.4.1)
51
55
  webmock (2.3.2)
@@ -60,7 +64,8 @@ DEPENDENCIES
60
64
  bundler (~> 1.16)
61
65
  rake (~> 10.0)
62
66
  rspec (~> 3.0)
63
- rubocop (~> 0.63.1)
67
+ rubocop (~> 0.65.0)
68
+ rubocop-rspec (~> 1.32.0)
64
69
  tikkie-api!
65
70
  timecop (~> 0.9)
66
71
  webmock (~> 2.3)
data/README.md CHANGED
@@ -24,11 +24,16 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- ### Initialization
27
+ ### Preparation
28
+
29
+ This library uses a JSON Web Token (JWT) as authentication method. You need to create a public/private key pair to sign the tokens.
30
+ See the [developer documentation from ABN AMRO](https://developer.abnamro.com/get-started#authentication) to get started.
28
31
 
29
- First create a Tikkie configuration and specify your API key and the path to your private RSA key. See also the [developer documentation from ABN AMRO](https://developer.abnamro.com/get-started) to get started.
32
+ Make sure you have created an App in the developers portal with the Tikkie API product enabled. This App contains a Consumer Key (this is your API key), which you will need next.
33
+
34
+ ### Initialization
30
35
 
31
- Use the configuration to initialize a Tikkie client:
36
+ First create a Tikkie configuration and specify the API key of your App and the path to your private RSA key. Then use the configuration to initialize a Tikkie client:
32
37
 
33
38
  ```ruby
34
39
  require 'tikkie/api'
@@ -98,12 +103,16 @@ payment_requests = client.payment_requests.list("platform_token", "user_token")
98
103
  The payments requests response is paginated. You can use the method `more_elements?` to determine if there's more data to retrieve. In the next request, set the `offset` parameter to the new offset using the method `next_offset` from the previous response. For example:
99
104
 
100
105
  ```ruby
101
- response = client.payment_requests.list("platform_token", "user_token")
102
- payment_requests = response.to_a
106
+ options = {}
107
+
108
+ loop do
109
+ payment_requests = client.payment_requests.list("platform_token", "user_token", options)
110
+
111
+ # Do something with payment requests
112
+
113
+ break unless payment_requests.more_elements?
103
114
 
104
- while response.more_elements?
105
- response = client.payment_requests.list("platform_token", "user_token", offset: response.next_offset)
106
- payment_requests << response.to_a
115
+ options[:offset] = payment_requests.next_offset
107
116
  end
108
117
  ```
109
118
 
@@ -12,7 +12,7 @@ module Tikkie
12
12
  def initialize(response)
13
13
  if response.respond_to?(:body)
14
14
  @response = response
15
- @data = JSON.parse(response.body, symbolize_names: true)
15
+ @data = parse_body(response.body)
16
16
  else
17
17
  @data = response
18
18
  end
@@ -23,7 +23,7 @@ module Tikkie
23
23
  end
24
24
 
25
25
  def success?
26
- response_code == 200 || response_code == 201
26
+ (response_code == 200 || response_code == 201) && !@invalid
27
27
  end
28
28
 
29
29
  def error?
@@ -47,6 +47,20 @@ module Tikkie
47
47
  errors
48
48
  end
49
49
  end
50
+
51
+ private
52
+
53
+ def parse_body(body)
54
+ body = body.respond_to?(:read) ? body.read : body
55
+
56
+ JSON.parse(body, symbolize_names: true)
57
+ rescue JSON::ParserError => ex
58
+ @invalid = true
59
+
60
+ {
61
+ message: "Unable to parse JSON: #{ex.message}"
62
+ }
63
+ end
50
64
  end
51
65
  end
52
66
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tikkie
4
4
  module Api
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tikkie-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa BV
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-11 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt