Skip to content

stockholmuniversity/SU-API-Nexus-Card-Ordering-perl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

NAME

SU::API::NexusCardOrdering

SYNOPSIS

use strict;
use warnings;

use SU::API::NexusCardOrdering;

my $nexus = new SU::API::NexusCardOrdering;

$nexus->login("username","password");

my $payload;

$payload->{layoutId} = 12345;
$payload->{FirstName} = "John;
$payload->{LastName} = "Doe";

$payload->{CustomersUniqueID} = 1337;

$payload->{Extra1} = "Cool field";
$payload->{DeliveryContact} = "John Doe";
$payload->{DeliveryAddress} = "Gullerasen Västabäcksgatu 95";
$payload->{DeliveryZipCode} = 66203;
$payload->{DeliveryCity} =  SVANSKOG;

my $response = $nexus->do_request("POST","order","",$payload);

   if ($nexus->request_code != 202) {
  die "Error POSTing $order->{id} to Nexus: " . $nexus->request_status_line;
   }


$nexus->logout();

DESCRIPTION

Module used to integrate with the REST API that Nexus provides for card ordering.

CONSTRUCTOR

new ()

Returns a new SU::API::NexusCardOrdering object.

METHODS

login (USERNAME, PASSWORD)

Configure and validate credantials.

logout

Destroy the login session.

login_status

Returns a human readable login status of the current session.

logged_in

Returns true when logged in, otherwise returns undef.

do_request (HTTP METHOD, URI, PARAMS, DATA)

Perform the actual request.

"PARAMS" is optional and can be any parameters that API supports. "DATA" is optional and is a Perl data structure that will be converted to JSON.

Returns the result in a perl reference.

request_code

Returns the last HTTP status code.

request_status_line

Returns the last HTTP status line.

DEPENDS

LWP::UserAgent, HTTP::Request, URI::Escape, JSON

LICENSE

Copyright (c) 2019-, IT Services, Stockholm University

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of Stockholm University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AUTHOR

Johan Wassberg - <[email protected]>

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 26:

Non-ASCII character seen before =encoding in 'Västabäcksgatu'. Assuming UTF-8

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages