Activiti-Rest-Client

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

  ],
  "dist_name" => "Activiti-Rest-Client",
  "dist_version" => "0.1259",
  "license" => "perl",
  "module_name" => "Activiti::Rest::Client",
  "recursive_test_files" => 1,
  "requires" => {
    "Carp" => 0,
    "Data::Util" => 0,
    "Encode" => 0,
    "JSON" => 0,
    "LWP::UserAgent" => 0,
    "Moo" => 0,
    "Moo::Role" => 0,
    "Throwable::Error" => 0,
    "URI::Escape" => 0,
    "perl" => "v5.10.0",
    "strict" => 0
  },
  "test_requires" => {
    "Software::License" => 0,

META.json  view on Meta::CPAN

         "requires" : {
            "Dist::Milla" : "v1.0.17",
            "Test::Pod" : "1.41"
         }
      },
      "runtime" : {
         "requires" : {
            "Carp" : "0",
            "Data::Util" : "0",
            "Encode" : "0",
            "JSON" : "0",
            "LWP::UserAgent" : "0",
            "Moo" : "0",
            "Moo::Role" : "0",
            "Throwable::Error" : "0",
            "URI::Escape" : "0",
            "perl" : "v5.10.0",
            "strict" : "0"
         }
      },
      "test" : {

META.json  view on Meta::CPAN

         "type" : "git",
         "url" : "https://github.com/Universiteitsbibliotheek/Activiti-Rest-Client.git",
         "web" : "https://github.com/Universiteitsbibliotheek/Activiti-Rest-Client"
      }
   },
   "version" : "0.1259",
   "x_contributors" : [
      "Nicolas Franck <nicolas.franck@ugent.be>",
      "njfranck <njfranck@ca20c521.ugent.be>"
   ],
   "x_serialization_backend" : "Cpanel::JSON::XS version 3.0225"
}

META.yml  view on Meta::CPAN

    - eg
    - examples
    - inc
    - share
    - t
    - xt
requires:
  Carp: '0'
  Data::Util: '0'
  Encode: '0'
  JSON: '0'
  LWP::UserAgent: '0'
  Moo: '0'
  Moo::Role: '0'
  Throwable::Error: '0'
  URI::Escape: '0'
  perl: v5.10.0
  strict: '0'
resources:
  bugtracker: https://github.com/Universiteitsbibliotheek/Activiti-Rest-Client/issues
  homepage: https://github.com/Universiteitsbibliotheek/Activiti-Rest-Client

cpanfile  view on Meta::CPAN


requires 'strict','0';
requires 'Encode','0';
requires 'Carp','0';
requires 'Moo','0';
requires 'Moo::Role','0';
requires 'URI::Escape','0';
requires 'LWP::UserAgent','0';
requires 'Data::Util','0';
requires 'Throwable::Error','0';
requires 'JSON','0';

lib/Activiti/Rest/Client.pm  view on Meta::CPAN

package Activiti::Rest::Client;
use Activiti::Sane;
use Carp qw(confess);
use Moo;
use Data::Util qw(:check :validate);
use JSON qw(decode_json encode_json);
use URI::Escape qw(uri_escape);
use Activiti::Rest::Response;

our $VERSION = "0.1259";

#see: http://www.activiti.org/userguide

=head1 NAME

Activiti::Rest::Client - Low level client for the Activiti Rest API

lib/Activiti/Rest/Response.pm  view on Meta::CPAN

package Activiti::Rest::Response;
use Activiti::Sane;
use Activiti::Rest::Error;
use Moo;
use JSON qw();
use Encode qw();

has content => (
  is => 'ro',
  predicate => 'has_content'
);
has parsed_content => (
  is => 'ro',
  predicate => 'has_parsed_content'
);

lib/Activiti/Rest/Response.pm  view on Meta::CPAN


  #status code indicates 'failure'
  unless($res->is_success){

    my $code = $res->code;

    #before version 5.17
    #   { "errorMessage": "<errorMessage>", "statusCode": "statusCode" }
    #from version 5.17
    #   { "message": "<http message>", "exception": "<former errorMessage>" }
    my $content_hash = JSON::decode_json($res->content);
    my $exception = $content_hash->{exception} || $content_hash->{errorMessage};
    #can return multiple values (e.g. 'application/json','charset=utf-8')
    my $ct = $res->content_type;
    my $args = {
        status_code => $res->code,
        message => $res->message,
        content => $res->content,
        content_type => $ct,
        error_message => $exception,
        exception => $exception

lib/Activiti/Rest/Response.pm  view on Meta::CPAN

    #The operation failed. The used method is not allowed for this resource. Eg. trying to update (PUT) a deployment-resource will result in a 405 status.
    elsif($code eq "405"){
      Activiti::Rest::Error::MethodNotAllowed->throw($args);
    }

    #The operation failed. The operation causes an update of a resource that has been updated by another operation, which makes the update no longer valid. Can also indicate a resource that is being created in a collection where a resource with that ...
    elsif($code eq "409"){
      Activiti::Rest::Error::Conflict->throw($args);
    }

    #The operation failed. The request body contains an unsupported media type. Also occurs when the request-body JSON contains an unknown attribute or value that doesn't have the right format/type to be accepted.
    elsif($code eq "415"){
      Activiti::Rest::Error::UnsupportedMediaType->throw($args);
    }

    #The operation failed. An unexpected exception occurred while executing the operation. The response-body contains details about the error.
    elsif($code eq "500"){
      Activiti::Rest::Error::InternalServerError->throw($args);
    }

    #common error

lib/Activiti/Rest/Response.pm  view on Meta::CPAN

  my(%new_args) = (
    code => $res->code,
    content_type => $content_type
  );

  if($res->code ne "204" && defined($content_type)){

    $new_args{content} = $res->content;

    if($content_type =~ /json/o){
      $new_args{parsed_content} = JSON::decode_json($res->content);
    }elsif($content_type =~ /(xml|html)/o){
      $new_args{parsed_content} = $res->decoded_content();
    }

  }

  __PACKAGE__->new(%new_args);
}

1;



( run in 1.333 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )