File Coverage

lib/Finance/Robinhood/Equity/Account/InstantEligibility.pm
Criterion Covered Total %
statement 13 34 38.2
branch 0 4 0.0
condition 3 6 50.0
subroutine 7 10 70.0
pod 2 2 100.0
total 25 56 44.6


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Equity::Account::InstantEligibility;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Equity::Account - Robinhood Account's Instant or Gold
10             Margin Account Eligibility
11              
12             =head1 SYNOPSIS
13              
14             use Finance::Robinhood;
15             my $rh = Finance::Robinhood->new->login('user', 'pass');
16             my $account = $rh->equity_accounts->current();
17              
18             CORE::say 'Instant? ' . $account->instant_eligibility->state;
19              
20             =cut
21              
22             sub _test__init {
23 1     1   13165 my $rh = t::Utility::rh_instance(1);
24 0         0 my $acct = $rh->equity_accounts->current;
25 0         0 my $instant_eligibility = $acct->instant_eligibility;
26 0         0 isa_ok($instant_eligibility, __PACKAGE__);
27 0         0 t::Utility::stash('INSTANT', $instant_eligibility); # Store it for later
28             }
29             our $VERSION = '0.92_003';
30 1     1   6 use Mojo::Base-base, -signatures;
  1         2  
  1         6  
31 1     1   153 use Mojo::URL;
  1         2  
  1         5  
32 1     1   51 use overload '""' => sub ($s, @) { $s->{state} }, fallback => 1;
  1     0   1  
  1         6  
  0         0  
  0         0  
  0         0  
  0         0  
33              
34             sub _test_stringify {
35 1   50 1   1860 t::Utility::stash('INSTANT') // skip_all();
36 0         0 is(+t::Utility::stash('INSTANT'), 'ok');
37             }
38              
39             =head1 METHODS
40              
41             =cut
42              
43             has _rh => undef => weak => 1;
44              
45             =head2 C
46              
47              
48             =head2 C
49              
50             =head2 C
51              
52             =cut
53              
54             has ['state', 'reversal', 'reason'];
55              
56             =head2 C
57              
58             Returns a Time::Moment object if applicable.
59              
60             =cut
61              
62 0     0 1 0 sub reinstatement_date ($s) {
  0         0  
  0         0  
63 0         0 Time::Moment->from_string($s->{reinstatement_date} . 'T00:00:00Z');
64             }
65              
66             sub _test_reinstatement_date {
67 1   50 1   2040 t::Utility::stash('INSTANT')
68             // skip_all('No instant eligibility object in stash');
69 0 0       0 skip_all('Instant state is okay... No reinstatement_date set')
70             if t::Utility::stash('INSTANT')->state eq 'ok';
71 0         0 isa_ok(t::Utility::stash('INSTANT')->reinstatement_date, 'Time::Moment');
72             }
73              
74             =head2 C
75              
76             Returns a Time::Moment object if applicable.
77              
78             =cut
79              
80 0     0 1 0 sub updated_at ($s) {
  0         0  
  0         0  
81 0         0 Time::Moment->from_string($s->{updated_at});
82             }
83              
84             sub _test_updated_at {
85 1   50 1   1869 t::Utility::stash('INSTANT')
86             // skip_all('No instant eligibility object in stash');
87 0 0         skip_all('Instant state is okay... No updated_at set')
88             if t::Utility::stash('INSTANT')->state eq 'ok';
89 0           isa_ok(t::Utility::stash('INSTANT')->updated_at, 'Time::Moment');
90             }
91              
92             =head1 LEGAL
93              
94             This is a simple wrapper around the API used in the official apps. The author
95             provides no investment, legal, or tax advice and is not responsible for any
96             damages incurred while using this software. This software is not affiliated
97             with Robinhood Financial LLC in any way.
98              
99             For Robinhood's terms and disclosures, please see their website at
100             https://robinhood.com/legal/
101              
102             =head1 LICENSE
103              
104             Copyright (C) Sanko Robinson.
105              
106             This library is free software; you can redistribute it and/or modify it under
107             the terms found in the Artistic License 2. Other copyrights, terms, and
108             conditions may apply to data transmitted through this module. Please refer to
109             the L section.
110              
111             =head1 AUTHOR
112              
113             Sanko Robinson Esanko@cpan.orgE
114              
115             =cut
116              
117             1;