1package Net::Gnats::Command::FTYP; 2use parent 'Net::Gnats::Command'; 3use strictures; 4BEGIN { 5 $Net::Gnats::Command::FTYP::VERSION = '0.22'; 6} 7use vars qw($VERSION); 8 9use Net::Gnats::Constants qw(CODE_INFORMATION CODE_INVALID_FIELD_NAME); 10 11=head1 NAME 12 13Net::Gnats::Command::FTYP 14 15=head1 DESCRIPTION 16 17Describes the type of data held in the field(s) specified with the 18command. 19 20If multiple field names were given, multiple response lines will be 21sent, one for each field, using the standard continuation protocol; 22each response except the last will have a dash - immedately after 23the response code. 24 25The currently defined data types are: 26 27Text 28 29A plain text field, containing exactly one line. 30 31MultiText 32 33A text field possibly containing multiple lines of text. 34 35Enum 36 37An enumerated data field; the value is restricted to one entry out 38of a list of values associated with the field. 39 40MultiEnum 41 42The field contains one or more enumerated values. Values are 43separated with spaces or colons :. 44 45Integer 46 47The field contains an integer value, possibly signed. 48 49Date 50 51The field contains a date. 52 53TextWithRegex 54 55The value in the field must match one or more regular expressions 56associated with the field. 57 58=head1 PROTOCOL 59 60 FTYP [fields...] 61 62=head1 RESPONSES 63 64The possible responses are: 65 66350 (CODE_INFORMATION) 67 68The normal response; the supplied text is the data type. 69 70410 (CODE_INVALID_FIELD_NAME) 71 72The specified field does not exist. 73 74=cut 75 76 77my $c = 'FTYP'; 78 79sub new { 80 my ( $class, %options ) = @_; 81 my $self = bless \%options, $class; 82 $self->{requests_multi} = 0; 83 return $self if not defined $self->{fields}; 84 85 if (ref $self->{fields} eq 'ARRAY') { 86 $self->{requests_multi} = 1 if scalar @{ $self->{fields} } > 1; 87 } 88 else { 89 $self->{fields} = [ $self->{fields} ]; 90 } 91 return $self; 92} 93 94sub as_string { 95 my ($self) = @_; 96 return undef if not defined $self->{fields}; 97 return $c . ' ' . join ( ' ', @{$self->{fields}} ); 98} 99 100# this command can take multiple fields, each getting their own response. 101# so, we check that 'everything' is okay by looking at the parent response. 102sub is_ok { 103 my $self = shift; 104 return 0 if not defined $self->response; 105 return 0 if not defined $self->response->code; 106 107 if ( $self->{requests_multi} == 0 and 108 $self->response->code == CODE_INFORMATION) { 109 return 1; 110 } 111 return 1 if $self->response->code == CODE_INFORMATION; 112 return 0; 113} 114 115 1161; 117