lib/Finance/GDAX/API/URL.pm

filter: Statementstmt 96.3% 26 / 27 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 94.5% 35 / 37 CC 2 SCAR 2.6
CC
2
Cov
93%
get
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Finance/GDAX/API/UserAccount.pm ↑ Summary lib/Finance/GDAX/API/TypeConstraints.pm »
1 package Finance::GDAX::API::URL;
2 16 our $VERSION = '0.02';
3 16 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Finance::GDAX::API::URL - URL assembly for GDAX REST API
10  
11 =head1 SYNOPSIS
12  
13 use Finanace::GDAX::API::URL;
14 my $url = Finance::GDAX::API::URL->new->testing;
15 `wget $url/test_thing`;
16  
17 =head1 DESCRIPTION
18  
19 This class builds URLs for Finance::GDAX::API classes
20  
21 =head1 ATTRIBUTES
22  
23 =head2 C<debug>
24  
25 Bool that sets debug mode (will use sandbox). Defaults to true (1).
26  
27 =head2 C<production>
28  
29 The base URI for production requests, including the https://
30  
31 =head2 C<testing>
32  
33 The base URI for testing requests to the GDAX sandbox, including the
34 https://
35  
36 =cut
37  
38 16 has 'production' => (is => 'rw',
39 isa => 'Str',
40 default => 'https://api.gdax.com',
41 );
42 16 has 'testing' => (is => 'rw',
43 isa => 'Str',
44 default => 'https://api-public.sandbox.gdax.com',
45 );
46 16 has 'debug' => (is => 'rw',
47 isa => 'Bool',
48 default => 1,
49 );
50 has '_sections' => (is => 'rw',
51 isa => 'ArrayRef',
52 2 ▶ default => sub {[]},
Subroutine __ANON__: called CC=1 SCAR=0.0
53 16 );
54
55  
56 =head1 METHODS
57  
58 =head2 C<get>
59  
60 Returns a string of the assembled URL
61  
62 =cut
63  
64 sub get {
65 2 ▶ my $self = shift;
Subroutine get: called CC=2 SCAR=7.1
Pod documented
66 2 my $url = join '/', @{$self->_sections};
67 2 $url = '/'.$url;
68 2 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) { } 0 2 2
69 0 return $self->testing.$url;
70 } else {
71 2 return $self->production.$url;
72 }
73 }
74  
75 =head2 C<add>
76  
77 Adds to the URL, each will be separated with a '/'
78  
79 $url->add('products');
80  
81 =cut
82  
83 sub add {
84 4 ▶ my ($self, $thing) = @_;
Subroutine add: called CC=1 SCAR=0.0
Pod documented
85 4 $thing =~ s/^\/+//;
86 4 push @{$self->_sections}, $thing;
87 }
88  
89 16 __PACKAGE__->meta->make_immutable;
90 16 1;
91  
92  
93 =head1 AUTHOR
94  
95 Mark Rushing <mark@orbislumen.net>
96  
97 =head1 COPYRIGHT AND LICENSE
98  
99 This software is copyright (c) 2017 by Home Grown Systems, SPC.
100  
101 This is free software; you can redistribute it and/or modify it under
102 the same terms as the Perl 5 programming language system itself.
103  
104 =cut
105  
« blib/lib/Finance/GDAX/API/UserAccount.pm ↑ Summary lib/Finance/GDAX/API/TypeConstraints.pm »