package Peace::Model::Developer; use v5.30.0; use strict; use warnings; use Params::ValidationCompiler qw/validation_for/; use Types::Standard qw/Str InstanceOf Bool HasMethods/; use DateTime; use Peace::DAO::Application; { my $validator = validation_for( params => { uuid => { type => Str, optional => 1 }, date_creation => { type => InstanceOf ['DateTime'], optional => 1 }, secret_bcrypt => { type => Str }, name => { type => Str }, surname => { type => Str }, email => { type => Str }, stripe_id => { type => Str, optional => 1 }, country => { type => Str }, verified => { type => Bool }, dbh => { type => HasMethods ['selectall_arrayref'], optional => 1 }, } ); sub new { my $class = shift; my %params = $validator->(@_); my $self = bless {%params}, $class; return $self; } } sub applications { my $self = shift; if (!defined $self->{applications}) { my $dbh = $self->_dbh; if (!defined $dbh) { die "There is no database handle, so no chance to recover applications from the developer."; } my $application_dao = Peace::DAO::Application->new( dbh => $dbh ); $self->{applications} = $application_dao->recover_by_developer(developer => $self); } return $self->{applications}; } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub uuid { my $self = shift; if (@_) { my ($new_uuid) = $validator->(@_); $self->{uuid} = $new_uuid; } return $self->{uuid}; } } { my $validator = validation_for( params => [ { type => InstanceOf ['DateTime'], optional => 1 } ] ); sub date_creation { my $self = shift; if (@_) { my ($new_date_creation) = $validator->(@_); $self->{date_creation} = $new_date_creation; } return $self->{date_creation}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub secret_bcrypt { my $self = shift; if (@_) { my ($new_secret_bcrypt) = $validator->(@_); $self->{secret_bcrypt} = $new_secret_bcrypt; } return $self->{secret_bcrypt}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub name { my $self = shift; if (@_) { my ($new_name) = $validator->(@_); $self->{name} = $new_name; } return $self->{name}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub surname { my $self = shift; if (@_) { my ($new_surname) = $validator->(@_); $self->{surname} = $new_surname; } return $self->{surname}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub email { my $self = shift; if (@_) { my ($new_email) = $validator->(@_); $self->{email} = $new_email; } return $self->{email}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub stripe_id { my $self = shift; if (@_) { my ($new_stripe_id) = $validator->(@_); $self->{stripe_id} = $new_stripe_id; } return $self->{stripe_id}; } } { my $validator = validation_for( params => [ { type => Str, optional => 1 } ] ); sub country { my $self = shift; if (@_) { my ($new_country) = $validator->(@_); $self->{country} = $new_country; } return $self->{country}; } } { my $validator = validation_for( params => [ { type => Bool, optional => 1 } ] ); sub verified { my $self = shift; if (@_) { my ($new_verified) = $validator->(@_); $self->{verified} = $new_verified; } return $self->{verified}; } } sub _dbh { my $self = shift; return $self->{dbh}; } 1;