twelvedata_ruby 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/README.md +125 -0
- data/Rakefile +12 -0
- data/bin/console +22 -0
- data/bin/setup +8 -0
- data/doc/TwelvedataRuby.html +353 -0
- data/doc/TwelvedataRuby/BadRequestResponseError.html +178 -0
- data/doc/TwelvedataRuby/Client.html +1443 -0
- data/doc/TwelvedataRuby/Endpoint.html +1478 -0
- data/doc/TwelvedataRuby/EndpointError.html +247 -0
- data/doc/TwelvedataRuby/EndpointNameError.html +167 -0
- data/doc/TwelvedataRuby/EndpointParametersKeysError.html +167 -0
- data/doc/TwelvedataRuby/EndpointRequiredParametersError.html +167 -0
- data/doc/TwelvedataRuby/Error.html +318 -0
- data/doc/TwelvedataRuby/ForbiddenResponseError.html +178 -0
- data/doc/TwelvedataRuby/InternalServerResponseErro.html +178 -0
- data/doc/TwelvedataRuby/NotFoundResponseError.html +178 -0
- data/doc/TwelvedataRuby/PageNotFoundResponseError.html +178 -0
- data/doc/TwelvedataRuby/ParameterTooLongResponseError.html +178 -0
- data/doc/TwelvedataRuby/Request.html +683 -0
- data/doc/TwelvedataRuby/Response.html +1622 -0
- data/doc/TwelvedataRuby/ResponseError.html +565 -0
- data/doc/TwelvedataRuby/TooManyRequestsResponseError.html +178 -0
- data/doc/TwelvedataRuby/UnauthorizedResponseError.html +178 -0
- data/doc/TwelvedataRuby/Utils.html +503 -0
- data/doc/_index.html +315 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +497 -0
- data/doc/file.README.html +194 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +194 -0
- data/doc/js/app.js +314 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +707 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/twelvedata_ruby.rb +43 -0
- data/lib/twelvedata_ruby/client.rb +148 -0
- data/lib/twelvedata_ruby/endpoint.rb +271 -0
- data/lib/twelvedata_ruby/error.rb +90 -0
- data/lib/twelvedata_ruby/request.rb +54 -0
- data/lib/twelvedata_ruby/response.rb +132 -0
- data/lib/twelvedata_ruby/utils.rb +36 -0
- data/twelvedata_ruby.gemspec +37 -0
- metadata +201 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 875e9a7aa6d49ba856df319540c987e48ac4fd04ab8cf10f80d804ac685b27c0
|
4
|
+
data.tar.gz: 3db748bb0a8945897b87748bd49705a9e435523f71c9c572eadd38363ff5b044
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da38162ec79f04bd05c69baa4ee8aa26c2419f557503fe6850f7babd3b10125536bc54e444000a8a8876ea99c754f38b195b6f5227130081f258945ef0bae7c5
|
7
|
+
data.tar.gz: a3bb92af00adeff804939396c2423a087bccfde71c12905b2a5e047aa4d93c5b446eed6ae123310490e7b9aacd23f6beaa2d5fa7314304a33163ff6d03a35f58
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
twelvedata_ruby (0.1.1)
|
5
|
+
httpx (~> 0.14.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
crack (0.4.5)
|
14
|
+
rexml
|
15
|
+
diff-lcs (1.4.4)
|
16
|
+
docile (1.4.0)
|
17
|
+
hashdiff (1.0.1)
|
18
|
+
http-2-next (0.4.3)
|
19
|
+
httpx (0.14.5)
|
20
|
+
http-2-next (>= 0.4.1)
|
21
|
+
timers
|
22
|
+
parallel (1.20.1)
|
23
|
+
parser (3.0.1.1)
|
24
|
+
ast (~> 2.4.1)
|
25
|
+
public_suffix (4.0.6)
|
26
|
+
rainbow (3.0.0)
|
27
|
+
rake (13.0.3)
|
28
|
+
regexp_parser (2.1.1)
|
29
|
+
rexml (3.2.5)
|
30
|
+
rspec (3.10.0)
|
31
|
+
rspec-core (~> 3.10.0)
|
32
|
+
rspec-expectations (~> 3.10.0)
|
33
|
+
rspec-mocks (~> 3.10.0)
|
34
|
+
rspec-core (3.10.1)
|
35
|
+
rspec-support (~> 3.10.0)
|
36
|
+
rspec-expectations (3.10.1)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-mocks (3.10.2)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-support (3.10.2)
|
43
|
+
rubocop (1.17.0)
|
44
|
+
parallel (~> 1.10)
|
45
|
+
parser (>= 3.0.0.0)
|
46
|
+
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
regexp_parser (>= 1.8, < 3.0)
|
48
|
+
rexml
|
49
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
50
|
+
ruby-progressbar (~> 1.7)
|
51
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
52
|
+
rubocop-ast (1.7.0)
|
53
|
+
parser (>= 3.0.1.1)
|
54
|
+
ruby-progressbar (1.11.0)
|
55
|
+
simplecov (0.21.2)
|
56
|
+
docile (~> 1.1)
|
57
|
+
simplecov-html (~> 0.11)
|
58
|
+
simplecov_json_formatter (~> 0.1)
|
59
|
+
simplecov-html (0.12.3)
|
60
|
+
simplecov_json_formatter (0.1.3)
|
61
|
+
timers (4.3.3)
|
62
|
+
unicode-display_width (2.0.0)
|
63
|
+
webmock (3.13.0)
|
64
|
+
addressable (>= 2.3.6)
|
65
|
+
crack (>= 0.3.2)
|
66
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
x86_64-darwin-18
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
rake (~> 13.0, >= 13.0.3)
|
73
|
+
rspec (~> 3.10.0)
|
74
|
+
rubocop (~> 1.17.0)
|
75
|
+
simplecov (~> 0.21, >= 0.21.2)
|
76
|
+
twelvedata_ruby!
|
77
|
+
webmock (~> 3.13, >= 3.13.0)
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
2.2.17
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# TwelvedataRuby
|
2
|
+
|
3
|
+
|
4
|
+
TwelvedataRuby is a Ruby library that exposes some convenient ways to access Twelve Data API to get information on stock, forex, crypto, and other financial market data. In order to do so, a free API key is required which can be easily requested [here](https://twelvedata.com/pricing). Visit their [API's full documentation](https://twelvedata.com/doc)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'twelvedata_ruby'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install twelvedata_ruby
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
The preferred way to include the Twelve Data API key in the request payload is to assign it to an ENVIRONMENT variable which your Ruby application can fetch if none was explicitly assigned. The default ENVIRONMENTt variable name is `TWELVEDATA_API_KEY` but you can configure this to any other value using the `#apikey_env_var_name=` setter method.
|
25
|
+
|
26
|
+
To get hold of the singleton `TwelvedataRuby::Client.instance`, you can directly used that inherited instance method from the mixed in `Singleton` module or thru the gem's module helper class method:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require "twelvedata_ruby"
|
30
|
+
client = TwelvedataRuby.client
|
31
|
+
```
|
32
|
+
|
33
|
+
By not passing anything to the options method parameters, the `client` instance attributes will have default values. Though you can still set different values to the attributes through their helper setter methods:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
client.apikey = "twelvedata-apikey"
|
37
|
+
client.apikey_env_var_name = "the_environment_variable_name" # the helper getter method will upcase the value
|
38
|
+
client.connect_timeout = 300 # can also accept "300"
|
39
|
+
```
|
40
|
+
|
41
|
+
or simply set them all at once:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require "twelvedata_ruby"
|
45
|
+
client = TwelvedataRuby.client(apikey: "twelvedata-apikey", connect_timeout: 300)
|
46
|
+
# or client = TwelvedataRuby.client(apikey_env_var_name: "the_environment_variable_name", connect_timeout: 300)
|
47
|
+
```
|
48
|
+
|
49
|
+
The default values though are sufficient already.
|
50
|
+
|
51
|
+
Getting any type of financial data then from the API, simply invoke any valid endpoint name to the client instance. For example, to fetch some data for `GOOG` stock symbol using quote, timeseries, price, and etd API endpoints:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# 1. response content-type will be :csv
|
55
|
+
client.quote(symbol: "GOOG", format: :csv)
|
56
|
+
# 2. assigns custom attachment name
|
57
|
+
client.timeseries(symbol: "GOOG", interval: "1hour", format: :csv, filename: "google_timeseries_1hour.csv")
|
58
|
+
# 3. the content-type format will be :json
|
59
|
+
client.price(symbol: "GOOG")
|
60
|
+
# 4. the passed apikey is the used in the request payload
|
61
|
+
client.etd(symbol: "GOOG", apikey: "overrides-whatever-is-the-current-apikey")
|
62
|
+
# 5. an example of invocation which the API will respond with 401 error code
|
63
|
+
client.etd(symbol: "GOOG", apikey: "invalid-api-key")
|
64
|
+
# 6. still exactly the same object with client
|
65
|
+
TwelvedataRuby.client.api_usage
|
66
|
+
# 7. an invalid request wherein the required query parameter :interval is missing
|
67
|
+
TwelvedataRuby.client.timeseries(symbol: "GOOG")
|
68
|
+
# 8. an invalid request because it contains an invalid parameter
|
69
|
+
client.price(symbol: "GOOG", invalid_parameter: "value")
|
70
|
+
# 9. invoking a non-existing API endpoint will cause a NoMethodError exception
|
71
|
+
client.price(symbol: "GOOG", invalid_parameter: "value")
|
72
|
+
```
|
73
|
+
|
74
|
+
All of the invocations possible return instance value is one of the following:
|
75
|
+
- `TwelvedataRuby::Response` instance object which `#error` instance getter method can return a nil or kind of `TwelvedataRuby::ResponseError` instance if the API, or the API web server responded with some errors. #5 is an example which the API response will have status error with 401 code. `TwelvedataRuby::Response` resolves this into `TwelvedataRuby::UnauthorizedResponseError` instance.
|
76
|
+
- `TwelvedataRuby::ResponseError` instance object itself when some error occurred that's not coming from the API
|
77
|
+
- a Hash instance which has an `:errors` key that contains instances of kind `TwelvedataRuby::EndpointError`. This is an invalid request scenario which the #7, #8, and #9 examples. No actual API request was sent in this scenario.
|
78
|
+
|
79
|
+
On first invocation of a valid endpoint name, a `TwelvedataRuby::Client` instance method of the same name is dynamically defined. So in effect, ideally, there can be a one-to-one mapping of all the API endpoints with their respective parameters constraints. Please visit their excellent API documentation to know more of the endpoint details here https://twelvedata.com/doc. Or if you're in a hurry, you can list the endpoints definitions:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
TwelvedataRuby::Endpoint.definitions
|
83
|
+
```
|
84
|
+
|
85
|
+
Another way of fetching data from API endpoints is by building a valid `TwelvedataRuby::Request` instance, then invoke `#fetch` on this instance. The possible return values are the same with the above examples.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
quote_req = TwelvedataRuby::Request.new(:quote, symbol: "IBM")
|
89
|
+
quote_resp = quote_req.fetch
|
90
|
+
timeseries_req = TwelvedataRuby::Request.new(:quote, symbol: "IBM", interval: "1hour", format: :csv)
|
91
|
+
timeseries_resp = timeseries_req.fetch
|
92
|
+
etd_req = TwelvedataRuby::Request.new(:etd, symbol: "GOOG")
|
93
|
+
etd_resp = etd_req.fetch
|
94
|
+
# or just simply chain
|
95
|
+
price_resp = TwelvedataRuby::Request.new(:price, symbol: "GOOG").fetch
|
96
|
+
```
|
97
|
+
|
98
|
+
An advantage of building a valid request instance first then invoke the `#fetch` on it is you actually have an option to not send the request one by one BUT rather send them to the API server all at once simultaneously (might be in parallel). Like so taking the above examples' request instance objects, send them all simultaneously
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
# returns a 3 element array of Response objects
|
102
|
+
resp_objects_array = TwelvedataRuby::Client.request(quote_req, timeseries_req, etd_req)
|
103
|
+
```
|
104
|
+
|
105
|
+
Be caution that the above example, depending on the number request objects sent and how large the responses, hitting the daily limit is likely possible. But then again if you have several api keys you might be able to supply each request object with its own apikey. :)
|
106
|
+
|
107
|
+
|
108
|
+
TODO: write more documenation especially the response object
|
109
|
+
|
110
|
+
## Contributing
|
111
|
+
|
112
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/twelvedata_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/twelvedata_ruby/blob/master/CODE_OF_CONDUCT.md).
|
113
|
+
|
114
|
+
## License
|
115
|
+
|
116
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
117
|
+
|
118
|
+
## Code of Conduct
|
119
|
+
|
120
|
+
Everyone interacting in the TwelvedataRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/twelvedata_ruby/blob/master/CODE_OF_CONDUCT.md).
|
121
|
+
|
122
|
+
|
123
|
+
# Notice
|
124
|
+
|
125
|
+
This is not an offical Twelve Data ruby library and the author of this gem is not affiliated with Twelve Data in any way, shape or form. Twelve Data APIs and data are Copyright © 2020 Twelve Data Pte. Ltd
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "twelvedata_ruby"
|
6
|
+
|
7
|
+
require "irb"
|
8
|
+
|
9
|
+
def reload!
|
10
|
+
root_dir = File.expand_path("..", __dir__)
|
11
|
+
orig_verbose = $VERBOSE
|
12
|
+
# suppresss annoying already initialized warnings
|
13
|
+
$VERBOSE = nil
|
14
|
+
puts "Reloading with suppressed warning messages about 'already initialized'..."
|
15
|
+
%w[lib].each do |dir|
|
16
|
+
Dir.glob("#{root_dir}/#{dir}/**/*.rb").each {|f| load(f) }
|
17
|
+
end
|
18
|
+
$VERBOSE = orig_verbose
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,353 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: TwelvedataRuby
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.26
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "TwelvedataRuby";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index (T)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">TwelvedataRuby</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: TwelvedataRuby
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/twelvedata_ruby.rb<span class="defines">,<br />
|
82
|
+
lib/twelvedata_ruby/error.rb,<br /> lib/twelvedata_ruby/utils.rb,<br /> lib/twelvedata_ruby/client.rb,<br /> lib/twelvedata_ruby/request.rb,<br /> lib/twelvedata_ruby/endpoint.rb,<br /> lib/twelvedata_ruby/response.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
89
|
+
<div class="discussion">
|
90
|
+
|
91
|
+
<p>The one module that all the classes and modules of this gem are namespaced</p>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
<div class="tags">
|
97
|
+
|
98
|
+
|
99
|
+
</div><h2>Defined Under Namespace</h2>
|
100
|
+
<p class="children">
|
101
|
+
|
102
|
+
|
103
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="TwelvedataRuby/Utils.html" title="TwelvedataRuby::Utils (module)">Utils</a></span>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="TwelvedataRuby/BadRequestResponseError.html" title="TwelvedataRuby::BadRequestResponseError (class)">BadRequestResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/Client.html" title="TwelvedataRuby::Client (class)">Client</a></span>, <span class='object_link'><a href="TwelvedataRuby/Endpoint.html" title="TwelvedataRuby::Endpoint (class)">Endpoint</a></span>, <span class='object_link'><a href="TwelvedataRuby/EndpointError.html" title="TwelvedataRuby::EndpointError (class)">EndpointError</a></span>, <span class='object_link'><a href="TwelvedataRuby/EndpointNameError.html" title="TwelvedataRuby::EndpointNameError (class)">EndpointNameError</a></span>, <span class='object_link'><a href="TwelvedataRuby/EndpointParametersKeysError.html" title="TwelvedataRuby::EndpointParametersKeysError (class)">EndpointParametersKeysError</a></span>, <span class='object_link'><a href="TwelvedataRuby/EndpointRequiredParametersError.html" title="TwelvedataRuby::EndpointRequiredParametersError (class)">EndpointRequiredParametersError</a></span>, <span class='object_link'><a href="TwelvedataRuby/Error.html" title="TwelvedataRuby::Error (class)">Error</a></span>, <span class='object_link'><a href="TwelvedataRuby/ForbiddenResponseError.html" title="TwelvedataRuby::ForbiddenResponseError (class)">ForbiddenResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/InternalServerResponseErro.html" title="TwelvedataRuby::InternalServerResponseErro (class)">InternalServerResponseErro</a></span>, <span class='object_link'><a href="TwelvedataRuby/NotFoundResponseError.html" title="TwelvedataRuby::NotFoundResponseError (class)">NotFoundResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/PageNotFoundResponseError.html" title="TwelvedataRuby::PageNotFoundResponseError (class)">PageNotFoundResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/ParameterTooLongResponseError.html" title="TwelvedataRuby::ParameterTooLongResponseError (class)">ParameterTooLongResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/Request.html" title="TwelvedataRuby::Request (class)">Request</a></span>, <span class='object_link'><a href="TwelvedataRuby/Response.html" title="TwelvedataRuby::Response (class)">Response</a></span>, <span class='object_link'><a href="TwelvedataRuby/ResponseError.html" title="TwelvedataRuby::ResponseError (class)">ResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/TooManyRequestsResponseError.html" title="TwelvedataRuby::TooManyRequestsResponseError (class)">TooManyRequestsResponseError</a></span>, <span class='object_link'><a href="TwelvedataRuby/UnauthorizedResponseError.html" title="TwelvedataRuby::UnauthorizedResponseError (class)">UnauthorizedResponseError</a></span>
|
108
|
+
|
109
|
+
|
110
|
+
</p>
|
111
|
+
|
112
|
+
|
113
|
+
<h2>
|
114
|
+
Constant Summary
|
115
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
116
|
+
</h2>
|
117
|
+
|
118
|
+
<dl class="constants">
|
119
|
+
|
120
|
+
<dt id="VERSION-constant" class="">VERSION =
|
121
|
+
<div class="docstring">
|
122
|
+
<div class="discussion">
|
123
|
+
|
124
|
+
<p>Holds the current version</p>
|
125
|
+
|
126
|
+
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
<div class="tags">
|
130
|
+
|
131
|
+
<p class="tag_title">Returns:</p>
|
132
|
+
<ul class="return">
|
133
|
+
|
134
|
+
<li>
|
135
|
+
|
136
|
+
|
137
|
+
<span class='type'>(<tt>String</tt>)</span>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
—
|
142
|
+
<div class='inline'>
|
143
|
+
<p>version number</p>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
</li>
|
147
|
+
|
148
|
+
</ul>
|
149
|
+
|
150
|
+
</div>
|
151
|
+
</dt>
|
152
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1.0</span><span class='tstring_end'>"</span></span></pre></dd>
|
153
|
+
|
154
|
+
</dl>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
<h2>
|
165
|
+
Class Method Summary
|
166
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
167
|
+
</h2>
|
168
|
+
|
169
|
+
<ul class="summary">
|
170
|
+
|
171
|
+
<li class="public ">
|
172
|
+
<span class="summary_signature">
|
173
|
+
|
174
|
+
<a href="#client-class_method" title="client (class method)">.<strong>client</strong>(**options) ⇒ Client </a>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
</span>
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<span class="summary_desc"><div class='inline'>
|
189
|
+
<p>A convenient and clearer way of getting and overriding default attribute values of the singleton `Client.instance`.</p>
|
190
|
+
</div></span>
|
191
|
+
|
192
|
+
</li>
|
193
|
+
|
194
|
+
|
195
|
+
</ul>
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
<div id="class_method_details" class="method_details_list">
|
201
|
+
<h2>Class Method Details</h2>
|
202
|
+
|
203
|
+
|
204
|
+
<div class="method_details first">
|
205
|
+
<h3 class="signature first" id="client-class_method">
|
206
|
+
|
207
|
+
.<strong>client</strong>(**options) ⇒ <tt><span class='object_link'><a href="TwelvedataRuby/Client.html" title="TwelvedataRuby::Client (class)">Client</a></span></tt>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</h3><div class="docstring">
|
214
|
+
<div class="discussion">
|
215
|
+
|
216
|
+
<p>A convenient and clearer way of getting and overriding default attribute values of the singleton `Client.instance`</p>
|
217
|
+
|
218
|
+
|
219
|
+
</div>
|
220
|
+
</div>
|
221
|
+
<div class="tags">
|
222
|
+
<p class="tag_title">Parameters:</p>
|
223
|
+
<ul class="param">
|
224
|
+
|
225
|
+
<li>
|
226
|
+
|
227
|
+
<span class='name'>options</span>
|
228
|
+
|
229
|
+
|
230
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
—
|
235
|
+
<div class='inline'>
|
236
|
+
<p>the optional Hash object that may contain values to override the defaults</p>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
</li>
|
240
|
+
|
241
|
+
</ul>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
<p class="tag_title">Options Hash (<tt>**options</tt>):</p>
|
247
|
+
<ul class="option">
|
248
|
+
|
249
|
+
<li>
|
250
|
+
<span class="name">:apikey</span>
|
251
|
+
<span class="type">(<tt>Symbol</tt>, <tt>String</tt>)</span>
|
252
|
+
<span class="default">
|
253
|
+
|
254
|
+
</span>
|
255
|
+
|
256
|
+
— <div class='inline'>
|
257
|
+
<p>the private key from Twelvedata API key</p>
|
258
|
+
</div>
|
259
|
+
|
260
|
+
</li>
|
261
|
+
|
262
|
+
<li>
|
263
|
+
<span class="name">:connect_timeout</span>
|
264
|
+
<span class="type">(<tt>Integer</tt>, <tt>String</tt>)</span>
|
265
|
+
<span class="default">
|
266
|
+
|
267
|
+
</span>
|
268
|
+
|
269
|
+
— <div class='inline'>
|
270
|
+
<p>milliseconds</p>
|
271
|
+
|
272
|
+
<p>@example Passing a nil options</p>
|
273
|
+
|
274
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="" title="TwelvedataRuby (module)">TwelvedataRuby</a></span></span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span>
|
275
|
+
</code></pre>
|
276
|
+
|
277
|
+
<p>The singleton instance object returned will use the default values for its attributes</p>
|
278
|
+
|
279
|
+
<p>@example Passing values of `:apikey` and `:connect_timeout`</p>
|
280
|
+
|
281
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="" title="TwelvedataRuby (module)">TwelvedataRuby</a></span></span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span><span class='lparen'>(</span><span class='label'>apikey:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>my-twelvedata-apikey</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>connect_timeout:</span> <span class='int'>3000</span><span class='rparen'>)</span>
|
282
|
+
</code></pre>
|
283
|
+
|
284
|
+
<p>@example or, chain with other Client instance method</p>
|
285
|
+
|
286
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="" title="TwelvedataRuby (module)">TwelvedataRuby</a></span></span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span><span class='lparen'>(</span><span class='label'>apikey:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>my-twelvedata-apikey</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>connect_timeout:</span> <span class='int'>3000</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_quote'>quote</span><span class='lparen'>(</span><span class='label'>symbol:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>IBM</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
287
|
+
</code></pre>
|
288
|
+
|
289
|
+
<p>In the last example, calling `#quote`, a valid API endpoint, an instance method with the same name was dynamically defined and then fired up an API request to Twelvedata.</p>
|
290
|
+
</div>
|
291
|
+
|
292
|
+
</li>
|
293
|
+
|
294
|
+
</ul>
|
295
|
+
|
296
|
+
|
297
|
+
<p class="tag_title">Returns:</p>
|
298
|
+
<ul class="return">
|
299
|
+
|
300
|
+
<li>
|
301
|
+
|
302
|
+
|
303
|
+
<span class='type'>(<tt><span class='object_link'><a href="TwelvedataRuby/Client.html" title="TwelvedataRuby::Client (class)">Client</a></span></tt>)</span>
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
—
|
308
|
+
<div class='inline'>
|
309
|
+
<p>singleton instance</p>
|
310
|
+
</div>
|
311
|
+
|
312
|
+
</li>
|
313
|
+
|
314
|
+
</ul>
|
315
|
+
|
316
|
+
</div><table class="source_code">
|
317
|
+
<tr>
|
318
|
+
<td>
|
319
|
+
<pre class="lines">
|
320
|
+
|
321
|
+
|
322
|
+
38
|
323
|
+
39
|
324
|
+
40
|
325
|
+
41
|
326
|
+
42</pre>
|
327
|
+
</td>
|
328
|
+
<td>
|
329
|
+
<pre class="code"><span class="info file"># File 'lib/twelvedata_ruby.rb', line 38</span>
|
330
|
+
|
331
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
332
|
+
<span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="TwelvedataRuby/Client.html" title="TwelvedataRuby::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
|
333
|
+
<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
334
|
+
<span class='id identifier rubyid_client'>client</span>
|
335
|
+
<span class='kw'>end</span></pre>
|
336
|
+
</td>
|
337
|
+
</tr>
|
338
|
+
</table>
|
339
|
+
</div>
|
340
|
+
|
341
|
+
</div>
|
342
|
+
|
343
|
+
</div>
|
344
|
+
|
345
|
+
<div id="footer">
|
346
|
+
Generated on Tue Jul 13 08:56:48 2021 by
|
347
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
348
|
+
0.9.26 (ruby-3.0.1).
|
349
|
+
</div>
|
350
|
+
|
351
|
+
</div>
|
352
|
+
</body>
|
353
|
+
</html>
|