API-MailboxOrg

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "Test::NoTabs" : "0",
            "Test::Perl::Critic" : "0",
            "Test::Pod" : "1.41",
            "Test::Pod::Coverage" : "1.08"
         }
      },
      "runtime" : {
         "requires" : {
            "Carp" : "0",
            "IO::Socket::SSL" : "0",
            "JSON::PP" : "0",
            "Mojolicious" : "8",
            "Moo" : "1.003001",
            "MooX::Singleton" : "0",
            "Params::ValidationCompiler" : "0.30",
            "Scalar::Util" : "0",
            "Type::Library" : "1.012",
            "Type::Utils" : "1.012",
            "Types::Mojo" : "0.04",
            "Types::Standard" : "1.012",
            "perl" : "5.024"

META.json  view on Meta::CPAN

         "type" : "git",
         "url" : "git://github.com/perlservices/API-MailboxOrg.git",
         "web" : "https://github.com/perlservices/API-MailboxOrg"
      }
   },
   "version" : "1.0.2",
   "x_contributors" : [
      "reneeb <info@perl-services.de>"
   ],
   "x_generated_by_perl" : "v5.30.0",
   "x_serialization_backend" : "Cpanel::JSON::XS version 4.19"
}

META.yml  view on Meta::CPAN

    version: v1.0.2
  API::MailboxOrg::APIBase:
    file: lib/API/MailboxOrg/APIBase.pm
    version: v1.0.2
  API::MailboxOrg::Types:
    file: lib/API/MailboxOrg/Types.pm
    version: v1.0.2
requires:
  Carp: '0'
  IO::Socket::SSL: '0'
  JSON::PP: '0'
  Mojolicious: '8'
  Moo: '1.003001'
  MooX::Singleton: '0'
  Params::ValidationCompiler: '0.30'
  Scalar::Util: '0'
  Type::Library: '1.012'
  Type::Utils: '1.012'
  Types::Mojo: '0.04'
  Types::Standard: '1.012'
  perl: '5.024'

Makefile.PL  view on Meta::CPAN

  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "API-MailboxOrg",
  "LICENSE" => "artistic_2",
  "MIN_PERL_VERSION" => "5.024",
  "NAME" => "API::MailboxOrg",
  "PREREQ_PM" => {
    "Carp" => 0,
    "IO::Socket::SSL" => 0,
    "JSON::PP" => 0,
    "Mojolicious" => 8,
    "Moo" => "1.003001",
    "MooX::Singleton" => 0,
    "Params::ValidationCompiler" => "0.30",
    "Scalar::Util" => 0,
    "Type::Library" => "1.012",
    "Type::Utils" => "1.012",
    "Types::Mojo" => "0.04",
    "Types::Standard" => "1.012"
  },

Makefile.PL  view on Meta::CPAN

  "VERSION" => "1.0.2",
  "test" => {
    "TESTS" => "t/*.t t/types/*.t"
  }
);


my %FallbackPrereqs = (
  "Carp" => 0,
  "IO::Socket::SSL" => 0,
  "JSON::PP" => 0,
  "Mojolicious" => 8,
  "Moo" => "1.003001",
  "MooX::Singleton" => 0,
  "Params::ValidationCompiler" => "0.30",
  "Pod::Coverage::TrustPod" => 0,
  "Scalar::Util" => 0,
  "Test::Exception" => 0,
  "Test::More" => 0,
  "Test::RequiresInternet" => 0,
  "Test::Spec" => 0,

cpanfile  view on Meta::CPAN

# This file is generated by Dist::Zilla::Plugin::SyncCPANfile v0.02
# Do not edit this file directly. To change prereqs, edit the `dist.ini` file.

requires "Carp" => "0";
requires "IO::Socket::SSL" => "0";
requires "JSON::PP" => "0";
requires "Mojolicious" => "8";
requires "Moo" => "1.003001";
requires "MooX::Singleton" => "0";
requires "Params::ValidationCompiler" => "0.30";
requires "Scalar::Util" => "0";
requires "Type::Library" => "1.012";
requires "Type::Utils" => "1.012";
requires "Types::Mojo" => "0.04";
requires "Types::Standard" => "1.012";
requires "perl" => "5.024";

dist.ini  view on Meta::CPAN

repository_type = github
repository_path = perlservices/API-MailboxOrg
is_cpan         = 1

[PruneFiles]
filename = bin/get_mailbox_api.pl

[Prereqs]
Carp            = 0
IO::Socket::SSL = 0
JSON::PP        = 0
Moo             = 1.003001
MooX::Singleton = 0
Mojolicious     = 8
Params::ValidationCompiler = 0.30
Scalar::Util    = 0
Type::Library   = 1.012
Type::Utils     = 1.012
Types::Mojo     = 0.04
Types::Standard = 1.012
perl            = 5.024

lib/API/MailboxOrg/APIBase.pm  view on Meta::CPAN

=head1 VERSION

version 1.0.2

=head1 ATTRIBUTES

=over 4

=item * json_rpc

I<(optional)> The version of JSON-RPC used. Defaults to C<2.0>.

=item * api

I<mandatory> An L<API::MailboxOrg> object.

=back

=head1 METHODS

=head2 request

lib/API/MailboxOrg/Types.pm  view on Meta::CPAN

use warnings;

use Type::Library
   -base,
   -declare => qw( HashRefRestricted Boolean );

use Type::Utils -all;
use Types::Standard -types;

use Carp;
use JSON::PP;
use Scalar::Util qw(blessed);

our $VERSION = '1.0.2'; # VERSION

my $meta = __PACKAGE__->meta;

$meta->add_type(
    name => 'HashRefRestricted',
    parent => HashRef,
    constraint_generator => sub {

lib/API/MailboxOrg/Types.pm  view on Meta::CPAN

    coercion_generator => sub {
        my ($parent, $child, $param) = @_;
        return $parent->coercion;
    },
    #inline_generator => sub {},
    #deep_explanation => sub {},
);

$meta->add_type(
    name => 'Boolean',
    parent => InstanceOf['JSON::PP::Boolean'],
    constraint_generator => sub {
        return $meta->get_type('Boolean') if !@_;

        return sub {
            return if ! ( blessed $_ and $_->isa('JSON::PP::Boolean') );
            return 1;
        };
    },
    coercion_generator => sub {
        my ($parent, $child, $param) = @_;
        return $parent->coercion;
    },
);

coerce Boolean,
    from Bool,
        via {
            my $new = $_ ? $JSON::PP::true : $JSON::PP::false;
            $new;
        }
;

__PACKAGE__->meta->make_immutable;

1;

__END__

lib/API/MailboxOrg/Types.pm  view on Meta::CPAN

        use Moo;
        use API::MailboxOrg::Types qw(Boolean HashRefRestricted);

        has true_or_false => ( is => 'ro', isa => Boolean, coerce => 1 );
        has map           => ( is => 'ro', isa => HashRefRestricted[qw(a b)] ); # allow only keys a and b

        1;
    }

    my $obj = TestClass->new(
        true_or_false => 1,  # 0|1|""|undef|JSON::PP::Boolean object
        map  => {
            a => 1,
            b => 1,
            # a key 'c' would cause a 'die'
        },
    );

=head1 TYPES

=head2 HashRefRestricted[`a]

This expects a hash reference. You can restrict the allowed keys

=head2 Boolean

A JSON::PP::Boolean object.

=head1 COERCIONS

These coercions are defined.

=head2 To Boolean

=over 4

=item * String/Integer to boolean

The values "" (empty string), I<undef>, 0, and 1 are coerced to C<JSON::PP::Boolean> objects.

=back

=head1 AUTHOR

Renee Baecker <reneeb@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2022 by Renee Baecker.

t/types/002_boolean.t  view on Meta::CPAN

use strict;
use warnings;

use Test::Spec;
use Test::Exception;

use File::Basename;
use lib dirname(__FILE__);

use API::MailboxOrg::Types qw(Boolean);
use JSON::PP;

{
    package  # private package - do not index
        TestClass;

    use Moo;
    use API::MailboxOrg::Types qw(Boolean);

    has true_or_false => ( is => 'rw', isa => Boolean, coerce => 1 );

    1;
}

describe 'Boolean' => sub {

    it 'allows a JSON::PP::true' => sub {
        my $type = Boolean();
        ok $type->( $JSON::PP::true );
    };

    it 'allows a JSON::PP::false' => sub {
        my $type = Boolean();
        is $type->( $JSON::PP::false ), 0;
        isa_ok $type->( $JSON::PP::false ), 'JSON::PP::Boolean';
    };
};

describe "TestClass' true_or_false" => sub {

    it 'allows a JSON::PP::true' => sub {
        my $obj = TestClass->new;

        lives_ok {
            $obj->true_or_false( $JSON::PP::true );
        };

        is $obj->true_or_false, 1;
        isa_ok $obj->true_or_false, 'JSON::PP::Boolean';
    };

    it 'allows a JSON::PP::false' => sub {
        my $obj = TestClass->new;

        lives_ok {
            $obj->true_or_false( $JSON::PP::false );
        };

        is $obj->true_or_false, 0;
        isa_ok $obj->true_or_false, 'JSON::PP::Boolean';
    };

    it 'allows a 0' => sub {
        my $obj = TestClass->new;

        lives_ok {
            $obj->true_or_false( 0 );
        };

        is $obj->true_or_false, 0;
        isa_ok $obj->true_or_false, 'JSON::PP::Boolean';
    };

    it 'allows a 1' => sub {
        my $obj = TestClass->new;

        lives_ok {
            $obj->true_or_false( 1 );
        };

        is $obj->true_or_false, 1;
        isa_ok $obj->true_or_false, 'JSON::PP::Boolean';
    };

    it 'allows undef' => sub {
        my $obj = TestClass->new;

        lives_ok {
            $obj->true_or_false( undef );
        };

        is $obj->true_or_false, 0;
        isa_ok $obj->true_or_false, 'JSON::PP::Boolean';
    };

    it 'allows empty string' => sub {
        my $obj = TestClass->new;

        lives_ok {
            $obj->true_or_false( "" );
        };

        is $obj->true_or_false, 0;
        isa_ok $obj->true_or_false, 'JSON::PP::Boolean';
    };

    it 'doesn\'t allow any references' => sub {
        my $obj = TestClass->new;

        dies_ok {
            $obj->true_or_false( [] );
        };
    };



( run in 1.821 second using v1.01-cache-2.11-cpan-140bd7fdf52 )