robinhood-api 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/robinhood.rb +22 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dfe1dce8dda9168979bd651c80b877f0ab9e0a0
|
4
|
+
data.tar.gz: 684af5059539659160b16aafeec5048bc185e54a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a93b1179979a58f8f41892d6735a23b6ca63b13b27cdb84128b8d8d22d280d82a542f9ef1b28779c2950cc2bb1c0510156a852dc210dc7aa66bd898dfdde44f
|
7
|
+
data.tar.gz: b31cd8904edb399e9b062f9801d648de7b09ecf5ff81076238a1eb53f833f97084eff1039ce5ce040668962005ea0bdf69c802c801e2b4ea281df165ad394e39
|
data/lib/robinhood.rb
CHANGED
@@ -4,11 +4,16 @@ module RobinhoodModule
|
|
4
4
|
m = instance_method(name)
|
5
5
|
define_method(name) do |*args, &block|
|
6
6
|
# yield
|
7
|
-
if
|
8
|
-
|
7
|
+
if prerequisites?(name)
|
8
|
+
if token_compliant?(name)
|
9
|
+
m.bind(self).(*args, &block)
|
10
|
+
else
|
11
|
+
puts "You have to run the login(<username>, <password>) method or a Robinhood.new instance before running the #{name} method"
|
12
|
+
exit 1
|
13
|
+
end
|
9
14
|
else
|
10
|
-
puts "You
|
11
|
-
exit
|
15
|
+
puts "You must define ROBINHOOD_USERNAME and ROBINHOOD_PASSWORD environment variables to run the #{name} method"
|
16
|
+
exit 2
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
@@ -200,14 +205,25 @@ module RobinhoodModule
|
|
200
205
|
}
|
201
206
|
end
|
202
207
|
|
208
|
+
def methodlist
|
209
|
+
[:investment_profile, :accounts, :ach_iav_auth, :ach_relationships, :ach_transfers, :applications, :dividends, :edocuments, :margin_upgrade, :notifications, :orders, :password_reset, :document_requests, :user, :watchlists]
|
210
|
+
end
|
211
|
+
|
203
212
|
def headers
|
204
213
|
@headers ||= {
|
205
214
|
'Accept' => 'application/json',
|
206
215
|
}
|
207
216
|
end
|
208
217
|
|
209
|
-
def
|
210
|
-
methodlist
|
218
|
+
def prerequisites?(method)
|
219
|
+
if methodlist.include?(method)
|
220
|
+
return ENV['ROBINHOOD_USERNAME'] && ENV['ROBINHOOD_PASSWORD']
|
221
|
+
else
|
222
|
+
return true
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def token_compliant?(method)
|
211
227
|
|
212
228
|
if methodlist.include?(method)
|
213
229
|
if headers.key?('Authorization')
|