server side trivial API
Check if a member is financial, return simple text (suitable for use by external code)
oms-demo-php-rest-isMemberFinancial
<?php
header('Content-type: text/plain');
if ( ! isset($_REQUEST['member'])) { exit("nomatch\n"); }
$userpw='guest:nosecret';
$baseurl='https://oms.economicoutlook.net/demo/apis/rest/admin/';
$groupId='744fb3bd-35a1-44f4-8c82-4ca8ac78f3d8';
$searchstring=urlencode($_REQUEST['member']);
$url=$baseurl.'associations/memberships?groupId='.$groupId.'&reference='.$searchstring;
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, $userpw);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_URL, $url );
$reply=curl_exec($ch);
$result= json_decode($reply);
if ($result->response->records == 0 ) { exit("nomatch\n"); }
exit ( $result->response->membershipAssociations[0]->unfinancial ? "unfinancial\n" : "financial\n" );
?>
rest script query
Search for the first 5 people matching a query string and print their fancy email address.
Takes the search string from the first parameter and the user:password from the OMSPW environment variable.
oms-demo-script-php-rest-findEmail
#!/usr/bin/php
<?php
$searchstring=urlencode($argv[1]);
$userpw=getenv('OMSPW');
$baseurl='https://oms.economicoutlook.net/demo/apis/rest/admin/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, $userpw);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json',) );
$url=$baseurl.'people?take=5&query='.$searchstring;
curl_setopt($ch, CURLOPT_URL, $url );
$reply=curl_exec($ch);
$result= json_decode($reply);
isset ($result->people->person[0]) or exit("no match found\n");
foreach ($result->people->person as &$person) {
echo "$person->firstNames $person->lastName <$person->email>\n";
}
?>
eg:
$ OMSPW="guest:nosecret" php oms-demo-script-php-rest-findEmail "adrian butterworth"
production subscription billing utility
This is a production OMS utility that bulk bills subscription renewals. The zipfile contains:
-
billSubsRenewals.sh - the cron job
-
bill.php - the launcher
-
SubscriptionBilling.php - the main code module
-
several billing algorithm processors.
The script is run daily via cron and calls bill.php for each configuration file in the config directory.
eg:
$ bill.php democonfig.json 2016-08-10
example democonfig.json
{
"username":"demosubsbilling",
"password":"top secret",
"url":"https://oms.economicoutlook.net/demo/apis/soap/eftgeneration",
"administrationUnitIds":["05878341-e3e8-406a-8088-245e00696bf0"]
}
example cron entry
0 16 * * * ~/apps/subscriptionbilling/billSubsRenewals.sh