Peace/lib/Peace/Model/Customer.pm

87 lines
1.9 KiB
Perl

package Peace::Model::Customer;
use v5.30.0;
use strict;
use warnings;
use Params::ValidationCompiler qw/validation_for/;
use Types::Standard qw/Str InstanceOf Bool/;
use DateTime;
{
my $validator = validation_for(
params => {
uuid => { type => Str, optional => 1 },
date_creation => { type => InstanceOf ['DateTime'], optional => 1 },
secret => { type => Str },
stripe_id => { type => Str, optional => 1 },
}
);
sub new {
my $class = shift;
my %params = $validator->(@_);
my $self = bless {%params}, $class;
return $self;
}
}
{
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 {
my $self = shift;
if (@_) {
my ($new_secret) = $validator->(@_);
$self->{secret} = $new_secret;
}
return $self->{secret};
}
}
{
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};
}
}
1;