signups with snarf info!
[freeside.git] / FS / FS / acct_snarf.pm
1 package FS::acct_snarf;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record;
6
7 @ISA = qw( FS::Record );
8
9 =head1 NAME
10
11 FS::acct_snarf - Object methods for acct_snarf records
12
13 =head1 SYNOPSIS
14
15   use FS::acct_snarf;
16
17   $record = new FS::acct_snarf \%hash;
18   $record = new FS::acct_snarf { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::svc_acct object represents an external mail account, typically for
31 download of mail.  FS::acct_snarf inherits from FS::Record.  The following
32 fields are currently supported:
33
34 =over 4
35
36 =item snarfnum - primary key
37
38 =item svcnum - Account (see L<FS::svc_acct>)
39
40 =item machine - external machine to download mail from
41
42 =item protocol - protocol (pop3, imap, etc.)
43
44 =item username - external login username
45
46 =item _password - external login password
47
48 =back
49
50 =head1 METHODS
51
52 =over 4
53
54 =item new HASHREF
55
56 Creates a new record.  To add the record to the database, see L<"insert">.
57
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to.  You can ask the object for a copy with the I<hash> method.
60
61 =cut
62
63 sub table { 'acct_snarf'; }
64
65 =item insert
66
67 Adds this record to the database.  If there is an error, returns the error,
68 otherwise returns false.
69
70 =cut
71
72 # the insert method can be inherited from FS::Record
73
74 =item delete
75
76 Delete this record from the database.
77
78 =cut
79
80 # the delete method can be inherited from FS::Record
81
82 =item replace OLD_RECORD
83
84 Replaces the OLD_RECORD with this one in the database.  If there is an error,
85 returns the error, otherwise returns false.
86
87 =cut
88
89 # the replace method can be inherited from FS::Record
90
91 =item check
92
93 Checks all fields to make sure this is a valid external mail account.  If
94 there is an error, returns the error, otherwise returns false.  Called by the
95 insert and replace methods.
96
97 =cut
98
99 sub check {
100   my $self = shift;
101   my $error =
102        $self->ut_numbern('snarfnum')
103     || $self->ut_number('svcnum')
104     || $self->ut_foreign_key('svcnum', 'svc_acct', 'svcnum')
105     || $self->ut_domain('machine')
106     || $self->ut_alphan('protocol')
107     || $self->ut_textn('username')
108   ;
109   return $error if $error;
110
111   $self->_password =~ /^[^\t\n]*$/ or return "illegal password";
112   $self->_password($1);
113
114   ''; #no error
115 }
116
117 =back
118
119 =head1 BUGS
120
121 =head1 SEE ALSO
122
123 L<FS::Record>, schema.html from the base documentation.
124
125 =cut
126
127 1;
128