Some examples of how to use the client.
Make sure you've enabled the Developer flag in your Wing user account and requested an API key. Then you can authenticate like this:
my $session = $wing->post('session', { username => 'me', password => '123qwe', api_key_id => 'abcdefghijklmnopqrztuz', });
All Wing::Client requests will throw an Ouch exception in the case of a failed lookup, or if the remote Wing server returned an error code.
Since any request can return an exception, you'll need to eval all requests.
my $session = eval { $wing->post('session', { username => 'me', password => '123qwe', api_key_id => 'abcdefghijklmnopqrztuz', }); };
You can use a combination of Ouch's trapping mechanisms to handle errors
if (kiss 440) { say "Wrong username and password combination"; exit 1; } else (hug) { #Catch all other errors say "Pigs are flying someplace, check the server-side code"; exit 2; } else { say "It worked"; } #Continue knowing that $session has valid data in it.
To install Wing::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wing::Client
CPAN shell
perl -MCPAN -e shell install Wing::Client
For more information on module installation, please visit the detailed CPAN module installation guide.