NAME

SU::API::Box

SYNOPSIS

use strict;
use warnings;

use SU::API::Box;

my $box = new SU::API::Box("client_id","client_secret","sub","box_sub_type");
$box->login("/path/to/key","kid") or die $box->login_status;
my $users = $box->do_request("GET", "users","limit=2");

if (!$users) {
    warn $box->request_code;
    warn $box->request_status_line;
};

$box->logout();

DESCRIPTION

Module used to integrate with the REST API that Box provides.

CONSTRUCTOR

new (CLIENT_ID, CLIENT_SECRET, SUB, BOX_SUB_TYPE)

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

METHODS

login (KEY, KID)

Login and get the access_token for use in future requests

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 the Box 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

Crypt::JWT, CryptX, HTTP::Request, JSON, LWP::UserAgent, String::Random, URI::Escape

LICENSE

Copyright (c) 2016-, 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 Carlquist <jocar@su.se>,