NAME

MooseY::RemoteHelper::Role::Client - Commonly used attributes for remote facade's

VERSION

version 0.001014

SYNOPSIS

# implementers
use Moose;
use Class::Load 0.20 'load_class';

with 'MooseY::RemoteHelper::Role::Client';

sub submit {
	my ( $self, $req ) = @_;

	# check test
	# check debug and output request/response
	# ...

	my $res; # = ...

	return $res;
}

# consumers debbuging live transactions
my $req; # your request object

my $client
	= load_class('My::Client')->new({
		user  => 'Str',
		pass  => 'Str',
		test  => 0,
		debug => 1,
	});

my $res = try { $client->submit( $req ) } catch { ... if $_->does('Throwable') };

DESCRIPTION

I've found that most remote clients have the same things in common, "user", "pass", a way to transmit "submit", need for "debug" modes, and commonly a "test" mode.

ATTRIBUTES

user

Type: Str Required

This should be the username or other credential used to identify your user.

pass

Type: Str Required

This should be the password, passphrase, or other credential used to authenticate your user initially. If for some reason your client doesn't have this, set it to an empty string and ignore it in "submit" method.

debug

Type: Int Default: $ENV{REMOTE_CLIENT_DEBUG} or 0

This is used to provide debugging levels, it defaults to the Environment variable REMOTE_CLIENT_DEBUG or 0 if that's not set.

test

Type: Bool Default: 1

Many remote APIs have a test mode, that is different from live transactions. Use this to turn that on. It could toggle a different endpoint, or simply a parameter. Defaults to 1 because it's better to send fake requests than accidentally send live ones. Remember to always set this on APIs that use it.

METHODS

submit

my $res = try { $client->submit( $req ) } catch { ... if $_->does('Throwable') };

The above is the method signature this should implement. Submit should take a request object that can serialize and return a response object. Throwable exceptions should occur if there is a network transmission error.

Note: the sample usage here is not good, write your exception handling better than this.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/xenoterracide/moosex-remotehelper/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Caleb Cushing <xenoterracide@gmail.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2013 by Caleb Cushing.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)