The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

        PayProp::API::Public::Client::Role::Storage - Role to encapsulate storage SETers and GETers.

SYNOPSIS

        package Module::Requiring::Storage;
        with qw/ PayProp::API::Public::Client::Role::Storage /;

        # To be implemented by the consumer of the role
        sub _set_p { ... }
        sub _get_p { ... }
        sub _ping_p { ... }
        sub _delete_p { ... }

        __PACKAGE__->meta->make_immutable;

        my $Module = Module::Requiring::Storage->new( encryption_secret => 's3cr3t123123' );
        $Module
                ->set_p( 'KEY', 'VALUE' )
                ->then( sub { ... } )
                ->wait
        ;

DESCRIPTION

Storage role that defines how storage solutions must be implemented.

It's expected to return Mojo::Promise from implemented methods. See PayProp::API::Public::Client::Authorization::Storage::Memcached for an example implementation.

METHODS

ping_p

Ping method to be overriden via _ping_p to check if storage is available.

        my $Promise = $self->ping_p;

Return:

        C<Mojo::Promise> containing truthy value on success.
        Throws C<PayProp::API::Public::Client::Exception::Storage> if storage is not available and C<throw_on_storage_unavailable> is set to truthy value.

set_p

Set method to be overriden via _set_p to store value.

        my $Promise = $self->set_p( 'KEY', 'VALUE' );

Return:

        C<Mojo::Promise> containing truthy value on success. Throws on missing key or value.
        Throws C<PayProp::API::Public::Client::Exception::Storage> if storage is not available and C<throw_on_storage_unavailable> is set to truthy value.

get_p

Get method to be overriden via _get_p to retrieve stored value.

        my $Promise = $self->get_p('KEY');

Return:

        C<Mojo::Promise> containing stored value on success. Throws on missing key.
        Throws C<PayProp::API::Public::Client::Exception::Storage> if storage is not available and C<throw_on_storage_unavailable> is set to truthy value.

delete_p

Delete method to be overriden via _delete_p to remove stored value.

        my $Promise = $self->delete_p('KEY');

Return:

        C<Mojo::Promise> containing truthy value on success. Throws on missing key.
        Throws C<PayProp::API::Public::Client::Exception::Storage> if storage is not available and C<throw_on_storage_unavailable> is set to truthy value.

AUTHOR

Yanga Kandeni <yangak@cpan.org>

Valters Skrupskis <malishew@cpan.org>

COPYRIGHT

Copyright 2023- PayProp

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

If you would like to contribute documentation or file a bug report then please raise an issue / pull request:

https://github.com/Humanstate/api-client-public-module