From 2da1326a2ba34b1e322af040b174f24c618dc1a7 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Wed, 31 Aug 2016 21:49:04 -0500 Subject: [PATCH] 71890: SelfService API: Return monthly recurring fee --- FS/FS/ClientAPI/MyAccount.pm | 23 +++++++++++++++++++++ FS/FS/ClientAPI_XMLRPC.pm | 1 + bin/xmlrpc-customer_recurring | 30 ++++++++++++++++++++++++++++ fs_selfservice/FS-SelfService/SelfService.pm | 26 ++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100755 bin/xmlrpc-customer_recurring diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 685821bad..07b1be903 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -672,6 +672,29 @@ sub customer_info_short { }; } +sub customer_recurring { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my %return; + + my $conf = new FS::Conf; + + my $search = { 'custnum' => $custnum }; + $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent'; + my $cust_main = qsearchs('cust_main', $search ) + or return { 'error' => "customer_info_short: unknown custnum $custnum" }; + + $return{'display_recurring'} = [ $cust_main->display_recurring ]; + + return { 'error' => '', + 'custnum' => $custnum, + %return, + }; +} + sub billing_history { my $p = shift; diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index 08c6c2d59..3167aa0e3 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -112,6 +112,7 @@ sub ss2clientapi { 'switch_cust' => 'MyAccount/switch_cust', 'customer_info' => 'MyAccount/customer_info', 'customer_info_short' => 'MyAccount/customer_info_short', + 'customer_recurring' => 'MyAccount/customer_recurring', 'contact_passwd' => 'MyAccount/contact/contact_passwd', 'list_contacts' => 'MyAccount/contact/list_contacts', diff --git a/bin/xmlrpc-customer_recurring b/bin/xmlrpc-customer_recurring new file mode 100755 index 000000000..18dd3e896 --- /dev/null +++ b/bin/xmlrpc-customer_recurring @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use Frontier::Client; +use Data::Dumper; + +my( $email, $password ) = @ARGV; +die "Usage: xmlrpc-customer_recurring email password\n" + unless $email && length($password); + +my $uri = new URI 'http://localhost:8080/'; + +my $server = new Frontier::Client ( 'url' => $uri ); + +my $login_result = $server->call( + 'FS.ClientAPI_XMLRPC.login', + 'email' => $email, + 'password' => $password, +); +die $login_result->{'error'}."\n" if $login_result->{'error'}; + +my $list_result = $server->call( + 'FS.ClientAPI_XMLRPC.customer_recurring', + 'session_id' => $login_result->{'session_id'}, +); +die $list_result->{'error'}."\n" if $list_result->{'error'}; + +print Dumper($list_result); + +1; diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 3be4ebd8b..185e3e2db 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -33,6 +33,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'switch_cust' => 'MyAccount/switch_cust', 'customer_info' => 'MyAccount/customer_info', 'customer_info_short' => 'MyAccount/customer_info_short', + 'customer_recurring' => 'MyAccount/customer_recurring', 'contact_passwd' => 'MyAccount/contact/contact_passwd', 'list_contacts' => 'MyAccount/contact/list_contacts', @@ -508,6 +509,31 @@ first last company address1 address2 city county state zip country daytime night =back +=item customer_recurring HASHREF + +Takes a hash reference as parameter with a single key B +or keys B and B. + +Returns a hash reference with the keys error, custnum and display_recurring. + +display_recurring is an arrayref of hashrefs with the following keys: + +=over 4 + +=item freq + +frequency of charge, in months unless units are specified + +=item freq_pretty + +frequency of charge, suitable for display + +=item amount + +amount charged at this frequency + +=back + =item edit_info HASHREF Takes a hash reference as parameter with any of the following keys: -- 2.11.0