oneaccess 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oneaccess/api/v3_0/references.rb +18 -0
- data/lib/oneaccess/data_object/investor.rb +19 -0
- data/lib/oneaccess/data_object/representer/investor.rb +15 -0
- data/lib/oneaccess/request/contributors_request_handler.rb +1 -1
- data/lib/oneaccess/request/investors_request_handler.rb +45 -0
- data/lib/oneaccess/response/investors_response.rb +16 -0
- data/lib/oneaccess/response/representer/investors_response.rb +19 -0
- data/oneaccess.gemspec +2 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cb2be652851f8dabc88a0bc8bcef6bae27aa143
|
4
|
+
data.tar.gz: d7bc86b14c570ab4cda8cf1f0bcd0efe45b56a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05d117dba4adb54a89f39b492026b2af6dcce7546f8d2af263e9795a4716f098e63f98d004edef4fad315a4806b9d5b0212d04c514022e94d77fb8cb678ac6a8
|
7
|
+
data.tar.gz: 81055f03e9fa3cce90ba8371ef41f4a9355b2d559b915e6591a10a7a24b77d96df64df7f1bc6cddee9752947749b9c12dd2de350b26059fc34519420096bbbe7
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../../response/contributors_response"
|
4
|
+
require_relative "../../response/investors_response"
|
4
5
|
require_relative "../../request/contributors_request_handler"
|
6
|
+
require_relative "../../request/investors_request_handler"
|
5
7
|
|
6
8
|
module ONEAccess
|
7
9
|
module API
|
@@ -25,6 +27,22 @@ module ONEAccess
|
|
25
27
|
def contributors_list
|
26
28
|
Request::ContributorsRequestHandler.new(url: api_url("contributors"))
|
27
29
|
end
|
30
|
+
|
31
|
+
def investors(investor_names: nil, limit: 20, offset: 0)
|
32
|
+
params = {
|
33
|
+
investor_names: investor_names,
|
34
|
+
limit: limit,
|
35
|
+
offset: offset
|
36
|
+
}.reject { |_, v| v.nil? }
|
37
|
+
|
38
|
+
resp = send_get("investors", params)
|
39
|
+
|
40
|
+
Response::InvestorsResponse.from_json(resp.body)
|
41
|
+
end
|
42
|
+
|
43
|
+
def investors_list
|
44
|
+
Request::InvestorsRequestHandler.new(url: api_url("investors"))
|
45
|
+
end
|
28
46
|
end
|
29
47
|
end
|
30
48
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./representer/investor"
|
4
|
+
|
5
|
+
module ONEAccess
|
6
|
+
module DataObject
|
7
|
+
class Investor
|
8
|
+
extend Serializable
|
9
|
+
|
10
|
+
represented_by Representer::Investor
|
11
|
+
|
12
|
+
attr_accessor :investor_id
|
13
|
+
attr_accessor :investor_name
|
14
|
+
attr_accessor :active
|
15
|
+
|
16
|
+
alias active? active
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ONEAccess
|
4
|
+
module DataObject
|
5
|
+
module Representer
|
6
|
+
class Investor < Representable::Decorator
|
7
|
+
include Representable::JSON
|
8
|
+
|
9
|
+
property :investor_id, type: Integer
|
10
|
+
property :investor_name, type: String
|
11
|
+
property :active
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../response/investors_response"
|
4
|
+
|
5
|
+
module ONEAccess
|
6
|
+
module Request
|
7
|
+
class InvestorsRequestHandler
|
8
|
+
def initialize(url:, limit: PAGE_SIZE)
|
9
|
+
@url = url
|
10
|
+
@limit = limit
|
11
|
+
end
|
12
|
+
|
13
|
+
def each
|
14
|
+
offset = 0
|
15
|
+
loop do
|
16
|
+
http_response = Http::HttpClient.get(url, build_params(offset))
|
17
|
+
response = Response::InvestorsResponse.from_json(http_response.body)
|
18
|
+
response&.data&.each do |investor|
|
19
|
+
yield investor
|
20
|
+
end
|
21
|
+
break unless more_records?(response.meta)
|
22
|
+
offset += 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
PAGE_SIZE = 100
|
29
|
+
|
30
|
+
attr_reader :url
|
31
|
+
attr_reader :limit
|
32
|
+
|
33
|
+
def build_params(offset)
|
34
|
+
{
|
35
|
+
limit: limit,
|
36
|
+
offset: offset
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def more_records?(meta)
|
41
|
+
meta.offset < (meta.total / meta.limit).ceil - 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_response"
|
4
|
+
require_relative "./representer/investors_response"
|
5
|
+
|
6
|
+
module ONEAccess
|
7
|
+
module Response
|
8
|
+
class InvestorsResponse
|
9
|
+
extend Serializable
|
10
|
+
represented_by Representer::InvestorsResponse
|
11
|
+
|
12
|
+
attr_accessor :meta
|
13
|
+
attr_accessor :data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../data_object/meta"
|
4
|
+
require_relative "../../data_object/investor"
|
5
|
+
|
6
|
+
module ONEAccess
|
7
|
+
module Response
|
8
|
+
module Representer
|
9
|
+
class InvestorsResponse < Representable::Decorator
|
10
|
+
include Representable::JSON
|
11
|
+
|
12
|
+
property :meta, decorator: DataObject::Representer::Meta,
|
13
|
+
class: DataObject::Meta
|
14
|
+
collection :data, decorator: DataObject::Representer::Investor,
|
15
|
+
class: DataObject::Investor
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/oneaccess.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "oneaccess"
|
4
|
-
s.version = "0.
|
5
|
-
s.date = "2018-02-
|
4
|
+
s.version = "0.3.0"
|
5
|
+
s.date = "2018-02-05"
|
6
6
|
s.summary = "ONEAccess API wrapper"
|
7
7
|
s.description = "Easily communicate with ONEAccess API"
|
8
8
|
s.homepage = "https://github.com/AlphaExchange/rixml"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneaccess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Correia Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/oneaccess/data_object/country.rb
|
209
209
|
- lib/oneaccess/data_object/global_region.rb
|
210
210
|
- lib/oneaccess/data_object/industry.rb
|
211
|
+
- lib/oneaccess/data_object/investor.rb
|
211
212
|
- lib/oneaccess/data_object/meta.rb
|
212
213
|
- lib/oneaccess/data_object/organization.rb
|
213
214
|
- lib/oneaccess/data_object/organization_light.rb
|
@@ -221,6 +222,7 @@ files:
|
|
221
222
|
- lib/oneaccess/data_object/representer/country.rb
|
222
223
|
- lib/oneaccess/data_object/representer/global_region.rb
|
223
224
|
- lib/oneaccess/data_object/representer/industry.rb
|
225
|
+
- lib/oneaccess/data_object/representer/investor.rb
|
224
226
|
- lib/oneaccess/data_object/representer/meta.rb
|
225
227
|
- lib/oneaccess/data_object/representer/organization.rb
|
226
228
|
- lib/oneaccess/data_object/representer/organization_light.rb
|
@@ -245,6 +247,7 @@ files:
|
|
245
247
|
- lib/oneaccess/error/api_error.rb
|
246
248
|
- lib/oneaccess/http/http_client.rb
|
247
249
|
- lib/oneaccess/request/contributors_request_handler.rb
|
250
|
+
- lib/oneaccess/request/investors_request_handler.rb
|
248
251
|
- lib/oneaccess/response/api_error.rb
|
249
252
|
- lib/oneaccess/response/base_response.rb
|
250
253
|
- lib/oneaccess/response/changed_users_response.rb
|
@@ -253,6 +256,7 @@ files:
|
|
253
256
|
- lib/oneaccess/response/contributors_response.rb
|
254
257
|
- lib/oneaccess/response/countries_response.rb
|
255
258
|
- lib/oneaccess/response/industries_response.rb
|
259
|
+
- lib/oneaccess/response/investors_response.rb
|
256
260
|
- lib/oneaccess/response/organization_response.rb
|
257
261
|
- lib/oneaccess/response/paginated_response.rb
|
258
262
|
- lib/oneaccess/response/product_groups_response.rb
|
@@ -264,6 +268,7 @@ files:
|
|
264
268
|
- lib/oneaccess/response/representer/contributors_response.rb
|
265
269
|
- lib/oneaccess/response/representer/countries_response.rb
|
266
270
|
- lib/oneaccess/response/representer/industries_response.rb
|
271
|
+
- lib/oneaccess/response/representer/investors_response.rb
|
267
272
|
- lib/oneaccess/response/representer/organization_response.rb
|
268
273
|
- lib/oneaccess/response/representer/paginated_response.rb
|
269
274
|
- lib/oneaccess/response/representer/product_groups_response.rb
|