passfort 0.3.1 → 0.4.0

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: 6895fae5e18a47206f33b537029a9b9ada673f0dc2c707bcc3eb041e2b054746
4
- data.tar.gz: 60682b4845fd07a3cf4b9f009a9362f0cff7f1d6825ee94f6e4de31ddb99ecca
3
+ metadata.gz: 3fae0cf597ac783a06b37fa4edbebbbd60b55ec711ba585c216010bc3e77d5ff
4
+ data.tar.gz: 96c0f4f15f58aacebfc044a5711f7f0f28b7dad7a3398f1c7377c107a0e31065
5
5
  SHA512:
6
- metadata.gz: e2484850489eb6035f75e64e1baa608c2c1a6d75677ffbcbf2a2998c0face9cffacdd6631c3079da8aa4f76d68047ad79799b7a5844bcf4fd7066dda85094d83
7
- data.tar.gz: a6b4fe95090fda50ec1fe4022383e5ac6c62bcba55d4e5ecfe03de381658c4fb98febc30adb0d42d7b2a5ce03a519748b11e57bc549b363e865721125ea771d0
6
+ metadata.gz: e05785677a8e26c10673944b56078dfca578f9b76151a07a557793393bbd811bb5b51a3ebd0d86fe460eae00092787a3ff89bff59ba08d57ab5747ed3fda78f7
7
+ data.tar.gz: 6aa7ef2c1dca9560de069a8930d2442c920bcb853a438821bc4064f79bb0eef515b72972cf37cb6bcd9075da1c66f98155e3f879f63b42fcc6e6c083e17de322
@@ -6,6 +6,11 @@ Unreleased
6
6
 
7
7
  No changes.
8
8
 
9
+ 0.4.0
10
+ -----
11
+
12
+ - Add `company_search` functionality
13
+
9
14
  0.3.1
10
15
  -----
11
16
 
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passfort (0.3.1)
4
+ passfort (0.4.0)
5
5
  activesupport (~> 5.0)
6
6
  excon (~> 0.60)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (5.1.6)
11
+ activesupport (5.2.0)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 0.7, < 2)
14
14
  minitest (~> 5.1)
@@ -19,5 +19,17 @@ module Passfort
19
19
  def tasks
20
20
  Endpoint::Tasks.new(@http)
21
21
  end
22
+
23
+ def company_search(country, query, state = nil, provider = nil)
24
+ search_query = "/search/companies?country=#{CGI.escape(country)}"
25
+ search_query += "&query=#{CGI.escape(query)}"
26
+ search_query += "&state=#{CGI.escape(state)}" unless state.nil?
27
+ search_query += "&provider=#{CGI.escape(provider)}" unless provider.nil?
28
+
29
+ response = @http.get(search_query)
30
+ response["companies"].map do |company|
31
+ Passfort::Resource::CompanySummary.new(company)
32
+ end
33
+ end
22
34
  end
23
35
  end
@@ -3,6 +3,7 @@
3
3
  require "passfort/resource/base"
4
4
  require "passfort/resource/profile"
5
5
  require "passfort/resource/company_data"
6
+ require "passfort/resource/company_summary"
6
7
  require "passfort/resource/task"
7
8
  require "passfort/resource/check"
8
9
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ module Resource
5
+ class CompanySummary < Base
6
+ attributes :name, :number, :country, :state
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passfort
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -0,0 +1,19 @@
1
+ {
2
+ "companies": [
3
+ {
4
+ "country": "GBR",
5
+ "name": "GOCARDLESS LTD",
6
+ "number": "07495895"
7
+ },
8
+ {
9
+ "country": "GBR",
10
+ "name": "GO CARD LIMITED",
11
+ "number": "07269277"
12
+ },
13
+ {
14
+ "country": "GBR",
15
+ "name": "GO CAR DIRECT LTD",
16
+ "number": "10333984"
17
+ }
18
+ ]
19
+ }
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Passfort::Client do
6
+ let(:client) { described_class.new(api_key: "api_key") }
7
+
8
+ describe "#company_search" do
9
+ let(:result) { client.company_search(country, query, state, provider) }
10
+
11
+ let(:country) { "GBR" }
12
+ let(:query) { "GoCard" }
13
+ let(:state) { nil }
14
+ let(:provider) { "duedil" }
15
+
16
+ before do
17
+ stub_request(
18
+ :get,
19
+ %r{/search/companies\?country=#{country}&provider=#{provider}&query=#{query}\z},
20
+ ).to_return(status: 200, body: load_fixture("companies.json"))
21
+ end
22
+
23
+ it "returns an array of companies" do
24
+ expect(result).to be_a(Array)
25
+ end
26
+
27
+ it "returns expected number of companies" do
28
+ expect(result.count).to eq(3)
29
+ end
30
+
31
+ it "returns right type of company summary resource" do
32
+ expect(result[0]).to be_a(Passfort::Resource::CompanySummary)
33
+ end
34
+
35
+ it "returns maps company summary data" do
36
+ expect(result[0]).to have_attributes(
37
+ country: "GBR",
38
+ name: "GOCARDLESS LTD",
39
+ number: "07495895",
40
+ )
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passfort
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -157,6 +157,7 @@ files:
157
157
  - lib/passfort/resource/base.rb
158
158
  - lib/passfort/resource/check.rb
159
159
  - lib/passfort/resource/company_data.rb
160
+ - lib/passfort/resource/company_summary.rb
160
161
  - lib/passfort/resource/individual_data.rb
161
162
  - lib/passfort/resource/profile.rb
162
163
  - lib/passfort/resource/task.rb
@@ -164,6 +165,7 @@ files:
164
165
  - passfort.gemspec
165
166
  - spec/fixtures/check.json
166
167
  - spec/fixtures/collected_data.json
168
+ - spec/fixtures/companies.json
167
169
  - spec/fixtures/company_ownership_check/check.json
168
170
  - spec/fixtures/company_ownership_check/collected_data.json
169
171
  - spec/fixtures/company_ownership_check/collected_data_update_request.json
@@ -171,6 +173,7 @@ files:
171
173
  - spec/fixtures/profile.json
172
174
  - spec/fixtures/task.json
173
175
  - spec/integration/company_ownership_check_spec.rb
176
+ - spec/passfort/client_spec.rb
174
177
  - spec/passfort/endpoint/checks_spec.rb
175
178
  - spec/passfort/endpoint/profiles_spec.rb
176
179
  - spec/passfort/endpoint/tasks_spec.rb
@@ -203,6 +206,7 @@ summary: Client for the PassFort API
203
206
  test_files:
204
207
  - spec/fixtures/check.json
205
208
  - spec/fixtures/collected_data.json
209
+ - spec/fixtures/companies.json
206
210
  - spec/fixtures/company_ownership_check/check.json
207
211
  - spec/fixtures/company_ownership_check/collected_data.json
208
212
  - spec/fixtures/company_ownership_check/collected_data_update_request.json
@@ -210,6 +214,7 @@ test_files:
210
214
  - spec/fixtures/profile.json
211
215
  - spec/fixtures/task.json
212
216
  - spec/integration/company_ownership_check_spec.rb
217
+ - spec/passfort/client_spec.rb
213
218
  - spec/passfort/endpoint/checks_spec.rb
214
219
  - spec/passfort/endpoint/profiles_spec.rb
215
220
  - spec/passfort/endpoint/tasks_spec.rb