fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / svc_External_Common.pm
1 package FS::svc_External_Common;
2
3 use strict;
4 use vars qw(@ISA);
5 use FS::svc_Common;
6
7 @ISA = qw( FS::svc_Common );
8
9 =head1 NAME
10
11 FS::svc_External_Common - Base class for svc_X classes which track external databases
12
13 =head1 SYNOPSIS
14
15   package FS::svc_newservice;
16   use base qw( FS::svc_External_Common );
17
18 =head1 DESCRIPTION
19
20 FS::svc_External_Common is intended as a base class for table-specific classes
21 to inherit from.  FS::svc_External_Common is used for services which connect
22 to externally tracked services via "id" and "table" fields.
23
24 FS::svc_External_Common inherits from FS::svc_Common.
25
26 The following fields are currently supported:
27
28 =over 4
29
30 =item svcnum - primary key
31
32 =item id - unique number of external record
33
34 =item title - for invoice line items
35
36 =back
37
38 =head1 METHODS
39
40 =over 4
41
42 =item search_sql
43
44 Provides a default search_sql method which returns an SQL fragment to search
45 the B<title> field.
46
47 =cut
48
49 sub search_sql {
50   my($class, $string) = @_;
51   $class->search_sql_field('title', $string);
52 }
53
54 =item new HASHREF
55
56 Creates a new external service.  To add the external service to the database,
57 see L<"insert">.  
58
59 Note that this stores the hash reference, not a distinct copy of the hash it
60 points to.  You can ask the object for a copy with the I<hash> method.
61
62 =cut
63
64 =item label
65
66 Returns a string identifying this external service in the form "id:title"
67
68 =cut
69
70 sub label {
71   my $self = shift;
72   $self->id. ':'. $self->title;
73 }
74
75 =item insert [ , OPTION => VALUE ... ]
76
77 Adds this external service to the database.  If there is an error, returns the
78 error, otherwise returns false.
79
80 The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be 
81 defined.  An FS::cust_svc record will be created and inserted.
82
83 Currently available options are: I<depend_jobnum>
84
85 If I<depend_jobnum> is set (to a scalar jobnum or an array reference of
86 jobnums), all provisioning jobs will have a dependancy on the supplied
87 jobnum(s) (they will not run until the specific job(s) complete(s)).
88
89 =cut
90
91 #sub insert {
92 #  my $self = shift;
93 #  my $error;
94 #
95 #  $error = $self->SUPER::insert(@_);
96 #  return $error if $error;
97 #
98 #  '';
99 #}
100
101 =item delete
102
103 Delete this record from the database.
104
105 =cut
106
107 #sub delete {
108 #  my $self = shift;
109 #  my $error;
110 #
111 #  $error = $self->SUPER::delete;
112 #  return $error if $error;
113 #
114 #  '';
115 #}
116
117
118 =item replace OLD_RECORD
119
120 Replaces the OLD_RECORD with this one in the database.  If there is an error,
121 returns the error, otherwise returns false.
122
123 =cut
124
125 #sub replace {
126 #  my ( $new, $old ) = ( shift, shift );
127 #  my $error;
128 #
129 #  $error = $new->SUPER::replace($old);
130 #  return $error if $error;
131 #
132 #  '';
133 #}
134
135 =item suspend
136
137 Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>).
138
139 =item unsuspend
140
141 Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>).
142
143 =item cancel
144
145 Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>).
146
147 =item check
148
149 Checks all fields to make sure this is a valid external service.  If there is
150 an error, returns the error, otherwise returns false.  Called by the insert
151 and replace methods.
152
153 =cut
154
155 sub check {
156   my $self = shift;
157
158   my $x = $self->setfixed;
159   return $x unless ref($x);
160   my $part_svc = $x;
161
162   my $error = 
163     $self->ut_numbern('svcnum')
164     || $self->ut_numbern('id')
165     || $self->ut_textn('title')
166   ;
167
168   $self->SUPER::check;
169 }
170
171 =back
172
173 =head1 BUGS
174
175 =head1 SEE ALSO
176
177 L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>,
178 L<FS::cust_pkg>, schema.html from the base documentation.
179
180 =cut
181
182 1;
183