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
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTlkMzQzN2M1ZDVmYzUxMTYyMWYzMmJiYzYxN2YyMmU3ZmE3MGM1Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTExNGYxYWFjNWE0NWQxZmYyN2FkNjgxMjJmZTI0ZmFlOGMwMjc3NQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjM3NmQxMWQyNzNmMTc5ODFlMmQwNmJkMTMyZTY0ZmVmNGRiNzYyN2E1MTMz
|
10
|
+
NWQ4YjVmYjI4NTZlZjk0MTc0NjEyYzUzMWUwMDE5ZWI0MDdjYzg5NWQ0MjM4
|
11
|
+
ZjI1Yzc0OWQxZmI3Y2U0ZDgwZGFkMzg2MTJhYzViMjNmNzg2YzY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTgwN2FmZWJmM2Q0NDdhNzc5ZWEzNDU3NWZhMjhhOTI3NTQ5NDE4MTAxYTBj
|
14
|
+
NWNjMTY3MTIxZjJlOTI5NjE4N2MwYjM3YmEwM2EwMDU4NDgwM2M2M2YyNTIw
|
15
|
+
ZmIxOGI5ODAxOTBhODVhZTM0YWIyOTUwYmIyNjA1NjljZjI5NWQ=
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
temp.rb
|
@@ -0,0 +1,23 @@
|
|
1
|
+
TrailingBlankLines:
|
2
|
+
Description: 'Checks trailing blank lines and final newline.'
|
3
|
+
Enabled: false
|
4
|
+
|
5
|
+
EmptyLinesAroundBody:
|
6
|
+
Description: "Keeps track of empty lines around expression bodies."
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
CaseEquality:
|
10
|
+
Description: 'Avoid explicit use of the case equality operator(===).'
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
ClassVars:
|
14
|
+
Description: 'Avoid the use of class variables.'
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
IndentationConsistency:
|
18
|
+
Description: 'Keep indentation straight.'
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
AccessModifierIndentation:
|
22
|
+
Description: Check indentation of private/protected visibility modifiers.
|
23
|
+
Enabled: true
|
data/.rubocop.yml
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
reuters
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p353
|
data/.travis.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0-p353
|
4
|
+
- 2.1.0
|
5
|
+
- ruby-head
|
6
|
+
notifications:
|
7
|
+
flowdock:
|
8
|
+
secure: LiGQvTUtEQyFRdM/nIDrzFI7aP5VGymCSGwrOFJ/ej//kiMc4fwjJqA+OD9JHT6bnBHx7BkFqXOMRIOBvxE2v5t0phmNJkEI9wc2Jiq6o9kdhMfVg9IQ8NTNdWK6cRqyfs96mLjFzweN+kUp6UnU/s9iXsU5XdOLYeklkC2U/sI=
|
9
|
+
before_deploy:
|
10
|
+
- yard doc
|
11
|
+
deploy:
|
12
|
+
- provider: s3
|
13
|
+
access_key_id: AKIAIWPY43DAALLVSXFQ
|
14
|
+
bucket: reuters.stockflair.com
|
15
|
+
skip_cleanup: true
|
16
|
+
local-dir: doc
|
17
|
+
edge: true
|
18
|
+
region: us-east-1
|
19
|
+
endpoint: s3-us-east-1.amazonaws.com
|
20
|
+
on:
|
21
|
+
branch: master
|
22
|
+
secret_access_key:
|
23
|
+
secure: BS3KV3AbGIxzwmEA53iceavyM6MWuDImiAeIRN0CTiT3yCOsD8m5M8dzB1Uxx0nOQNj3W47ywpD2PDciEyr8RnEjMpLSPfEe1/bBJuiWUGDI5x2w2dg5M02/kJLMS3hFVbEvdoCN2owKpWA4Gm95JvkeWH8eL3JWIi7sxHC+Kxw=
|
24
|
+
- provider: rubygems
|
25
|
+
on:
|
26
|
+
branch: master
|
27
|
+
api_key:
|
28
|
+
secure: cDRvAU7Beo+0BNfgbAcyPvaTtR4yv539sm7Lkx0HOUMi+O9L/qhQgCCzacIwUeEAf5kPj9m7HSW5BzLddiOZlQ/rQLFOSctmzeF5Swj/oQZ6OqQDhvjjtazMrNiNvNvGmchbeEBdQw46q/aaAgHsvXWNtEjYES+4+3A8YVtCn+Q=
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Contributing to Reuters
|
2
|
+
|
3
|
+
The Reuters API is vast and has lots of calls that each vary in complexity and usage. At the moment, we only have limited development time, so have only developed the calls that we use.
|
4
|
+
|
5
|
+
If you would like to develop an API Call, open an issue and please feel free to ask for assistance with building it.
|
6
|
+
|
7
|
+
You will find that most classes are well documented and we have designed the gem to be as intuitive and flexible to develop as possible.
|
8
|
+
|
9
|
+
If you find a bug, have a feature request or even want to contribute an enhancement or fix, please follow the below guidelines so that we can help you out and/or get your code merged quickly.
|
10
|
+
|
11
|
+
## If you find what looks like a bug
|
12
|
+
|
13
|
+
* Check the [GitHub issue tracker](http://github.com/stockflare/reuters/issues/) to see if anyone else has reported the issue.
|
14
|
+
* Make sure you are using the latest version of Reuters
|
15
|
+
* If you are still having an issue, create an issue including:
|
16
|
+
* Information you will need to reproduce and diagnose the problem
|
17
|
+
|
18
|
+
## If you want to contribute an enhancement or a fix
|
19
|
+
|
20
|
+
0. Discuss any major enhancement with the project moderator.
|
21
|
+
0. Write your [Spec tests](http://betterspecs.org/).
|
22
|
+
0. Write or modify any affected documentation.
|
23
|
+
0. Ensure that your tests work and your documentation is complete.
|
24
|
+
|
25
|
+
### General Contributition Guidelines
|
26
|
+
|
27
|
+
We follow the standard GitHub fork & pull request approach to open source collaboration. You can find a description on how this works on the [gun.io blog](https://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
|
28
|
+
|
29
|
+
In a nutshell:
|
30
|
+
|
31
|
+
0. Fork it.
|
32
|
+
0. Create your feature branch (`git checkout -b feature/my-new-feature`).
|
33
|
+
0. Commit your changes (`git commit -am 'Add some feature'`) and [reference any issues](https://github.com/blog/831-issues-2-0-the-next-generation).
|
34
|
+
0. Push to your branch (`git push origin my-new-feature`).
|
35
|
+
0. Send a new Pull Request describing what you have done and why, in detail.
|
36
|
+
|
37
|
+
**IMPORTANT**: By submitting a patch, you agree to allow the project owners to license your work under the the terms of the MIT license. A copy of this license is provided in the root of the repository.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Stockflare Ltd.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
# Thomson Reuters API Client
|
2
|
+
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/Stockflare/reuters/badge.png?branch=master)](https://coveralls.io/r/Stockflare/reuters?branch=master) [![Build Status](https://travis-ci.org/Stockflare/reuters.svg?branch=master)](https://travis-ci.org/Stockflare/reuters) [![Dependency Status](https://gemnasium.com/Stockflare/reuters.svg)](https://gemnasium.com/Stockflare/reuters) [![Code Climate](https://codeclimate.com/github/Stockflare/reuters.png)](https://codeclimate.com/github/Stockflare/reuters)
|
4
|
+
|
5
|
+
|
6
|
+
Uses the [Reuter's TRKD API](http://thomsonreuters.com/knowledge-direct/) to grab financial data for stocks, such as quotes, estimates and snapshots.
|
7
|
+
|
8
|
+
This gem will only work if you have been provided with valid credentials by Reuters. See below for more information about configuring your login credentials.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'reuters'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle install
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
This gem provides no CLI and is intended to be used in conjunction with other applications.
|
23
|
+
|
24
|
+
### Configuring Credentials
|
25
|
+
|
26
|
+
Before any API calls will work, you need to configure the library with valid credentials. Once credentials have been configured, an access token will be retrieved from the Reuter' API upon a client request.
|
27
|
+
|
28
|
+
```
|
29
|
+
Reuters.configure do |config|
|
30
|
+
|
31
|
+
config.credentials do |login|
|
32
|
+
# Set username
|
33
|
+
login.username = "my_username"
|
34
|
+
|
35
|
+
# Set my password
|
36
|
+
login.password = "my_super_secret_password"
|
37
|
+
|
38
|
+
# Set application ID
|
39
|
+
login.application_id = "application_id"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### Configuring Namespaces and WSDL endpoints
|
46
|
+
|
47
|
+
All the default configurations point towards the SOAP11 service that Reuters provides. In our experience, we were unable to get their SOAP 2 service working reliably.
|
48
|
+
|
49
|
+
Each class has a `#configure` method that can be used to adjust the endpoints and other attributes of the class, as shown in the example below.
|
50
|
+
|
51
|
+
```
|
52
|
+
Reuters::Namespaces::Search::Equity.configure do |c|
|
53
|
+
c.name 'Search/A_Different_Equity_1'
|
54
|
+
end
|
55
|
+
|
56
|
+
```
|
57
|
+
|
58
|
+
### Making A Request
|
59
|
+
|
60
|
+
There are three components to each request made to the Reuter's API. The `Request` object, the `Client` and finally the `Response`. Because Reuters API calls can become quite complex it would become arduous to build a separate "helper" method for every possible variation on every possible call.
|
61
|
+
|
62
|
+
#### Building A Request
|
63
|
+
|
64
|
+
All requests to the Reuters API are XML-based. You are responsible for building the request (except for adding the "xmlns" attributes; which should be handled by the client). Every example documented below, can be nested up to n-depth. I have laid out some examples and their XML-counterparts to help you get started with the request builder.
|
65
|
+
|
66
|
+
**Note: These are only examples to help you get started with the request builder, and are not valid API Calls**
|
67
|
+
|
68
|
+
```
|
69
|
+
<Query>
|
70
|
+
<ExchangeCode Include="true">NYSE</ExchangeCode>
|
71
|
+
</Query>
|
72
|
+
```
|
73
|
+
|
74
|
+
```
|
75
|
+
message = Reuters::Builder.new
|
76
|
+
message.query.exchange_code = "NYSE"
|
77
|
+
message.query.exchange_code include: true
|
78
|
+
```
|
79
|
+
|
80
|
+
You can also pass a block to the builder to achieve the same result:
|
81
|
+
|
82
|
+
```
|
83
|
+
message = Reuters::Builder.new do |body|
|
84
|
+
body.query do |query|
|
85
|
+
query.exchange_code = "NYSE"
|
86
|
+
query.exchange_code include: true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
---
|
92
|
+
|
93
|
+
The builder allows you to very quickly define nested elements with attributes:
|
94
|
+
|
95
|
+
```
|
96
|
+
<This>
|
97
|
+
<Is>
|
98
|
+
<A>
|
99
|
+
<Nested>
|
100
|
+
<Element Hello="world">
|
101
|
+
</Element>
|
102
|
+
</Nested>
|
103
|
+
</A>
|
104
|
+
</Is>
|
105
|
+
</This>
|
106
|
+
```
|
107
|
+
|
108
|
+
```
|
109
|
+
message = Reuters::Builder.new
|
110
|
+
message.this.is.a.nested.element hello: "world"
|
111
|
+
```
|
112
|
+
|
113
|
+
---
|
114
|
+
|
115
|
+
The Request Builder also supports building arrays of elements with only attributes, content or both.
|
116
|
+
|
117
|
+
```
|
118
|
+
<Filter>
|
119
|
+
<ExchangeCode Include="true">
|
120
|
+
<StringValue Value="NSQ" Negated="false" />
|
121
|
+
<StringValue Value="GER" Negated="true" />
|
122
|
+
<StringValue Value="LSE" Negated="false" />
|
123
|
+
</ExchangeCode>
|
124
|
+
</Filter>
|
125
|
+
```
|
126
|
+
|
127
|
+
```
|
128
|
+
Reuters::Builder.new do |body|
|
129
|
+
body.filter do |filter|
|
130
|
+
filter.exchange_code include: true do |ex|
|
131
|
+
ex.stringValue [
|
132
|
+
{ value: "NSQ", negated: false },
|
133
|
+
{ value: "GER", negated: true },
|
134
|
+
{ value: "LSE", negated: false },
|
135
|
+
]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
```
|
142
|
+
<Filter>
|
143
|
+
<ExchangeCode Include="true">
|
144
|
+
<StringValue Negated="false">NSQ</StringValue>
|
145
|
+
<StringValue Negated="true">GER</StringValue>
|
146
|
+
<StringValue Negated="false">LSE</StringValue>
|
147
|
+
</ExchangeCode>
|
148
|
+
</Filter>
|
149
|
+
```
|
150
|
+
|
151
|
+
```
|
152
|
+
Reuters::Builder.new do |body|
|
153
|
+
body.filter do |filter|
|
154
|
+
filter.exchange_code include: true do |ex|
|
155
|
+
ex.stringValue [
|
156
|
+
{ negated: false },
|
157
|
+
{ negated: true },
|
158
|
+
{ negated: false },
|
159
|
+
]
|
160
|
+
ex.stringValue = ["NSQ", "GER", "LSE"]
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
166
|
+
The request that you build, will be sent inside the request element. So there is no need to define any header information.
|
167
|
+
|
168
|
+
```
|
169
|
+
<Body>
|
170
|
+
<GetEquityQuote_Request_1 ...>
|
171
|
+
<!-- Your request will appear here -->
|
172
|
+
</GetEquityQuote_Request_1>
|
173
|
+
</Body>
|
174
|
+
```
|
175
|
+
|
176
|
+
#### Sending the Request to a Client
|
177
|
+
|
178
|
+
When you initialize a client that requires a valid access token, the client will automagically take care of obtaining a token for you when the request is sent (providing you have valid credentials configured).
|
179
|
+
|
180
|
+
```
|
181
|
+
Reuters::Credentials.configure do |c|
|
182
|
+
c.username = "my_username"
|
183
|
+
c.password = "my_password"
|
184
|
+
c.app_id = "my_app_id"
|
185
|
+
end
|
186
|
+
|
187
|
+
message = Reuters::Builder.new do |body|
|
188
|
+
...
|
189
|
+
end
|
190
|
+
|
191
|
+
client = Reuters::Client::Search::Equity.new
|
192
|
+
|
193
|
+
client.operations #=> [:get_equity_quote_1]
|
194
|
+
|
195
|
+
client.get_equity_quote_1(message)
|
196
|
+
```
|
197
|
+
|
198
|
+
#### Using the Response
|
199
|
+
|
200
|
+
Different Response classes parse data slightly differently depending on how it is intended to be used. You will need to take a look at the documentation for the Response corresponding to your Client.
|
201
|
+
|
202
|
+
|
203
|
+
## Contributing
|
204
|
+
|
205
|
+
The Reuters API is vast and has lots of calls that each vary in complexity and usage. At the moment, we only have limited development time, so have only developed the calls that we use.
|
206
|
+
|
207
|
+
If you would like to develop an API Call, open an issue and please feel free to ask for assistance with building it.
|
208
|
+
|
209
|
+
If you find a bug, have a feature request or even want to contribute an enhancement or fix, please follow the contributing guidelines included in the repository.
|
data/Rakefile
ADDED
data/lib/reuters.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
4
|
+
require 'active_support/core_ext/module/delegation'
|
5
|
+
require 'active_support/core_ext/hash/deep_merge'
|
6
|
+
require 'active_support/core_ext/string/inflections'
|
7
|
+
require 'active_support/inflector'
|
8
|
+
|
9
|
+
require 'reuters/namespaces'
|
10
|
+
require 'reuters/wsdls'
|
11
|
+
require 'reuters/credentials'
|
12
|
+
require 'reuters/version'
|
13
|
+
require 'reuters/builder'
|
14
|
+
require 'reuters/response'
|
15
|
+
require 'reuters/client'
|
16
|
+
|
17
|
+
# Ruby Gem for interacting with the Thomson Reuters
|
18
|
+
# Knowledge Direct API.
|
19
|
+
#
|
20
|
+
# @example Configuring the Reuters Gem.
|
21
|
+
# Reuters.configure do |config|
|
22
|
+
# config.credentials do |login|
|
23
|
+
# # Set username
|
24
|
+
# login.username = "my_username"
|
25
|
+
# # Set my password
|
26
|
+
# login.password = "my_super_secret_password"
|
27
|
+
# # Set application ID
|
28
|
+
# login.application_id = "application_id"
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
module Reuters
|
32
|
+
|
33
|
+
# @!attribute namespaces_endpoint
|
34
|
+
# @!scope class
|
35
|
+
# The endpoint that will be used to contact Reuters to determine
|
36
|
+
# the fully resolved namespaces.
|
37
|
+
# @return [String] The configured namespace endpoint.
|
38
|
+
|
39
|
+
# @!attribute wsdl_endpoint
|
40
|
+
# @!scope class
|
41
|
+
# The WSDL endpoint that will be used to contact Reuters.
|
42
|
+
# @return [String] The configured WSDL endpoint.
|
43
|
+
|
44
|
+
# @!attribute debug
|
45
|
+
# @!scope class
|
46
|
+
# Determines if debugging mode is enabled for the Reuters gem.
|
47
|
+
# If enabled, any Reuters API requests will debug to STDOUT.
|
48
|
+
# @return [Boolean] False if disabled, true if enabled.
|
49
|
+
|
50
|
+
# Sets whether debugging is enabled for the Reuters API calls.
|
51
|
+
# By default, this value is set to false as to not make any output
|
52
|
+
# unnecessarily noisy.
|
53
|
+
mattr_accessor :debug
|
54
|
+
self.debug = false
|
55
|
+
|
56
|
+
# Set the default Reuters API namespace endpoint. This is the
|
57
|
+
# standard default for most API requests and shouldn't
|
58
|
+
# really need to be changed.
|
59
|
+
mattr_accessor :namespaces_endpoint
|
60
|
+
self.namespaces_endpoint = 'http://www.reuters.com/ns'
|
61
|
+
|
62
|
+
# Set the default Reuter's API WSDL endpoint. This endpoint
|
63
|
+
# sets compatibility for SOAP 1.1 requests and will need to
|
64
|
+
# be changed if you wish to use SOAP 1.2 with the Reuter's API.
|
65
|
+
mattr_accessor :wsdl_endpoint
|
66
|
+
self.wsdl_endpoint = 'http://api.rkd.reuters.com/schemas'
|
67
|
+
|
68
|
+
# Sets Reuters specific acronyms, such as ISIN and RIC.
|
69
|
+
# The API requests these acronyms to be in uppercase
|
70
|
+
# rather than camelcase.
|
71
|
+
mattr_accessor :reuters_acronyms
|
72
|
+
def self.reuters_acronyms=(val)
|
73
|
+
ActiveSupport::Inflector.inflections do |i|
|
74
|
+
val.each { |v| i.acronym v }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Set the default Reuters Acronyms that consistently appear
|
79
|
+
# throughout the API.
|
80
|
+
self.reuters_acronyms = %w(ID RIC ISIN)
|
81
|
+
|
82
|
+
# Helper to configure the Reuters gem.
|
83
|
+
#
|
84
|
+
# @yield [Reuters] Yields the {Reuters} module.
|
85
|
+
def self.configure
|
86
|
+
yield self
|
87
|
+
end
|
88
|
+
|
89
|
+
# Yield the {Reuters::Credentials} class as a configurable
|
90
|
+
# block. This block helps clients to set their credentials
|
91
|
+
# easily.
|
92
|
+
#
|
93
|
+
# @yield [Reuters::Credentials] Yields the {Credentials} module.
|
94
|
+
def self.credentials(&block)
|
95
|
+
self::Credentials.configure(&block)
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|