[freeside-commits] branch FREESIDE_3_BRANCH updated. b09e1848dec8bcd74f67de910532d195810590ad

Christopher Burger burgerc at 420.am
Tue Aug 22 04:43:02 PDT 2017


The branch, FREESIDE_3_BRANCH has been updated
       via  b09e1848dec8bcd74f67de910532d195810590ad (commit)
       via  f633e15977df07607b8b91782237f919328e6cc9 (commit)
      from  60379ff3215e4bfe644c4777e8156195133d9c49 (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 b09e1848dec8bcd74f67de910532d195810590ad
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Aug 21 12:40:42 2017 -0400

    RT# 27969 - added documentation for advertising_sources api functions

diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index 29b6118..99b2f91 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -908,6 +908,34 @@ sub bill_now {
 
 #next.. Delete Advertising sources?
 
+=item list_advertising_sources OPTION => VALUE, ...
+
+Lists all advertising sources.
+
+=over
+
+=item secret
+
+API Secret
+
+=back
+
+Example:
+
+  my $result = FS::API->list_advertising_sources(
+    'secret'  => 'sharingiscaring',
+  );
+
+  if ( $result->{'error'} ) {
+    die $result->{'error'};
+  } else {
+    # list advertising sources returns an array of hashes for sources.
+    print Dumper($result->{'sources'});
+  }
+
+=cut
+
+#list_advertising_sources
 sub list_advertising_sources {
   my( $class, %opt ) = @_;
   return _shared_secret_error() unless _check_shared_secret($opt{secret});
@@ -922,6 +950,56 @@ sub list_advertising_sources {
   $return;
 }
 
+=item add_advertising_source OPTION => VALUE, ...
+
+Add a new advertising source.
+
+=over
+
+=item secret
+
+API Secret
+
+=item referral
+
+Referral name
+
+=item disabled
+
+Referral disabled, Y for disabled or nothing for enabled
+
+=item agentnum
+
+Agent ID number
+
+=item title
+
+External referral ID
+
+=back
+
+Example:
+
+  my $result = FS::API->add_advertising_source(
+    'secret'     => 'sharingiscaring',
+    'referral'   => 'test referral',
+
+    #optional
+    'disabled'   => 'Y',
+    'agentnum'   => '2', #agent id number
+    'title'      => 'test title',
+  );
+
+  if ( $result->{'error'} ) {
+    die $result->{'error'};
+  } else {
+    # add_advertising_source returns new source upon success.
+    print Dumper($result);
+  }
+
+=cut
+
+#add_advertising_source
 sub add_advertising_source {
   my( $class, %opt ) = @_;
   return _shared_secret_error() unless _check_shared_secret($opt{secret});
@@ -940,6 +1018,70 @@ sub add_advertising_source {
   $return;
 }
 
+=item edit_advertising_source OPTION => VALUE, ...
+
+Edit a advertising source.
+
+=over
+
+=item secret
+
+API Secret
+
+=item refnum
+
+Referral number to edit
+
+=item source
+
+hash of edited source fields.
+
+=over
+
+=item referral
+
+Referral name
+
+=item disabled
+
+Referral disabled, Y for disabled or nothing for enabled
+
+=item agentnum
+
+Agent ID number
+
+=item title
+
+External referral ID
+
+=back
+
+=back
+
+Example:
+
+  my $result = FS::API->edit_advertising_source(
+    'secret'     => 'sharingiscaring',
+    'refnum'     => '4', # referral number to edit
+    'source'     => {
+       #optional
+       'referral'   => 'test referral',
+       'disabled'   => 'Y',
+       'agentnum'   => '2', #agent id number
+       'title'      => 'test title',
+    }
+  );
+
+  if ( $result->{'error'} ) {
+    die $result->{'error'};
+  } else {
+    # edit_advertising_source returns updated source upon success.
+    print Dumper($result);
+  }
+
+=cut
+
+#edit_advertising_source
 sub edit_advertising_source {
   my( $class, %opt ) = @_;
   return _shared_secret_error() unless _check_shared_secret($opt{secret});

commit f633e15977df07607b8b91782237f919328e6cc9
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 39a959a..29b6118 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -906,7 +906,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                                       |  200 +++++++++++++++++++-
 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, 263 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