NAME

WebService::HMRC::HelloWorld - Interact with the UK HMRC HelloWorld API

VERSION

Version 0.01

SYNOPSIS

use WebService::HMRC::HelloWorld;
my $hmrc = WebService::HMRC::HelloWorld->new();

# Hello World endpoint requires no authorisation
my $result = $hmrc->hello_world()
print $result->data->{message} if $result->is_success;

# Hello Application endpoint requires a server token
$hmrc->auth->server_token( $my_server_token );
$result = $hmrc->hello_application();
print $result->data->{message} if $result->is_success;

# Hello User endpoint requires an access token
$hmrc->auth->access_token( $my_access_token );
$result = $hmrc->hello_user();
print $result->data->{message} if $result->is_success;

DESCRIPTION

Perl module to interact with the UK's HMRC Making Tax Digital `Hello World` API. This is often used as a basic test of configuration and credentials before using their more involved APIs for managing corporate and personal tax affairs.

For more information, see: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/api-example-microservice/1.0

REQUIRES

WebService::HMRC

EXPORTS

Nothing

PROPERTIES

Inherits from WebService::HMRC::Request.

METHODS

Inherits from WebService::HMRC::Request.

hello_world()

Retrieve a "Hello World" message. Does not require authorisation.

Returns a WebService::HMRC::Response object.

hello_application()

Retrieve a "Hello Application" message. This is an application-restricted endpoint which requires that this module's server_token property be set.

Returns a WebService::HMRC::Response object.

hello_user()

Retrieve a "Hello User" message. This is a user-restricted endpoint requiring permission for the hello service scope.

Returns a WebService::HMRC::Response object.

INSTALLATION

To install this module, run the following commands:

perl Makefile.PL
make
make test
make install

AUTHORISATION

Except for a small number of open endpoints, access to the HMRC APIs requires appliction or user credentials. These must be obtained from HMRC. Application credentials (and documentation) may be obtained from their Developer Hub

Access to the HMRC Hello World service requires that an application be registered with HMRC and 'subscribed' for this api.

This module allows all three of the possible authorisation types to be exercised.

The hello_world() method accesses an 'open' endpoint and does not require authorisation.

The hello_application() method accesses an 'application-restricted' endpoint and therefore requires a server token for authorisation. This is issued when the application is registered with HMRC and may be retrieved from the HMRC Developer Hub.

The hello_user() method accesses a 'user-restricted' endpoint and therefore requires an access token for authorisation, obtained when a user grants permission to the application for the hello service scope.

For more details on obtaining and using access tokens, See WebService::HMRC::Authenticate.

Further information, application credentials and documentation may be obtained from the HMRC Developer Hub.

TESTING

The basic tests are run as part of the installation instructions shown above and do not require authorisation with HMRC. A call will be made to the open /hello/world api endpoint, which requires a working internet connection and that the HMRC sandbox test environment is operational.

Developer pre-release tests may be run with the following command:

prove -l xt/

With a working internet connection and appropriate HMRC credentials, specified as environment variables, interaction with the protected HelloWorld endpoints can be tested:

  • Test access to an application-restricted endpoint:

    HMRC_SERVER_TOKEN=[MY-SERVER-TOKEN] make test TEST_VERBOSE=1
  • Test access to a user-restricted endpoint:

    HMRC_ACCESS_TOKEN=[MY-SERVER-TOKEN] make test TEST_VERBOSE=1

AUTHOR

Nick Prater, <nick@npbroadcast.com>

BUGS

Please report any bugs or feature requests to bug-webservice-hmrc-helloworld at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-HMRC-HelloWorld. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc WebService::HMRC::HelloWorld

The README.pod file supplied with this distribution is generated from the WebService::HMRC::HelloWorld module's pod by running the following command from the distribution root:

perldoc -u lib/WebService/HMRC/HelloWorld.pm > README.pod

You can also look for information at:

ACKNOWLEDGEMENTS

This module was originally developed for use as part of the LedgerSMB open source accounting software.

LICENSE AND COPYRIGHT

Copyright 2018 Nick Prater, NP Broadcast Ltd.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.