summaryrefslogtreecommitdiff
path: root/FS/FS/svc_CGPRule_Mixin.pm
diff options
context:
space:
mode:
authorivan <ivan>2010-05-23 01:59:19 +0000
committerivan <ivan>2010-05-23 01:59:19 +0000
commit940401c77b8455dd47b57e06dcfedd7514c24a7c (patch)
tree1abfdb7847feeba2b6bbba7687f869a62f55dda0 /FS/FS/svc_CGPRule_Mixin.pm
parentfc3c94d637caecb7932c09fb1e7baceaad069eda (diff)
communigate pro rules, RT#7515
Diffstat (limited to 'FS/FS/svc_CGPRule_Mixin.pm')
-rw-r--r--FS/FS/svc_CGPRule_Mixin.pm61
1 files changed, 61 insertions, 0 deletions
diff --git a/FS/FS/svc_CGPRule_Mixin.pm b/FS/FS/svc_CGPRule_Mixin.pm
new file mode 100644
index 0000000..4501580
--- /dev/null
+++ b/FS/FS/svc_CGPRule_Mixin.pm
@@ -0,0 +1,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
+
+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;