reuters 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +23 -0
- data/.rubocop.enabled.yml +23 -0
- data/.rubocop.yml +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +28 -0
- data/CONTRIBUTING.md +37 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +209 -0
- data/Rakefile +5 -0
- data/lib/reuters.rb +98 -0
- data/lib/reuters/builder.rb +117 -0
- data/lib/reuters/client.rb +12 -0
- data/lib/reuters/client/base.rb +132 -0
- data/lib/reuters/client/fundamentals.rb +20 -0
- data/lib/reuters/client/search.rb +19 -0
- data/lib/reuters/client/search/base.rb +26 -0
- data/lib/reuters/client/search/equity.rb +64 -0
- data/lib/reuters/client/token.rb +101 -0
- data/lib/reuters/credentials.rb +79 -0
- data/lib/reuters/namespaces.rb +25 -0
- data/lib/reuters/namespaces/base.rb +47 -0
- data/lib/reuters/namespaces/common.rb +30 -0
- data/lib/reuters/namespaces/fundamentals.rb +31 -0
- data/lib/reuters/namespaces/search.rb +48 -0
- data/lib/reuters/namespaces/search/equity.rb +32 -0
- data/lib/reuters/namespaces/token.rb +30 -0
- data/lib/reuters/response.rb +32 -0
- data/lib/reuters/version.rb +6 -0
- data/lib/reuters/wsdls.rb +25 -0
- data/lib/reuters/wsdls/base.rb +44 -0
- data/lib/reuters/wsdls/fundamentals.rb +21 -0
- data/lib/reuters/wsdls/search.rb +13 -0
- data/lib/reuters/wsdls/search/equity.rb +25 -0
- data/lib/reuters/wsdls/token.rb +22 -0
- data/reuters.gemspec +41 -0
- data/spec/fixtures/responses/token.xml +11 -0
- data/spec/reuters/builder_spec.rb +189 -0
- data/spec/reuters/client/fundamentals_spec.rb +11 -0
- data/spec/reuters/client/search/equity_spec.rb +46 -0
- data/spec/reuters/client/token_spec.rb +91 -0
- data/spec/reuters/client_spec.rb +0 -0
- data/spec/reuters/credentials_spec.rb +68 -0
- data/spec/reuters/namespaces/common_spec.rb +5 -0
- data/spec/reuters/namespaces/fundamentals_spec.rb +5 -0
- data/spec/reuters/namespaces/search/equity_spec.rb +5 -0
- data/spec/reuters/namespaces/search_spec.rb +31 -0
- data/spec/reuters/namespaces/token_spec.rb +5 -0
- data/spec/reuters/namespaces_spec.rb +31 -0
- data/spec/reuters/response_spec.rb +54 -0
- data/spec/reuters/version_spec.rb +9 -0
- data/spec/reuters/wsdls/fundamentals_spec.rb +5 -0
- data/spec/reuters/wsdls/search/equity_spec.rb +5 -0
- data/spec/reuters/wsdls/token_spec.rb +5 -0
- data/spec/reuters/wsdls_spec.rb +31 -0
- data/spec/reuters_spec.rb +10 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/client/search_shared.rb +5 -0
- data/spec/support/client_shared.rb +70 -0
- data/spec/support/configurable_shared.rb +9 -0
- data/spec/support/namespaces_actions_shared.rb +36 -0
- data/spec/support/namespaces_shared.rb +42 -0
- data/spec/support/wsdls_actions_shared.rb +36 -0
- data/spec/support/wsdls_shared.rb +53 -0
- metadata +333 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module Reuters
|
2
|
+
module Wsdls
|
3
|
+
# Represents the Wsdl endpoint that will be used to
|
4
|
+
# make Fundamentals Reuters API calls.
|
5
|
+
module Fundamentals
|
6
|
+
|
7
|
+
# @!parse include Base
|
8
|
+
|
9
|
+
include Base
|
10
|
+
|
11
|
+
# Wsdl for the TokenManagement endpoint.
|
12
|
+
mattr_accessor :name
|
13
|
+
self.name = 'Fundamentals'
|
14
|
+
|
15
|
+
# Method to use for the Wsdl
|
16
|
+
mattr_accessor :method
|
17
|
+
self.method = 'Fundamentals_1_HttpAndRkdToken_Soap11.wsdl'
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'reuters/wsdls/search/equity'
|
2
|
+
|
3
|
+
module Reuters
|
4
|
+
module Wsdls
|
5
|
+
# Represents the WSDL endpoints for all Search API calls.
|
6
|
+
#
|
7
|
+
# @note This Wsdl module does not contain any endpoint
|
8
|
+
# information, as it is recommended to use a specific
|
9
|
+
# endpoint, such as {Reuters::Wsdls::Search::Equity}.
|
10
|
+
module Search
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Reuters
|
2
|
+
module Wsdls
|
3
|
+
module Search
|
4
|
+
# The Equity Search WSDL endpoint is used by the
|
5
|
+
# {Reuters::Client::Search::Equity} class to discover
|
6
|
+
# and make search-based API calls.
|
7
|
+
module Equity
|
8
|
+
|
9
|
+
# @!parse include Base
|
10
|
+
|
11
|
+
include Base
|
12
|
+
|
13
|
+
# Wsdl for the TokenManagement endpoint.
|
14
|
+
mattr_accessor :name
|
15
|
+
self.name = 'Search'
|
16
|
+
|
17
|
+
# Default method for this Wsdl
|
18
|
+
mattr_accessor :method
|
19
|
+
self.name = 'EquityQuote_1_HttpAndRkdToken_Soap11.wsdl'
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Reuters
|
2
|
+
module Wsdls
|
3
|
+
# Represents the WSDL used by Reuters in their internal API for
|
4
|
+
# providing information related to the operations that can be
|
5
|
+
# performed to retrieve access tokens.
|
6
|
+
module Token
|
7
|
+
|
8
|
+
# @!parse include Base
|
9
|
+
|
10
|
+
include Base
|
11
|
+
|
12
|
+
# Wsdl for the TokenManagement endpoint.
|
13
|
+
mattr_accessor :name
|
14
|
+
self.name = 'TokenManagement'
|
15
|
+
|
16
|
+
# Method to use for the Wsdl
|
17
|
+
mattr_accessor :method
|
18
|
+
self.method = 'TokenManagement_1_HttpsAndAnonymous_Soap11.wsdl'
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/reuters.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'reuters/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
|
8
|
+
# Only with >= Ruby 2
|
9
|
+
spec.required_ruby_version = '>= 2.0.0'
|
10
|
+
|
11
|
+
spec.name = "reuters"
|
12
|
+
spec.version = Reuters::VERSION
|
13
|
+
spec.authors = ['Stockflare']
|
14
|
+
spec.email = ['info@stockflare.com']
|
15
|
+
spec.summary = %q(Ruby client for Thomson Reuters Knowledge Direct (TRKD) API)
|
16
|
+
spec.description = %q(Ruby Gem for interacting with the Thomson Reuters Knowledge Direct API)
|
17
|
+
spec.homepage = 'https://github.com/stockflare/reuters'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency "savon", "~> 2.5.1"
|
26
|
+
spec.add_dependency "activesupport"
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'yard'
|
32
|
+
spec.add_development_dependency 'faker'
|
33
|
+
spec.add_development_dependency 'redcarpet'
|
34
|
+
spec.add_development_dependency 'cucumber'
|
35
|
+
spec.add_development_dependency 'aruba'
|
36
|
+
spec.add_development_dependency 'factory_girl'
|
37
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
38
|
+
spec.add_development_dependency 'coveralls'
|
39
|
+
spec.add_development_dependency 'rubocop'
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<s:Envelope
|
2
|
+
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<s:Body>
|
4
|
+
<CreateServiceToken_Response_1
|
5
|
+
xmlns="http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1"
|
6
|
+
xmlns:global="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1">
|
7
|
+
<Expiration>2014-05-14T19:05:04.8429795Z</Expiration>
|
8
|
+
<global:Token>92C6ECD09825AC24C977F352FB31F8E4DF10BC84502A1CBDDF4636371E6714BA6DB028EAB6B832398B64AFE7895D53521C7F4CB84AF643D902E7707887C62DBEAF7398A9AB812B817F9C06B476EA6A017B629BE78FB965F4B2B46CCC7BCCF993</global:Token>
|
9
|
+
</CreateServiceToken_Response_1>
|
10
|
+
</s:Body>
|
11
|
+
</s:Envelope>
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Reuters::Builder do
|
4
|
+
|
5
|
+
before { @builder = Reuters::Builder.new }
|
6
|
+
|
7
|
+
subject { @builder }
|
8
|
+
|
9
|
+
it { should respond_to(:attributes) }
|
10
|
+
|
11
|
+
it "should correctly camelcase a body key" do
|
12
|
+
@builder.test_method
|
13
|
+
expect(@builder.keys).to include("TestMethod")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should call a block" do
|
17
|
+
expect { |b| Reuters::Builder.new &b }.to yield_control.once
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should pass itself to the block" do
|
21
|
+
expect { |b| Reuters::Builder.new &b }.to yield_with_args(Reuters::Builder)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should chain body calls inside the block" do
|
25
|
+
b = Reuters::Builder.new { |b| b.test_method }
|
26
|
+
expect(b).to include("TestMethod")
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "return value of #keys" do
|
30
|
+
before do
|
31
|
+
@builder.foo_test
|
32
|
+
@builder.bar_test
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should include camelcased keys" do
|
36
|
+
expect(@builder.keys).to include("FooTest", "BarTest")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should not include underscored keys" do
|
40
|
+
expect(@builder.keys).to_not include(:foo_test, :bar_test, 'foo_test', 'bar_test')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should not be empty" do
|
44
|
+
expect(@builder.keys).to_not be_empty
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should add new keys" do
|
48
|
+
expect { @builder.david }.to change { @builder.keys }
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not include attributes!" do
|
52
|
+
expect(@builder.keys).to_not include(:attributes!)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "return value of #key?" do
|
57
|
+
|
58
|
+
before { @builder.test_build }
|
59
|
+
|
60
|
+
it "should allow camelcase keys" do
|
61
|
+
expect(@builder.key?("TestBuild")).to be_true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should allow underscore keys" do
|
65
|
+
expect(@builder.key?(:test_build)).to be_true
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "when a block is passed to a nested builder" do
|
71
|
+
|
72
|
+
it "should call the block" do
|
73
|
+
expect { |b| @builder.foo.bar &b }.to yield_control.once
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should enable modifications inside the block" do
|
77
|
+
@builder.foo.bar { |body| body.test = 1 }
|
78
|
+
expect(@builder.foo.bar.key?(:test)).to_not be_false
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "when attributes are set" do
|
84
|
+
|
85
|
+
let(:attributes) { { "xmlns" => "http://..." } }
|
86
|
+
|
87
|
+
it "should set attributes" do
|
88
|
+
@builder.test(attributes)
|
89
|
+
expect(@builder[:attributes!]["Test"]).to include "Xmlns"
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "when camelcasing is disabled" do
|
93
|
+
|
94
|
+
it "should still camcelcase the key" do
|
95
|
+
@builder.test(attributes, false)
|
96
|
+
expect(@builder[:attributes!]).to include "Test"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should set attributes that aren't camelcased" do
|
100
|
+
@builder.test(attributes, false)
|
101
|
+
expect(@builder[:attributes!]["Test"]).to include "xmlns"
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "when a chain of keys is set" do
|
109
|
+
|
110
|
+
it "should set all keys" do
|
111
|
+
expect(@builder.this.is.a.chain).to_not be_nil
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should set attributes for a nested key" do
|
115
|
+
@builder.this(a: 1).is.a(b: 2).chain
|
116
|
+
expect(@builder[:attributes!]).to include({"This" => { "A" => 1}})
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should set nested attributes for a nested key" do
|
120
|
+
@builder.this(a: 1).is.a(b: 2).chain
|
121
|
+
expect(@builder.this.is[:attributes!]).to include({"A" => { "B" => 2}})
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "when the value is explicitly set" do
|
127
|
+
|
128
|
+
it "should set a string" do
|
129
|
+
@builder.test = "foobar"
|
130
|
+
expect(@builder).to include({"Test" => "foobar"})
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should set an array" do
|
134
|
+
@builder.test = [1,2,3,4]
|
135
|
+
expect(@builder).to include({"Test" => [1,2,3,4]})
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should set an integer" do
|
139
|
+
@builder.test = 1
|
140
|
+
expect(@builder).to include({"Test" => 1})
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should set attributes for a key" do
|
146
|
+
@builder.test a: true
|
147
|
+
expect(@builder[:attributes!]).to include("Test")
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should camelize attribute keys" do
|
151
|
+
@builder.test a: 1
|
152
|
+
expect(@builder[:attributes!]["Test"]).to include "A"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should set multiple attributes for a key" do
|
156
|
+
@builder.test a: 1, b: 2, c: 3
|
157
|
+
expected_attributes = { "A" => 1, "B" => 2, "C" => 3 }
|
158
|
+
expect(@builder[:attributes!]["Test"]).to include expected_attributes
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "when the key is an array" do
|
162
|
+
|
163
|
+
let(:test_array) { [{a: 1, b: 2}, {a: 3, b: 4}] }
|
164
|
+
|
165
|
+
before { @builder.test test_array }
|
166
|
+
|
167
|
+
it "should set an array for the key" do
|
168
|
+
expect(@builder["Test"]).to be_a(Array)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should set an array of the correct length" do
|
172
|
+
expect(@builder["Test"].count).to eq test_array.count
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should set an attribute for the key" do
|
176
|
+
expect(@builder[:attributes!]["Test"]).to be_a(Hash)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should include the attribute keys" do
|
180
|
+
expect(@builder[:attributes!]["Test"].keys).to include("A", "B")
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should order the attributes correctly" do
|
184
|
+
expect(@builder[:attributes!]["Test"]["A"]).to eq ["1","3"]
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Reuters::Client::Search::Equity do
|
4
|
+
|
5
|
+
before { @equity = Reuters::Client::Search::Equity.new }
|
6
|
+
|
7
|
+
subject { @equity }
|
8
|
+
|
9
|
+
it_behaves_like "a search client class"
|
10
|
+
|
11
|
+
it { should respond_to(:data_type) }
|
12
|
+
it { should respond_to(:query_spec) }
|
13
|
+
|
14
|
+
describe "return value of #data_type" do
|
15
|
+
|
16
|
+
it "should be a string" do
|
17
|
+
expect(@equity.data_type).to be_a(String)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be a resolved namespace" do
|
21
|
+
expect(@equity.data_type).to include(Reuters.namespaces_endpoint)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should include the camelcased data type" do
|
25
|
+
expect(@equity.data_type).to include("QuerySpecDataTypes")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "return value of #query_spec" do
|
31
|
+
|
32
|
+
it "should be a string" do
|
33
|
+
expect(@equity.query_spec).to be_a(String)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be a resolved namespace" do
|
37
|
+
expect(@equity.query_spec).to include(Reuters.namespaces_endpoint)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should include the camelcased specification namespace" do
|
41
|
+
expect(@equity.query_spec).to include("EquityQuote_QuerySpec_1")
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Reuters::Client::Token do
|
4
|
+
|
5
|
+
before { @token = Reuters::Client::Token.new }
|
6
|
+
|
7
|
+
subject { @token }
|
8
|
+
|
9
|
+
it_behaves_like "a client class"
|
10
|
+
|
11
|
+
it { should respond_to(:token) }
|
12
|
+
it { should respond_to(:expiration) }
|
13
|
+
|
14
|
+
it { should respond_to(:username) }
|
15
|
+
it { should respond_to(:password) }
|
16
|
+
it { should respond_to(:app_id) }
|
17
|
+
|
18
|
+
it { should respond_to(:authenticate) }
|
19
|
+
it { should respond_to(:header) }
|
20
|
+
it { should respond_to(:message) }
|
21
|
+
|
22
|
+
describe "return value of #message" do
|
23
|
+
|
24
|
+
it "should be a request builder object" do
|
25
|
+
expect(@token.message).to be_an_instance_of(Reuters::Builder)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should include necessary authentication information" do
|
29
|
+
expect(@token.message.keys).to include("ApplicationID", "Username", "Password")
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "return value of #header" do
|
35
|
+
|
36
|
+
include Savon::SpecHelper
|
37
|
+
|
38
|
+
before(:all) { savon.mock! }
|
39
|
+
after(:all) { savon.unmock! }
|
40
|
+
|
41
|
+
before do
|
42
|
+
test_response = File.read("spec/fixtures/responses/token.xml")
|
43
|
+
savon.expects(:create_service_token_1).with(message: :any).returns(test_response)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be a request builder object" do
|
47
|
+
expect(@token.header).to be_an_instance_of(Reuters::Builder)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should include the token and application id" do
|
51
|
+
expect(@token.header.authorization.keys).to include("Token", "ApplicationID")
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "when the user attempts to #authenticate" do
|
57
|
+
|
58
|
+
describe "when the credentials are valid" do
|
59
|
+
|
60
|
+
include Savon::SpecHelper
|
61
|
+
|
62
|
+
before(:all) { savon.mock! }
|
63
|
+
after(:all) { savon.unmock! }
|
64
|
+
|
65
|
+
let(:test_response) { File.read("spec/fixtures/responses/token.xml") }
|
66
|
+
|
67
|
+
before { savon.expects(:create_service_token_1).with(message: :any).returns(test_response) }
|
68
|
+
|
69
|
+
it "should return a token response object" do
|
70
|
+
expect(@token.authenticate).to be_an_instance_of Reuters::Response
|
71
|
+
end
|
72
|
+
|
73
|
+
it "authenticates the user with Reuters API" do
|
74
|
+
expect { @token.authenticate }.to_not raise_error
|
75
|
+
end
|
76
|
+
|
77
|
+
it "populates the response object" do
|
78
|
+
expect(@token.authenticate.token).to_not be_nil
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "when the credentials are not valid" do
|
84
|
+
it "raises a Savon SOAP Client Error" do
|
85
|
+
expect { @token.authenticate }.to raise_error
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|