| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebService::Box::Folder; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 7 |  |  | 7 |  | 40 | use strict; | 
|  | 7 |  |  |  |  | 14 |  | 
|  | 7 |  |  |  |  | 266 |  | 
| 4 | 7 |  |  | 7 |  | 41 | use warnings; | 
|  | 7 |  |  |  |  | 13 |  | 
|  | 7 |  |  |  |  | 194 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 7 |  |  | 7 |  | 37 | use Moo; | 
|  | 7 |  |  |  |  | 13 |  | 
|  | 7 |  |  |  |  | 41 |  | 
| 7 | 7 |  |  | 7 |  | 2168 | use Types::Standard qw(Str Int InstanceOf); | 
|  | 7 |  |  |  |  | 17 |  | 
|  | 7 |  |  |  |  | 57 |  | 
| 8 | 7 |  |  | 7 |  | 6745 | use WebService::Box::Types::Library qw(BoxPerson Timestamp BoxFolderHash OptionalStr); | 
|  | 7 |  |  |  |  | 14 |  | 
|  | 7 |  |  |  |  | 55 |  | 
| 9 | 7 |  |  | 7 |  | 4920 | use WebService::Box::Request; | 
|  | 7 |  |  |  |  | 13 |  | 
|  | 7 |  |  |  |  | 131 |  | 
| 10 | 7 |  |  | 7 |  | 37 | use WebService::Box::File; | 
|  | 7 |  |  |  |  | 44 |  | 
|  | 7 |  |  |  |  | 3694 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our $VERSION = 0.01; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | has session => (is => 'ro', isa => InstanceOf["WebService::Box::Session"], required => 1); | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | has [qw/type id name description structure/] => ( | 
| 17 |  |  |  |  |  |  | is  => 'ro', | 
| 18 |  |  |  |  |  |  | isa => Str, | 
| 19 |  |  |  |  |  |  | ); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | has [qw/etag sequence_id sha1 item_status version_number/] => ( | 
| 22 |  |  |  |  |  |  | is  => 'ro', | 
| 23 |  |  |  |  |  |  | isa => OptionalStr, | 
| 24 |  |  |  |  |  |  | ); | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | has [qw/size comment_count/] => ( | 
| 27 |  |  |  |  |  |  | is  => 'ro', | 
| 28 |  |  |  |  |  |  | isa => Int, | 
| 29 |  |  |  |  |  |  | ); | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | has [qw/created_by modified_by owned_by/] => ( | 
| 32 |  |  |  |  |  |  | is     => 'ro', | 
| 33 |  |  |  |  |  |  | isa    => BoxPerson, | 
| 34 |  |  |  |  |  |  | coerce => BoxPerson()->coercion, | 
| 35 |  |  |  |  |  |  | ); | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | has [qw/created_at modified_at trashed_at purged_at content_created_at content_modified_at/] => ( | 
| 38 |  |  |  |  |  |  | is     => 'ro', | 
| 39 |  |  |  |  |  |  | isa    => Timestamp, | 
| 40 |  |  |  |  |  |  | coerce => Timestamp()->coercion, | 
| 41 |  |  |  |  |  |  | ); | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | has parent_data => (is => 'ro', isa => BoxFolderHash); | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | has request => ( | 
| 46 |  |  |  |  |  |  | is      => 'ro', | 
| 47 |  |  |  |  |  |  | isa     => InstanceOf["WebService::Box::Request"], | 
| 48 |  |  |  |  |  |  | lazy    => 1, | 
| 49 |  |  |  |  |  |  | default => sub { | 
| 50 |  |  |  |  |  |  | my $self = shift; | 
| 51 |  |  |  |  |  |  | WebService::Box::Request->new( session => $self->session ) | 
| 52 |  |  |  |  |  |  | }, | 
| 53 |  |  |  |  |  |  | ); | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | has _parent_object => (is => 'rwp', isa => InstanceOf["WebService::Box::Folder"]); | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub parent { | 
| 58 | 0 |  |  | 0 | 0 | 0 | my ($self) = @_; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 0 |  |  |  |  | 0 | my $data = $self->parent_data; | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 0 | 0 |  |  |  | 0 | if ( !$data ) { | 
| 63 | 0 | 0 |  |  |  | 0 | if ( !$self->id ) { | 
| 64 | 0 |  |  |  |  | 0 | $self->session->box->error( 'no id for parent found and no file id exists' ); | 
| 65 | 0 |  |  |  |  | 0 | return; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 0 |  |  |  |  | 0 | my %file_data = $self->request->do( | 
| 69 |  |  |  |  |  |  | ressource => 'files', | 
| 70 |  |  |  |  |  |  | id        => $self->id, | 
| 71 |  |  |  |  |  |  | ); | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 0 |  |  |  |  | 0 | $self = $_[0] = WebService::Box::File->new( %file_data, session => $self->session ); | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 0 | 0 |  |  |  | 0 | if ( !$self->_parent_object ) { | 
| 77 | 0 |  |  |  |  | 0 | my $data               = $self->parent_data; | 
| 78 | 0 |  |  |  |  | 0 | my %parent_data_result = $self->request->do( | 
| 79 |  |  |  |  |  |  | ressource => 'folders', | 
| 80 |  |  |  |  |  |  | id        => $data->{id}, | 
| 81 |  |  |  |  |  |  | ); | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 0 |  |  |  |  | 0 | $self->_set__parent_object( | 
| 84 | 0 |  |  |  |  | 0 | WebService::Box::Folder->new( %{$data}, session => $self->session ) | 
| 85 |  |  |  |  |  |  | ); | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 0 |  |  |  |  | 0 | return $self->_parent_object; | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | sub BUILDARGS { | 
| 92 | 2 |  |  | 2 | 0 | 29279 | my ( $class, @args ) = @_; | 
| 93 |  |  |  |  |  |  |  | 
| 94 | 2 | 50 |  |  |  | 15 | unshift @args, "id" if @args % 2 == 1; | 
| 95 |  |  |  |  |  |  |  | 
| 96 | 2 |  |  |  |  | 51 | return { @args }; | 
| 97 |  |  |  |  |  |  | } | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | 1; | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | __END__ |