onfido 0.0.2 → 0.0.3

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: eb62e7ece24a16478754873e6948aa5f8b04d819
4
- data.tar.gz: cc0e79b4c4ba3ce9f19ca11537f69b531ba765a9
3
+ metadata.gz: 6ade11756020fd962ad312d8ebd50cca72b47df9
4
+ data.tar.gz: 08d2c3429fb9acff54175a1cb80f9a58fc1357b0
5
5
  SHA512:
6
- metadata.gz: d21f5ce8994ca3e63e252ca224222fa87a60646f257c9ac7cbd428a075c7670008d1613c564b8e750110ea5f3932a2005a30c51a84a0c22b6daa05b499bcf86d
7
- data.tar.gz: 07e4cfa49dcb4bcc22378138bae8843b3b0f3b612eb067f9aa01bf2319e78736563e1801ddd438e69dd477ccbfa9d7b8f4924751a3245481067dc5ada5a424ae
6
+ metadata.gz: 863ada612067a0e826ead5d97b0eb98043c53bc4fd1d174b00a8b2d173a2ec86a1c3411be7c1721d671131e0c703baa73116a06bdf056158b93f2d8394062fdd
7
+ data.tar.gz: 51e5078edb94d2457833aed52f4e4f7b249085f2fe5730d7d743f024c8e01c39cfdd584ad3f0560896958676ac88c607a819acbce589d2be4262f38757e74fa0
@@ -11,8 +11,8 @@ module Onfido
11
11
  get(url: url_for("applicants/#{applicant_id}"), payload: {})
12
12
  end
13
13
 
14
- def all
15
- get(url: url_for("applicants"), payload: {})
14
+ def all(page: 1, per_page: 20)
15
+ get(url: url_for("applicants?page=#{page}&per_page=#{per_page}"), payload: {})
16
16
  end
17
17
  end
18
18
  end
@@ -14,8 +14,11 @@ module Onfido
14
14
  )
15
15
  end
16
16
 
17
- def all(applicant_id)
18
- get(url: url_for("applicants/#{applicant_id}/checks"), payload: {})
17
+ def all(applicant_id, page: 1, per_page: 20)
18
+ get(
19
+ url: url_for("applicants/#{applicant_id}/checks?page=#{page}&per_page=#{per_page}"),
20
+ payload: {}
21
+ )
19
22
  end
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module Onfido
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -65,9 +65,18 @@ describe Onfido::Applicant do
65
65
  end
66
66
 
67
67
  describe '#all' do
68
- it 'returns all the applicants' do
69
- response = applicant.all
70
- expect(response['applicants'].size).to eq(2)
68
+ context 'with the default page and per page params' do
69
+ it 'returns all the applicants' do
70
+ response = applicant.all
71
+ expect(response['applicants'].size).to eq(2)
72
+ end
73
+ end
74
+
75
+ context 'with specific range of results for a page' do
76
+ it 'returns the specified applicants' do
77
+ response = applicant.all(page: 1, per_page: 1)
78
+ expect(response['applicants'].size).to eq(1)
79
+ end
71
80
  end
72
81
  end
73
82
  end
@@ -28,9 +28,11 @@ describe Onfido::Check do
28
28
  describe '#all' do
29
29
  let(:check_id) { '8546921-123123-123123' }
30
30
 
31
- it 'returns all existing checks for the applicant' do
32
- response = check.all(applicant_id)
33
- expect(response['checks'].size).to eq(1)
31
+ context 'with the default page and per page params' do
32
+ it 'returns all existing checks for the applicant' do
33
+ response = check.all(applicant_id)
34
+ expect(response['checks'].size).to eq(1)
35
+ end
34
36
  end
35
37
  end
36
38
  end
@@ -14,7 +14,8 @@ class FakeOnfidoAPI < Sinatra::Base
14
14
  end
15
15
 
16
16
  get '/v1/applicants' do
17
- json_response(200, 'applicants.json')
17
+ response = json_response(200, 'applicants.json')
18
+ {applicants: JSON.parse(response)['applicants'][pagination_range]}.to_json
18
19
  end
19
20
 
20
21
  post '/v1/applicants/:id/documents' do
@@ -30,7 +31,8 @@ class FakeOnfidoAPI < Sinatra::Base
30
31
  end
31
32
 
32
33
  get '/v1/applicants/:id/checks' do
33
- json_response(200, 'checks.json')
34
+ response = json_response(200, 'checks.json')
35
+ {checks: JSON.parse(response)['checks'][pagination_range]}.to_json
34
36
  end
35
37
 
36
38
  get '/v1/checks/:id/reports' do
@@ -52,4 +54,10 @@ class FakeOnfidoAPI < Sinatra::Base
52
54
  status response_code
53
55
  File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
54
56
  end
57
+
58
+ def pagination_range
59
+ start = (params.fetch('page').to_i - 1) * 20
60
+ limit = start + params.fetch('per_page').to_i - 1
61
+ start..limit
62
+ end
55
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onfido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pericles Theodorou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler