schwab-api-ruby 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9659741b90ac05d0426da9e7ff4c6d3a03a205deeb2901d3ec97b9a8dd39165
4
- data.tar.gz: 5d27d65ef5d09158b61d41d621db97869cd137d11912d339fa0ff3cbea71258e
3
+ metadata.gz: a2aa249e30dc900c19f003e9085db5fe33907a69156e8eef47cd669bd09364d7
4
+ data.tar.gz: 298dc7d7330942e8c9f89189e3552ca165038616f8a825873cc0ce227f37fff4
5
5
  SHA512:
6
- metadata.gz: 3f5c84e4f946111c19adc93b4d73a2d3c4c45edfd397b9f6ec3ee05e1632f18695d0c311e6fd4d07442f2bd0d7604fda875056c09a55c496b721a4bcfddc0919
7
- data.tar.gz: a9ae1f55fd29ff52d032463b8e0d28ab50f51576957e78d98aefa3c7c9a15ee9e6a020dac4fec5d59d24183c24d448665a5019a6920206a45ddfd2e8321aef4a
6
+ metadata.gz: 8807115e742d49e4eadbbb87ace49fcae2875643ca029b62788c72189276d0e5477cdef567c0a83ab00fabb8512a5605573ca5f56d0051805daeda06ae5bd55f
7
+ data.tar.gz: d87fd1a1704c794cf60e7eae06026f7fa79098fb17a36af3b6fd0af0d14a0ede142b2640d019203b9d17e9d21906f4468c6675f6509e23a5349ece994608eef9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ Version 2.1.0
2
+ - Enable Instrument endpoint with "projection" param so you can query for fundamentals or other data about the ticker
3
+
1
4
  Version 2.0.0
2
5
  - This is version 2.0.0 becuase it's a continuation of the TDAmeritradeAPI gem.
3
6
 
@@ -44,7 +44,7 @@ module Schwab
44
44
  )
45
45
 
46
46
  unless response_success?(response)
47
- raise Schwab::Error::SchwabAPIError.new(
47
+ raise Schwab::APIError.new(
48
48
  "Unable to retrieve access tokens from API - #{response.code} - #{response.body}"
49
49
  )
50
50
  end
data/lib/schwab/client.rb CHANGED
@@ -2,7 +2,7 @@ require 'schwab/authentication'
2
2
  require 'schwab/client'
3
3
  require 'schwab/error'
4
4
  require 'schwab/version'
5
- # require 'schwab/operations/get_instrument_fundamentals'
5
+ require 'schwab/operations/get_instrument'
6
6
  require 'schwab/operations/get_price_history'
7
7
  require 'schwab/operations/get_quotes'
8
8
 
@@ -21,9 +21,9 @@ module Schwab
21
21
  @redirect_uri = args[:redirect_uri] || raise_error('redirect_uri is required!')
22
22
  end
23
23
 
24
- # def get_instrument_fundamentals(symbol)
25
- # Operations::GetInstrumentFundamentals.new(self).call(symbol)
26
- # end
24
+ def get_instrument(symbol, projection)
25
+ Operations::GetInstrument.new(self).call(symbol, projection:)
26
+ end
27
27
 
28
28
  def get_price_history(symbol, **options)
29
29
  Operations::GetPriceHistory.new(self).call(symbol, **options)
@@ -0,0 +1,23 @@
1
+ require 'schwab/operations/base_operation'
2
+
3
+ module Schwab; module Operations
4
+ class GetInstrument < BaseOperation
5
+
6
+ def call(symbols, projection:)
7
+ symbol = symbols.is_a?(Array) ? symbols.join(',') : symbols
8
+
9
+ params = {
10
+ symbol: symbol,
11
+ projection:
12
+ }
13
+
14
+ response = perform_api_get_request(
15
+ url: 'https://api.schwabapi.com/marketdata/v1/instruments',
16
+ query: params,
17
+ )
18
+
19
+ response
20
+ end
21
+
22
+ end
23
+ end; end
@@ -1,3 +1,3 @@
1
1
  module Schwab
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -35,7 +35,7 @@ describe Schwab::Error do
35
35
  end
36
36
 
37
37
  it 'raises a RateLimitError' do
38
- expect { subject }.to raise_error(Schwab::Error::RateLimitError)
38
+ expect { subject }.to raise_error(Schwab::RateLimitError)
39
39
  end
40
40
  end
41
41
 
@@ -68,7 +68,7 @@ describe Schwab::Error do
68
68
  end
69
69
 
70
70
  it 'raises a NotAuthorizedError' do
71
- expect { subject }.to raise_error(Schwab::Error::NotAuthorizedError)
71
+ expect { subject }.to raise_error(Schwab::NotAuthorizedError)
72
72
  end
73
73
  end
74
74
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schwab-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winston Kotzan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-27 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,7 +114,7 @@ files:
114
114
  - lib/schwab/client.rb
115
115
  - lib/schwab/error.rb
116
116
  - lib/schwab/operations/base_operation.rb
117
- - lib/schwab/operations/get_instrument_fundamentals.rb
117
+ - lib/schwab/operations/get_instrument.rb
118
118
  - lib/schwab/operations/get_price_history.rb
119
119
  - lib/schwab/operations/get_quotes.rb
120
120
  - lib/schwab/operations/support/build_watchlist_items.rb
@@ -1,23 +0,0 @@
1
- # require 'schwab/operations/base_operation'
2
- #
3
- # module Schwab
4
- # ; module Operations
5
- # class GetInstrumentFundamentals < BaseOperation
6
- #
7
- # def call(symbol)
8
- # params = {
9
- # apikey: client.client_id,
10
- # symbol: symbol,
11
- # projection: 'fundamental'
12
- # }
13
- #
14
- # response = perform_api_get_request(
15
- # url: 'https://api.tdameritrade.com/v1/instruments',
16
- # query: params,
17
- # )
18
- #
19
- # parse_api_response(response)
20
- # end
21
- #
22
- # end
23
- # end; end