lib/Finance/Robinhood/ACATS/Transfer.pm

filter: Statementstmt 58.0% 18 / 31 Branchbran 0.0% 0 / 6 Conditioncond 25.0% 1 / 4 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 54.5% 6 / 11 Podpod 100% 4 / 4 totaltotal 49.1% 29 / 59 CC 6 SCAR 18.8
CC
6
Cov
46%
cancel
20.0
_test__init
4.5
_test_stringify
2.1
CRAP 6.5
« lib/Finance/Robinhood/Forex/Order/Execution.pm ↑ Summary lib/Finance/Robinhood/User.pm »
1 package Finance::Robinhood::ACATS::Transfer;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::ACATS::Transfer - Represents a ACATS Transfer
10  
11 =head1 SYNOPSIS
12  
13 use Finance::Robinhood;
14 my $rh = Finance::Robinhood->new;
15 my $transfers = $rh->acats_transfters();
16  
17 for my $transfer ($transferss->all) {
18 CORE::say 'ACATS transfer from ' . $transfer->contra_brokerage_name;
19 }
20  
21 =cut
22  
23 1 our $VERSION = '0.92_003';
24 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Finance::Robinhood::ACATS::Transfer::Position;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶sub _test__init {
Subroutine _test__init: called CC=2 SCAR=15.1
29 1 my $rh = t::Utility::rh_instance(1);
30 0 my $transfer = $rh->acats_transfers->current;
31 0 ▶ skip_all('No ACATS transfers found') if !defined $transfer;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $transfer 0 0 0
32 0 isa_ok($transfer, __PACKAGE__);
33 0 t::Utility::stash('TRANSFER', $transfer); # Store it for later
34 }
35 0 ▶use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
36  
37 1 ▶sub _test_stringify {
Subroutine _test_stringify: called CC=2 SCAR=7.6
38 1 ▶ t::Utility::stash('TRANSFER') // skip_all();
Condition50%1/2
t::Utility::stash("TRANSFER") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("TRANSFER") // skip_all()
t::Utility::stash("TRANSFER") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("TRANSFER")B= skip_all()
ABresult
1X1
011
000
39  
40 #is(
41 # +t::Utility::stash('TRANSFER'),
42 # 'https://api.robinhood.com//',
43 #);
44 }
45 #
46 1 has _rh => undef => weak => 1;
47  
48 =head1 METHODS
49  
50  
51  
52 =head2 C<id( )>
53  
54  
55  
56 =head2 C<cash_value( )>
57  
58  
59  
60 =head2 C<contra_account_number( )>
61  
62  
63  
64 =head2 C<contra_brokerage_name( )>
65  
66  
67  
68 =head2 C<failure_reason( )>
69  
70  
71 =head2 C<fees_reimbursed( )>
72  
73  
74  
75 =head2 C<transfer_type( )>
76  
77  
78  
79 =head2 C<replaced_by( )>
80  
81  
82  
83  
84 =head2 C<state( )>
85  
86  
87  
88 =cut
89  
90 1 has ['cash_value', 'contra_account_number',
91 'contra_brokerage_name', 'failure_reason',
92 'fees_reimbursed', 'id',
93 'replaced_by', 'state',
94 'transfer_type'
95 ];
96  
97 =head2 C<cancel( )>
98  
99 If the transfer can be cancelled, this method will do it.
100  
101 =cut
102  
103 0 ▶sub cancel($s) {
Subroutine cancel: not called CC=4 SCAR=30.0
Pod documented
104 0 ▶ $s->{cancel} // return !1;
Condition0%0/2
$s->{"cancel"} //
l!l
00
MC/DC0%0/1
$s->{"cancel"} //
$s->{"cancel"}
Truth table0%0/2
A
A= $s->{"cancel"}
Aresult
11
00
105 0 my $res = $s->_rh->_post($s->{cancel});
106 0 ▶ return $res->is_success
Branch: 2 branches
BranchTrueFalseTotal
$res->is_success ? : 0 0 0
$res->is_server_error ? : 0 0 0
107 ? !0
108 : Finance::Robinhood::Error->new(
109 $res->is_server_error ? (details => $res->message) : $res->json);
110 }
111  
112 =head2 C<updated_at( )>
113  
114 Returns a Time::Moment object.
115  
116 =cut
117  
118 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
119 0 Time::Moment->from_string($s->{updated_at});
120 }
121  
122 =head2 C<expected_landing_date( )>
123  
124 Returns a Time::Moment object.
125  
126 =cut
127  
128 0 ▶sub expected_landing_date ($s) {
Subroutine expected_landing_date: not called CC=1 SCAR=6.9
Pod documented
129 0 Time::Moment->from_string($s->{expected_landing_date} . 'T00:00:00Z');
130 }
131  
132 =head2 C<positions( )>
133  
134 my $positions = $transfer->equity_positions();
135  
136 Returns a list of Finance::Robinhood::ACATS::Transfer::Position objects with
137 this transfer's data.
138  
139 =cut
140  
141 0 ▶sub positions ($s) {
Subroutine positions: not called CC=1 SCAR=6.9
Pod documented
142 map {
143 0 Finance::Robinhood::ACATS::Transfer::Position->new(_rh => $s->_rh,
144 %$_)
145 0 } %{$s->{positions}};
146 }
147  
148 =head1 LEGAL
149  
150 This is a simple wrapper around the API used in the official apps. The author
151 provides no investment, legal, or tax advice and is not responsible for any
152 damages incurred while using this software. This software is not affiliated
153 with Robinhood Financial LLC in any way.
154  
155 For Robinhood's terms and disclosures, please see their website at
156 https://robinhood.com/legal/
157  
158 =head1 LICENSE
159  
160 Copyright (C) Sanko Robinson.
161  
162 This library is free software; you can redistribute it and/or modify it under
163 the terms found in the Artistic License 2. Other copyrights, terms, and
164 conditions may apply to data transmitted through this module. Please refer to
165 the L<LEGAL> section.
166  
167 =head1 AUTHOR
168  
169 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
170  
171 =cut
172  
173 1 1;
« lib/Finance/Robinhood/Forex/Order/Execution.pm ↑ Summary lib/Finance/Robinhood/User.pm »