[freeside-commits] branch master updated. 05de6d688077b77b7da5bc8ae238871f354459a9

Christopher Burger burgerc at 420.am
Mon Aug 21 08:43:00 PDT 2017


The branch, master has been updated
       via  05de6d688077b77b7da5bc8ae238871f354459a9 (commit)
      from  7d80f005462758e0271215240cdf99a9336f03dd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 05de6d688077b77b7da5bc8ae238871f354459a9
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Aug 21 11:42:36 2017 -0400

    RT# 27969 - created 3 new api functions to add, edit and list advertising sources

diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index fd3793d..735088f 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -719,7 +719,63 @@ sub bill_now {
 }
 
 
-#next.. Advertising sources?
+#next.. Delete Advertising sources?
+
+sub list_advertising_sources {
+  my( $class, %opt ) = @_;
+  return _shared_secret_error() unless _check_shared_secret($opt{secret});
+
+  my @sources = qsearch('part_referral', {}, '', "")
+    or return { 'error' => 'No referrals' };
+
+  my $return = {
+    'sources'       => [ map $_->hashref, @sources ],
+  };
+
+  $return;
+}
+
+sub add_advertising_source {
+  my( $class, %opt ) = @_;
+  return _shared_secret_error() unless _check_shared_secret($opt{secret});
+
+  use FS::part_referral;
+
+  my $new_source = $opt{source};
+
+  my $source = new FS::part_referral $new_source;
+
+  my $error = $source->insert;
+
+  my $return = {$source->hash};
+  $return = { 'error' => $error, } if $error;
+
+  $return;
+}
+
+sub edit_advertising_source {
+  my( $class, %opt ) = @_;
+  return _shared_secret_error() unless _check_shared_secret($opt{secret});
+
+  use FS::part_referral;
+
+  my $refnum = $opt{refnum};
+  my $source = $opt{source};
+
+  my $old = FS::Record::qsearchs('part_referral', {'refnum' => $refnum,});
+  my $new = new FS::part_referral { $old->hash };
+
+  foreach my $key (keys %$source) {
+    $new->$key($source->{$key});
+  }
+
+  my $error = $new->replace;
+
+  my $return = {$new->hash};
+  $return = { 'error' => $error, } if $error;
+
+  $return;
+}
 
 
 ##
diff --git a/bin/xmlrpc-advertising_sources-add.pl b/bin/xmlrpc-advertising_sources-add.pl
new file mode 100755
index 0000000..4800ad0
--- /dev/null
+++ b/bin/xmlrpc-advertising_sources-add.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+my $uri = new URI 'http://localhost:8008/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $result = $server->call(
+  'FS.API.add_advertising_source',
+    'secret' => 'MySecretCode',
+    'source' => {
+    		'referral' => 'API test referral',
+    		'disabled' => '',
+    		'agentnum' => '',
+    		'title'    => 'API test title',
+    	},
+);
+
+die $result->{'error'} if $result->{'error'};
+
+print Dumper($result);
+
+print "\nAll Done\n";
+
+exit;
\ No newline at end of file
diff --git a/bin/xmlrpc-advertising_sources-edit.pl b/bin/xmlrpc-advertising_sources-edit.pl
new file mode 100755
index 0000000..80f9139
--- /dev/null
+++ b/bin/xmlrpc-advertising_sources-edit.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+my $uri = new URI 'http://localhost:8008/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $result = $server->call(
+  'FS.API.edit_advertising_source',
+    'secret' => 'MySecretCode',
+    'refnum' => '4',
+    'source' => {
+    		'referral' => 'Edit referral',
+    		'title'    => 'Edit Referral title',
+    		#'disabled' => 'Y',
+    		#'disabled' => '',
+    		#'agentnum' => '2',
+    	},
+);
+
+die $result->{'error'} if $result->{'error'};
+
+print Dumper($result);
+
+print "\nAll Done\n";
+
+exit;
\ No newline at end of file
diff --git a/bin/xmlrpc-advertising_sources-list.pl b/bin/xmlrpc-advertising_sources-list.pl
new file mode 100755
index 0000000..317a38b
--- /dev/null
+++ b/bin/xmlrpc-advertising_sources-list.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+my $uri = new URI 'http://localhost:8008/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $result = $server->call(
+  'FS.API.list_advertising_sources',
+    'secret'  => 'MySecretCode',
+);
+
+die $result->{'error'} if $result->{'error'};
+
+print Dumper($result);
+
+print "\nAll Done\n";
+
+exit;
\ No newline at end of file

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/API.pm                                       |   58 +++++++++++++++++++-
 bin/xmlrpc-advertising_sources-add.pl              |   28 ++++++++++
 bin/xmlrpc-advertising_sources-edit.pl             |   30 ++++++++++
 ...ion_info => xmlrpc-advertising_sources-list.pl} |   11 ++--
 4 files changed, 121 insertions(+), 6 deletions(-)
 create mode 100755 bin/xmlrpc-advertising_sources-add.pl
 create mode 100755 bin/xmlrpc-advertising_sources-edit.pl
 copy bin/{xmlrpc-location_info => xmlrpc-advertising_sources-list.pl} (61%)




More information about the freeside-commits mailing list