whos_got_dirt 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/whos_got_dirt/requests/entity.rb +3 -0
- data/lib/whos_got_dirt/requests/entity/corp_watch.rb +2 -1
- data/lib/whos_got_dirt/requests/entity/little_sis.rb +2 -1
- data/lib/whos_got_dirt/requests/entity/open_corporates.rb +2 -1
- data/lib/whos_got_dirt/requests/list.rb +3 -0
- data/lib/whos_got_dirt/requests/list/little_sis.rb +2 -1
- data/lib/whos_got_dirt/requests/list/open_corporates.rb +2 -1
- data/lib/whos_got_dirt/requests/relation.rb +3 -0
- data/lib/whos_got_dirt/requests/relation/open_corporates.rb +2 -1
- data/lib/whos_got_dirt/requests/relation/open_oil.rb +2 -1
- data/lib/whos_got_dirt/responses/entity/corp_watch.rb +7 -3
- data/lib/whos_got_dirt/responses/entity/little_sis.rb +5 -1
- data/lib/whos_got_dirt/responses/entity/open_corporates.rb +5 -5
- data/lib/whos_got_dirt/responses/list/little_sis.rb +5 -1
- data/lib/whos_got_dirt/responses/list/open_corporates.rb +1 -1
- data/lib/whos_got_dirt/responses/relation/open_corporates.rb +1 -1
- data/lib/whos_got_dirt/version.rb +1 -1
- data/spec/requests/entity/corp_watch_spec.rb +4 -0
- data/spec/requests/entity/little_sis_spec.rb +4 -0
- data/spec/requests/entity/open_corporates_spec.rb +4 -0
- data/spec/requests/list/little_sis_spec.rb +4 -0
- data/spec/requests/list/open_corporates_spec.rb +4 -0
- data/spec/requests/relation/open_corporates_spec.rb +4 -0
- data/spec/requests/relation/open_oil_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84ee304532b79d4d989aeae5085c700d4e19ea84
|
4
|
+
data.tar.gz: 5c1a6022426e70affa41c335f7f2c8bbef978cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4576f8a93268f16d22fd3bb717e6e6f2ecbdf10cde62b4955db5bbc1e737aee68b575b79ddbe37609bb3558def5a8046b6a6991fb777428444b8abf22d1a924a
|
7
|
+
data.tar.gz: 324bae3a7234a301cd920d3e3745f735d266b4f2c823b089199c9295bb1b3e236dbacf279cd800ea5baa0170960621075d4bfa35c6f4b3aa00aeac68af703ae2
|
@@ -81,7 +81,8 @@ module WhosGotDirt
|
|
81
81
|
# @see http://api.corpwatch.org/documentation/api_examples.html#A17
|
82
82
|
def convert
|
83
83
|
match('company_name', 'name')
|
84
|
-
equal('limit', 'limit')
|
84
|
+
equal('limit', 'limit') # default 100, maximum 5000
|
85
|
+
equal('index', 'page', transform: lambda{|v| (v - 1) * (input['limit'] || 100)})
|
85
86
|
|
86
87
|
input['identifiers'] && input['identifiers'].each do |identifier|
|
87
88
|
case identifier['scheme']
|
@@ -38,7 +38,8 @@ module WhosGotDirt
|
|
38
38
|
def convert
|
39
39
|
match('q', 'name')
|
40
40
|
one_of('type_ids', 'classification')
|
41
|
-
equal('num', 'limit')
|
41
|
+
equal('num', 'limit') # default 20, maximum 1000?
|
42
|
+
equal('page', 'page')
|
42
43
|
|
43
44
|
# API-specific parameters.
|
44
45
|
equal('_key', 'little_sis_api_key')
|
@@ -78,7 +78,8 @@ module WhosGotDirt
|
|
78
78
|
equal('created_since', 'created_at>=')
|
79
79
|
date_range('incorporation_date', 'founding_date')
|
80
80
|
date_range('dissolution_date', 'dissolution_date')
|
81
|
-
equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100)
|
81
|
+
equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100) # default 30, maximum 100
|
82
|
+
equal('page', 'page')
|
82
83
|
|
83
84
|
input['contact_details'] && input['contact_details'].each do |contact_detail|
|
84
85
|
if contact_detail['type'] == 'address' && (contact_detail['value'] || contact_detail['value~='])
|
@@ -24,7 +24,8 @@ module WhosGotDirt
|
|
24
24
|
# @see http://api.littlesis.org/documentation#lists
|
25
25
|
def convert
|
26
26
|
match('q', 'name')
|
27
|
-
equal('num', 'limit')
|
27
|
+
equal('num', 'limit') # default 100, maximum 100
|
28
|
+
equal('page', 'page')
|
28
29
|
|
29
30
|
# API-specific parameters.
|
30
31
|
equal('_key', 'little_sis_api_key')
|
@@ -23,7 +23,8 @@ module WhosGotDirt
|
|
23
23
|
# @see https://api.opencorporates.com/documentation/API-Reference
|
24
24
|
def convert
|
25
25
|
match('q', 'name')
|
26
|
-
equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100)
|
26
|
+
equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100) # default 30, maximum 100
|
27
|
+
equal('page', 'page')
|
27
28
|
|
28
29
|
# API-specific parameters.
|
29
30
|
equal('api_token', 'open_corporates_api_key')
|
@@ -45,7 +45,8 @@ module WhosGotDirt
|
|
45
45
|
# @return [Hash] API-specific parameters
|
46
46
|
# @see https://api.opencorporates.com/documentation/API-Reference
|
47
47
|
def convert
|
48
|
-
equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100)
|
48
|
+
equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100) # default 30, maximum 100
|
49
|
+
equal('page', 'page')
|
49
50
|
|
50
51
|
input['subject'] && input['subject'].each do |subject|
|
51
52
|
match('q', 'name', input: subject)
|
@@ -29,7 +29,8 @@ module WhosGotDirt
|
|
29
29
|
# @return [Hash] API-specific parameters
|
30
30
|
# @see http://openoil.net/openoil-api/
|
31
31
|
def convert
|
32
|
-
equal('per_page', 'limit')
|
32
|
+
equal('per_page', 'limit') # default 100, no maximum
|
33
|
+
equal('page', 'page')
|
33
34
|
|
34
35
|
input['subject'] && input['subject'].each do |subject|
|
35
36
|
equal('licensee', 'name', input: subject) # doesn't work, upstream bug
|
@@ -62,8 +62,12 @@ module WhosGotDirt
|
|
62
62
|
#
|
63
63
|
# @return [Array<Hash>] the results
|
64
64
|
def to_a
|
65
|
-
parsed_body['result']['companies']
|
66
|
-
|
65
|
+
if parsed_body['result']['companies']
|
66
|
+
parsed_body['result']['companies'].map do |_,data|
|
67
|
+
Result.new('Entity', renderer.result(data), self).finalize!
|
68
|
+
end
|
69
|
+
else
|
70
|
+
[]
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
@@ -74,7 +78,7 @@ module WhosGotDirt
|
|
74
78
|
def item_url(result)
|
75
79
|
query = CGI.parse(env.url.query.to_s)
|
76
80
|
url = "#{env.url.scheme}://#{env.url.host}#{env.url.path.sub(/\.json\z/, '')}/#{result['identifiers'][0]['identifier']}.json"
|
77
|
-
if query['key']
|
81
|
+
if query['key'].any?
|
78
82
|
url += "?key=#{CGI.escape(query['key'][0].to_s)}"
|
79
83
|
end
|
80
84
|
url
|
@@ -56,7 +56,11 @@ module WhosGotDirt
|
|
56
56
|
#
|
57
57
|
# @return [Array<Hash>] the results
|
58
58
|
def to_a
|
59
|
-
parsed_body['Data']['Entities']['Entity']
|
59
|
+
list = parsed_body['Data']['Entities']['Entity']
|
60
|
+
if Hash === list
|
61
|
+
list = [list]
|
62
|
+
end
|
63
|
+
list.map do |data|
|
60
64
|
Result.new('Entity', renderer.result(data), self).finalize!
|
61
65
|
end
|
62
66
|
end
|
@@ -12,10 +12,10 @@ module WhosGotDirt
|
|
12
12
|
'founding_date' => '/incorporation_date',
|
13
13
|
'dissolution_date' => '/dissolution_date',
|
14
14
|
'other_names' => [{
|
15
|
-
'name' => '/previous_names/company_name',
|
16
|
-
'start_date' => '/previous_names/start_date',
|
17
|
-
'end_date' => '/previous_names/end_date',
|
18
|
-
'note' => '/previous_names/type',
|
15
|
+
'name' => '/previous_names/0/company_name',
|
16
|
+
'start_date' => '/previous_names/0/start_date',
|
17
|
+
'end_date' => '/previous_names/0/end_date',
|
18
|
+
'note' => '/previous_names/0/type',
|
19
19
|
}],
|
20
20
|
'identifiers' => [{
|
21
21
|
'identifier' => '/company_number',
|
@@ -64,7 +64,7 @@ module WhosGotDirt
|
|
64
64
|
def item_url(result)
|
65
65
|
query = CGI.parse(env.url.query.to_s)
|
66
66
|
url = "#{env.url.scheme}://#{env.url.host}/companies/#{result['jurisdiction_code']}/#{result['identifiers'][0]['identifier']}"
|
67
|
-
if query['api_token']
|
67
|
+
if query['api_token'].any?
|
68
68
|
url += "?api_token=#{CGI.escape(query['api_token'][0].to_s)}"
|
69
69
|
end
|
70
70
|
url
|
@@ -32,7 +32,11 @@ module WhosGotDirt
|
|
32
32
|
#
|
33
33
|
# @return [Array<Hash>] the results
|
34
34
|
def to_a
|
35
|
-
parsed_body['Data']['Lists']['List']
|
35
|
+
list = parsed_body['Data']['Lists']['List']
|
36
|
+
if Hash === list
|
37
|
+
list = [list]
|
38
|
+
end
|
39
|
+
list.map do |data|
|
36
40
|
Result.new('List', renderer.result(data), self).finalize!
|
37
41
|
end
|
38
42
|
end
|
@@ -36,7 +36,7 @@ module WhosGotDirt
|
|
36
36
|
def item_url(result)
|
37
37
|
query = CGI.parse(env.url.query.to_s)
|
38
38
|
url = "#{env.url.scheme}://#{env.url.host}/corporate_groupings/#{CGI.escape(result['name'].to_s)}"
|
39
|
-
if query['api_token']
|
39
|
+
if query['api_token'].any?
|
40
40
|
url += "?api_token=#{CGI.escape(query['api_token'][0].to_s)}"
|
41
41
|
end
|
42
42
|
url
|
@@ -68,7 +68,7 @@ module WhosGotDirt
|
|
68
68
|
def item_url(result)
|
69
69
|
query = CGI.parse(env.url.query.to_s)
|
70
70
|
url = "#{env.url.scheme}://#{env.url.host}/officers/#{result['identifiers'][0]['identifier']}"
|
71
|
-
if query['api_token']
|
71
|
+
if query['api_token'].any?
|
72
72
|
url += "?api_token=#{CGI.escape(query['api_token'][0].to_s)}"
|
73
73
|
end
|
74
74
|
url
|
@@ -17,6 +17,10 @@ module WhosGotDirt::Requests::Entity
|
|
17
17
|
include_examples 'equal', 'limit', 'limit', 5
|
18
18
|
end
|
19
19
|
|
20
|
+
context 'when given a page' do
|
21
|
+
include_examples 'equal', 'index', 'page', 2, transformed: 100
|
22
|
+
end
|
23
|
+
|
20
24
|
context 'when given an IRS identifier' do
|
21
25
|
it 'should return a criterion' do
|
22
26
|
expect(CorpWatch.new({
|
@@ -21,6 +21,10 @@ module WhosGotDirt::Requests::Entity
|
|
21
21
|
include_examples 'equal', 'num', 'limit', 5
|
22
22
|
end
|
23
23
|
|
24
|
+
context 'when given a page' do
|
25
|
+
include_examples 'equal', 'page', 'page', 2
|
26
|
+
end
|
27
|
+
|
24
28
|
context 'when given an API key' do
|
25
29
|
include_examples 'equal', '_key', 'little_sis_api_key', 123
|
26
30
|
end
|
@@ -43,6 +43,10 @@ module WhosGotDirt::Requests::Entity
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
context 'when given a page' do
|
47
|
+
include_examples 'equal', 'page', 'page', 2
|
48
|
+
end
|
49
|
+
|
46
50
|
context 'when given an API key' do
|
47
51
|
it 'should return an API key parameter' do
|
48
52
|
expect(OpenCorporates.new('open_corporates_api_key' => 123).convert).to eq('api_token' => 123, 'per_page' => 100)
|
@@ -17,6 +17,10 @@ module WhosGotDirt::Requests::List
|
|
17
17
|
include_examples 'equal', 'num', 'limit', 5
|
18
18
|
end
|
19
19
|
|
20
|
+
context 'when given a page' do
|
21
|
+
include_examples 'equal', 'page', 'page', 2
|
22
|
+
end
|
23
|
+
|
20
24
|
context 'when given an API key' do
|
21
25
|
include_examples 'equal', '_key', 'little_sis_api_key', 123
|
22
26
|
end
|
@@ -23,6 +23,10 @@ module WhosGotDirt::Requests::List
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
context 'when given a page' do
|
27
|
+
include_examples 'equal', 'page', 'page', 2
|
28
|
+
end
|
29
|
+
|
26
30
|
context 'when given an API key' do
|
27
31
|
it 'should return an API key parameter' do
|
28
32
|
expect(OpenCorporates.new('open_corporates_api_key' => 123).convert).to eq('api_token' => 123, 'per_page' => 100)
|
@@ -31,6 +31,10 @@ module WhosGotDirt::Requests::Relation
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
context 'when given a page' do
|
35
|
+
include_examples 'equal', 'page', 'page', 2
|
36
|
+
end
|
37
|
+
|
34
38
|
context 'when given an API key' do
|
35
39
|
it 'should return an API key parameter' do
|
36
40
|
expect(OpenCorporates.new('open_corporates_api_key' => 123).convert).to eq('api_token' => 123, 'per_page' => 100)
|
@@ -17,6 +17,10 @@ module WhosGotDirt::Requests::Relation
|
|
17
17
|
include_examples 'equal', 'per_page', 'limit', 5
|
18
18
|
end
|
19
19
|
|
20
|
+
context 'when given a page' do
|
21
|
+
include_examples 'equal', 'page', 'page', 2
|
22
|
+
end
|
23
|
+
|
20
24
|
context 'when given an API key' do
|
21
25
|
include_examples 'equal', 'apikey', 'open_oil_api_key', 123
|
22
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whos_got_dirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James McKinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|