summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/REST/1.0/.cust_bill.swpbin0 -> 12288 bytes
-rw-r--r--httemplate/REST/1.0/.cust_main.swpbin0 -> 12288 bytes
-rw-r--r--httemplate/REST/1.0/.cust_pkg.swpbin0 -> 12288 bytes
-rw-r--r--httemplate/REST/1.0/.part_pkg.swpbin0 -> 12288 bytes
-rw-r--r--httemplate/REST/1.0/.phone_avail.swpbin0 -> 12288 bytes
-rw-r--r--httemplate/REST/1.0/.rate_detail.swpbin0 -> 12288 bytes
-rw-r--r--httemplate/REST/1.0/cust_bill28
-rw-r--r--httemplate/REST/1.0/cust_main81
-rw-r--r--httemplate/REST/1.0/cust_pkg39
-rw-r--r--httemplate/REST/1.0/part_pkg40
-rw-r--r--httemplate/REST/1.0/phone_avail25
-rw-r--r--httemplate/REST/1.0/rate_detail35
12 files changed, 248 insertions, 0 deletions
diff --git a/httemplate/REST/1.0/.cust_bill.swp b/httemplate/REST/1.0/.cust_bill.swp
new file mode 100644
index 000000000..44d4de7a9
--- /dev/null
+++ b/httemplate/REST/1.0/.cust_bill.swp
Binary files differ
diff --git a/httemplate/REST/1.0/.cust_main.swp b/httemplate/REST/1.0/.cust_main.swp
new file mode 100644
index 000000000..d785784d3
--- /dev/null
+++ b/httemplate/REST/1.0/.cust_main.swp
Binary files differ
diff --git a/httemplate/REST/1.0/.cust_pkg.swp b/httemplate/REST/1.0/.cust_pkg.swp
new file mode 100644
index 000000000..451a98554
--- /dev/null
+++ b/httemplate/REST/1.0/.cust_pkg.swp
Binary files differ
diff --git a/httemplate/REST/1.0/.part_pkg.swp b/httemplate/REST/1.0/.part_pkg.swp
new file mode 100644
index 000000000..547a79eee
--- /dev/null
+++ b/httemplate/REST/1.0/.part_pkg.swp
Binary files differ
diff --git a/httemplate/REST/1.0/.phone_avail.swp b/httemplate/REST/1.0/.phone_avail.swp
new file mode 100644
index 000000000..a65bb2748
--- /dev/null
+++ b/httemplate/REST/1.0/.phone_avail.swp
Binary files differ
diff --git a/httemplate/REST/1.0/.rate_detail.swp b/httemplate/REST/1.0/.rate_detail.swp
new file mode 100644
index 000000000..8d46a280f
--- /dev/null
+++ b/httemplate/REST/1.0/.rate_detail.swp
Binary files differ
diff --git a/httemplate/REST/1.0/cust_bill b/httemplate/REST/1.0/cust_bill
new file mode 100644
index 000000000..926cf3bee
--- /dev/null
+++ b/httemplate/REST/1.0/cust_bill
@@ -0,0 +1,28 @@
+<% encode_rest($return) %>\
+<%init>
+
+rest_auth($cgi);
+
+my( $invnum, $command ) = split('/', rest_uri_remain($r, $m) );
+
+my $cust_bill = qsearchs('cust_bill', { 'invnum'=>$invnum } )
+ or die "unknown invnum $invnum";
+
+my $return = [];
+
+if ( $command eq '' ) {
+
+ my @fields = fields('cust_bill');
+ $return = +{ map { $_=>$cust_bill->$_ } @fields };
+
+} elsif ( $command eq 'cust_bill_pkg' ) {
+
+ my @fields = fields('cust_bill_pkg');
+ $return = [ map { my $cust_bill_pkg = $_;
+ +{ map { $_=>$cust_bill_pkg->$_ } @fields };
+ }
+ $cust_bill->cust_bill_pkg
+ ];
+}
+
+</%init>
diff --git a/httemplate/REST/1.0/cust_main b/httemplate/REST/1.0/cust_main
new file mode 100644
index 000000000..89c558cc2
--- /dev/null
+++ b/httemplate/REST/1.0/cust_main
@@ -0,0 +1,81 @@
+<% encode_rest($return) %>\
+<%init>
+
+rest_auth($cgi);
+
+my( $custnum, $command ) = split('/', rest_uri_remain($r, $m), 2 );
+
+if ( $r->method eq 'GET' ) {
+
+ my $return = [];
+
+ if ( $custnum ) {
+
+ my $cust_main = qsearchs('cust_main', { 'custnum'=>$custnum } )
+ or die "unknown custnum $custnum";
+
+ if ( $command eq '' ) {
+
+ $return = $cust_main->API_getinfo;
+
+ } elsif ( $command =~ /^(cust_(pkg|attachment|bill|pay))$/ ) {
+
+ my $method = $1;
+
+ $return = [ map $_->API_getinfo, $cust_main->$method ];
+
+ } elsif ( $command eq 'part_pkg' ) {
+
+ my %pkgpart = map { $_->pkgpart => 1 } $cust_main->cust_pkg;
+
+ $return = [ map $_->API_getinfo,
+ map qsearchs('part_pkg', { 'pkgpart'=>$_ }),
+ keys %pkgpart;
+ ];
+
+ }
+
+ } else { #list
+
+ my %hash = ( map { $_ => scalar($cgi->param($_)) }
+ qw( agentnum salesnum refnum classnum usernum
+ referral_custnum
+ )
+ );
+
+ my $extra_sql = '';
+ if ( $cgi->param('cust_main_invoice_dest') ) {
+ my $dest = dbh->quote(scalar($cgi->param('cust_main_invoice_dest')));
+ $extra_sql = "
+ WHERE EXISTS ( SELECT 1 FROM cust_main_invoice
+ WHERE cust_main.custnum = cust_main_invoice.custnum
+ AND dest = $dest
+ )
+ ";
+ } elsif ( $cgi->param('cust_main_invoice_dest_substring') ) {
+ my $dest = dbh->quote('%'. scalar($cgi->param('cust_main_invoice_dest_substring')). '%');
+ $extra_sql = "
+ WHERE EXISTS ( SELECT 1 FROM cust_main_invoice
+ WHERE cust_main.custnum = cust_main_invoice.custnum
+ AND dest ILIKE $dest
+ )
+ ";
+ }
+
+ my @cust_main = qsearch({
+ 'table' => 'cust_main',
+ 'hashref' => \%hash,
+ 'extra_sql' => $extra_sql;
+ });
+
+ $return = [ map $_->API_getinfo, @cust_main ];
+
+ }
+
+} elsif ( $r->method eq 'POST' ) { #create new
+
+} elsif ( $r->method eq 'PUT' ) { #modify
+
+}
+
+</%init>
diff --git a/httemplate/REST/1.0/cust_pkg b/httemplate/REST/1.0/cust_pkg
new file mode 100644
index 000000000..3c58bcf31
--- /dev/null
+++ b/httemplate/REST/1.0/cust_pkg
@@ -0,0 +1,39 @@
+<% encode_rest($return) %>\
+<%init>
+
+rest_auth($cgi);
+
+my( $pkgnum, $command ) = split('/', rest_uri_remain($r, $m), 2 );
+
+if ( $r->method eq 'GET' ) {
+
+ my $return = [];
+
+ if ( $pkgnum ) {
+
+ my $cust_pkg = qsearchs('cust_main', { 'pkgnum'=>$pkgnum } )
+ or die "unknown pkgnum $pkgnum";
+
+ if ( $command eq '' ) {
+
+ $return = $cust_pkg->API_getinfo;
+
+ } elsif ( $command eq 'cust_svc' ) {
+
+ $return = [ map $_->API_getinfo, $cust_pkg->cust_svc ];
+
+ }
+
+
+
+ #} else { #list
+
+ }
+
+} elsif ( $r->method eq 'POST' ) { #create new
+
+} elsif ( $r->method eq 'PUT' ) { #modify
+
+}
+
+</%init>
diff --git a/httemplate/REST/1.0/part_pkg b/httemplate/REST/1.0/part_pkg
new file mode 100644
index 000000000..c81b7b89b
--- /dev/null
+++ b/httemplate/REST/1.0/part_pkg
@@ -0,0 +1,40 @@
+<% encode_rest($return) %>\
+<%init>
+
+rest_auth($cgi);
+
+my( $pkgpart, $command ) = split('/', rest_uri_remain($r, $m) );
+
+my @fields = fields('part_pkg');
+
+my $return = [];
+
+if ( $pkgpart ) {
+
+ my $part_pkg = qsearchs('part_pkg', { 'pkgpart'=>$pkgpart } )
+ or die "unknown pkgpart $pkgpart";
+
+ if ( $command eq '' ) {
+
+ $return = $part_pkg->API_getinfo;
+
+ } elsif ( $command eq 'customers' ) {
+ die 'XXX not yet implemented';
+ #XXX redirect to a cust_main search?
+ }
+
+} else {
+
+ my %hash = ( map { $_ => scalar($cgi->param($_)) }
+ qw( disabled classnum )
+ );
+
+ my @part_pkg = qsearch('part_pkg', \%hash);
+
+ $return = [ map $part_pkg->API_getinfo, @part_pkg ];
+
+}
+
+
+
+</%init>
diff --git a/httemplate/REST/1.0/phone_avail b/httemplate/REST/1.0/phone_avail
new file mode 100644
index 000000000..ef9d3e7f0
--- /dev/null
+++ b/httemplate/REST/1.0/phone_avail
@@ -0,0 +1,25 @@
+<% encode_rest($phonenums) %>\
+<%init>
+
+rest_auth($cgi);
+
+#i'm basically a simpler misc/phonenums.cgi
+
+my $svcpart = $cgi->param('svcpart');
+
+my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
+die "unknown svcpart $svcpart" unless $part_svc;
+
+my @exports = $part_svc->part_export_did;
+if ( scalar(@exports) > 1 ) {
+ die "more than one DID-providing export attached to svcpart $svcpart";
+} elsif ( ! @exports ) {
+ die "no DID providing export attached to svcpart $svcpart";
+}
+my $export = $exports[0];
+
+my $phonenums = $export->get_dids( map { $_ => scalar($cgi->param($_)) }
+ qw( ratecenter state areacode exchange )
+ );
+
+</%init>
diff --git a/httemplate/REST/1.0/rate_detail b/httemplate/REST/1.0/rate_detail
new file mode 100644
index 000000000..54e55de6c
--- /dev/null
+++ b/httemplate/REST/1.0/rate_detail
@@ -0,0 +1,35 @@
+<% encode_rest( \@rate_detail ) %>\
+<%init>
+
+rest_auth($cgi);
+
+my $extra_sql = '';
+if ( $cgi->param('countrycode') =~ /^\+?(\d+)$/ ) {
+ my $countrycode = $1;
+ $extra_sql = "
+ WHERE EXISTS ( SELECT 1 rate_region
+ WHERE rate_detail.dest_regionnum = rate_region.regionnum
+ AND countrycode = '$countrycode'
+ ";
+}
+
+my @detail_fields = fields('rate_detail');
+my @region_fields = fields('rate_region');
+
+my @rate_detail =
+ map {
+ my $rate_detail = $_;
+ my $rate_region = $rate_detail->dest_region;
+
+ +{
+ ( map { $_ => $rate_detail->$_ } @detail_fields ),
+ ( map { $_ => $rate_region->$_ } @region_fields ),
+ };
+
+ } qsearch({
+ 'table' => 'rate_detail',
+ 'hashref' => {},
+ extra_sql => $extra_sql,
+ });
+
+</%init>