summaryrefslogtreecommitdiff
path: root/FS/FS/svc_CGPRule_Mixin.pm
blob: cf2eca76c1609f41cadc2d8893c426b173f45a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package FS::svc_CGPRule_Mixin;

use strict;
use FS::Record qw(qsearch);
use FS::cgp_rule;

=head1 NAME

FS::svc_CGPRule_Mixin - Mixin class for svc_classes which can be related to cgp_rule

=head1 SYNOPSIS

package FS::svc_table;
use base qw( FS::svc_CGPRule_Mixin FS::svc_Common );

=head1 DESCRIPTION

This is a mixin class for svc_ classes that can have Communigate Pro rules
(currently, domains and accounts).

=head1 METHODS

=over 4

=item cgp_rule

Returns the rules associated with this service, as FS::cgp_rule objects.

=cut

sub cgp_rule {
  my $self = shift;
  qsearch({
    'table'    => 'cgp_rule',
    'hashref'  => { 'svcnum' => $self->svcnum },
    'order_by' => 'ORDER BY priority ASC',
  });
}

=item cgp_rule_arrayref

Returns an arrayref of rules suitable for Communigate Pro API commands.

=cut

sub cgp_rule_arrayref {
  my $self = shift;
  [ map $_->arrayref, $self->cgp_rule ];
}

=back

=head1 BUGS

=head1 SEE ALSO

L<FS::cgp_rule>

=cut

1;