File Coverage

blib/lib/WebService/Freshservice/User/CustomField.pm
Criterion Covered Total %
statement 28 36 77.7
branch 0 4 0.0
condition n/a
subroutine 11 13 84.6
pod n/a
total 39 53 73.5


line stmt bran cond sub pod time code
1             package WebService::Freshservice::User::CustomField;
2              
3 2     2   28 use v5.010;
  2         9  
4 2     2   14 use strict;
  2         6  
  2         52  
5 2     2   13 use warnings;
  2         5  
  2         68  
6 2     2   15 use Method::Signatures 20140224;
  2         29  
  2         27  
7 2     2   988 use List::MoreUtils qw(any);
  2         7  
  2         13  
8 2     2   1200 use Carp qw( croak );
  2         5  
  2         119  
9 2     2   15 use JSON qw( encode_json );
  2         5  
  2         12  
10 2     2   216 use Moo;
  2         7  
  2         24  
11 2     2   896 use namespace::clean;
  2         7  
  2         18  
12              
13             # ABSTRACT: Freshservice User Custom Field
14              
15             our $VERSION = '0.004'; # VERSION: Generated by DZP::OurPkg:Version
16              
17              
18             my $Ref = sub {
19             croak("api isn't a 'WebService::Freshservice::API' object!") unless $_[0]->DOES("WebService::Freshservice::API");
20             };
21              
22             has 'api' => ( is => 'rw', required => 1, isa => $Ref );
23             has 'id' => ( is => 'ro', required => 1 );
24             has 'field' => ( is => 'rw', required => 1 );
25             has 'value' => ( is => 'rw', required => 1 );
26              
27              
28 2 0   2   3135 method update_custom_field {
  0     0      
  0            
29 0           my $data->{user}{custom_field}{$self->field} = $self->value;
30 0           $self->api->put_api( "itil/requesters/".$self->id.".json", $data);
31 0           return 1;
32             }
33              
34             # Internal method that returns a clean perl data structure
35             # for encode_json
36 2 0   2   1936 method TO_JSON {
  0     0      
  0            
37 0           return $self->value;
38             }
39              
40             1;
41              
42             __END__
43              
44             =pod
45              
46             =encoding UTF-8
47              
48             =head1 NAME
49              
50             WebService::Freshservice::User::CustomField - Freshservice User Custom Field
51              
52             =head1 VERSION
53              
54             version 0.004
55              
56             =head1 SYNOPSIS
57              
58             use WebService::Freshservice::User::CustomField;
59              
60             my $customfield = WebService::Freshservice::User::CustomField->new( api => $api, id => '1234567890' raw => $data );
61              
62             Requires an 'WebService::Freshservice::API' object, id of the user and
63             'raw' data.
64              
65             =head1 DESCRIPTION
66              
67             Provides a Freshservice user custom field object.
68              
69             =head1 METHODS
70              
71             =head2 update_custom_field
72              
73             =head1 AUTHOR
74              
75             Leon Wright <techman@cpan.org>
76              
77             =head1 COPYRIGHT AND LICENSE
78              
79             This software is copyright (c) 2016 by Leon Wright.
80              
81             This is free software; you can redistribute it and/or modify it under
82             the same terms as the Perl 5 programming language system itself.
83              
84             =cut