Update examples

This commit is contained in:
AnthorNet 2018-11-23 08:58:09 +01:00
parent a733ff22ed
commit eb137fbcba
4 changed files with 170 additions and 206 deletions

View File

@ -125,14 +125,14 @@ while (true)
$converted = false; $converted = false;
// Handle commodity v1 // Handle commodity v1
if($json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/1' . (($debugEDDN === true) ? '/test' : '')) if($json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/1' . (($debugEDDN === true) ? '/test' : ''))
{ {
echoLogJSON($message); echoLogJSON($message);
echoLog('Receiving commodity-v1 message...'); echoLog('Receiving commodity-v1 message...');
echoLog(' - Converting to v2...'); echoLog(' - Converting to v2...');
$temp = array(); $temp = array();
$temp['$schemaRef'] = 'http://schemas.elite-markets.net/eddn/commodity/2' . (($debugEDDN === true) ? '/test' : ''); $temp['$schemaRef'] = 'https://eddn.edcd.io/schemas/commodity/3' . (($debugEDDN === true) ? '/test' : '');
$temp['header'] = $json['header']; $temp['header'] = $json['header'];
$temp['message'] = array(); $temp['message'] = array();
@ -169,13 +169,13 @@ while (true)
} }
// Handle commodity v2 // Handle commodity v3
if($json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2' . (($debugEDDN === true) ? '/test' : '')) if($json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' . (($debugEDDN === true) ? '/test' : ''))
{ {
if($converted === false) if($converted === false)
{ {
echoLogJSON($message); echoLogJSON($message);
echoLog('Receiving commodity-v2 message...'); echoLog('Receiving commodity-v3 message...');
} }
$authorised = false; $authorised = false;

View File

@ -5,23 +5,7 @@
* 'uploaderID' => 'abcdef0123456789', * 'uploaderID' => 'abcdef0123456789',
* 'softwareName' => 'My Awesome Market Uploader', * 'softwareName' => 'My Awesome Market Uploader',
* 'softwareVersion' => 'v3.14' * 'softwareVersion' => 'v3.14'
* )); * )); *
*
* $result = $eddn->publishCommodityV1(
* 'Eranin',
* 'Azeban Orbital',
* time(),
* array(
* "itemName" => "Gold",
* "buyPrice" => 1024,
* "supply" => 7,
* "stationStock" => "Low",
* "sellPrice" => 1138,
* "demand" => 42,
* "demandLevel" => "Med"
* )
* ); // return true;
*
* *
* $result = $eddn->publishCommodityV2( * $result = $eddn->publishCommodityV2(
* 'Eranin', * 'Eranin',
@ -55,19 +39,14 @@ class EDDN
private static $_debug = true; private static $_debug = true;
private static $_gateways = array( private static $_gateways = array(
'http://eddn-gateway.elite-markets.net:8080/upload/', 'https://eddn.edcd.io:8080/upload/',
'http://eddn-gateway.ed-td.space:8080/upload/'
); );
private static $_schemas = array( private static $_schemas = array(
'commodity-v1' => array( 'commodity-v3' => array(
'production' => 'http://schemas.elite-markets.net/eddn/commodity/1', 'production' => 'https://eddn.edcd.io/schemas/commodity/3',
'test' => 'http://schemas.elite-markets.net/eddn/commodity/1/test' 'test' => 'https://eddn.edcd.io/schemas/commodity/3/test',
), ),
'commodity-v2' => array(
'production' => 'http://schemas.elite-markets.net/eddn/commodity/2',
'test' => 'http://schemas.elite-markets.net/eddn/commodity/2/test'
)
); );
private $_uploaderID = null; private $_uploaderID = null;
@ -92,22 +71,7 @@ class EDDN
throw new Exception('Option "softwareVersion" is required.'); throw new Exception('Option "softwareVersion" is required.');
} }
public function publishCommodityV1($systemName, $stationName, $timestamp, array $commodity) public function publishCommodityV3($systemName, $stationName, $timestamp, array $commodities)
{
$schema = self::$_schemas['commodity-v1'][((self::$_debug === true) ? 'test' : 'production')];
$message = array();
$message['systemName'] = $systemName;
$message['stationName'] = $stationName;
$message['timestamp'] = date('c', $timestamp);
foreach($commodity AS $key => $value)
$message[$key] = $value;
return $this->_postToEDDN($schema, $message);
}
public function publishCommodityV2($systemName, $stationName, $timestamp, array $commodities)
{ {
$schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')]; $schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')];

View File

@ -116,13 +116,13 @@ def main():
# Handle commodity v1 # Handle commodity v1
if __json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/1' + ('/test' if (__debugEDDN == True) else ''): if __json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/1' + ('/test' if (__debugEDDN == True) else ''):
echoLogJSON(__message) echoLogJSON(__message)
echoLog('Receiving commodity-v1 message...') echoLog('Receiving commodity-v1 message...')
echoLog(' - Converting to v2...') echoLog(' - Converting to v3...')
__temp = {} __temp = {}
__temp['$schemaRef'] = 'http://schemas.elite-markets.net/eddn/commodity/2' + ('/test' if (__debugEDDN == True) else '') __temp['$schemaRef'] = 'https://eddn.edcd.io/schemas/commodity/3' + ('/test' if (__debugEDDN == True) else '')
__temp['header'] = __json['header'] __temp['header'] = __json['header']
__temp['message'] = {} __temp['message'] = {}
@ -157,11 +157,11 @@ def main():
__converted = True __converted = True
# Handle commodity v2 # Handle commodity v3
if __json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2' + ('/test' if (__debugEDDN == True) else ''): if __json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' + ('/test' if (__debugEDDN == True) else ''):
if __converted == False: if __converted == False:
echoLogJSON(__message) echoLogJSON(__message)
echoLog('Receiving commodity-v2 message...') echoLog('Receiving commodity-v3 message...')
__authorised = False __authorised = False
__excluded = False __excluded = False

View File

@ -127,13 +127,13 @@ def main():
# Handle commodity v1 # Handle commodity v1
if __json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/1' + ('/test' if (__debugEDDN == True) else ''): if __json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/1' + ('/test' if (__debugEDDN == True) else ''):
echoLogJSON(__message) echoLogJSON(__message)
echoLog('Receiving commodity-v1 message...') echoLog('Receiving commodity-v1 message...')
echoLog(' - Converting to v2...') echoLog(' - Converting to v3...')
__temp = {} __temp = {}
__temp['$schemaRef'] = 'http://schemas.elite-markets.net/eddn/commodity/2' + ('/test' if (__debugEDDN == True) else '') __temp['$schemaRef'] = 'https://eddn.edcd.io/schemas/commodity/3' + ('/test' if (__debugEDDN == True) else '')
__temp['header'] = __json['header'] __temp['header'] = __json['header']
__temp['message'] = {} __temp['message'] = {}
@ -168,11 +168,11 @@ def main():
__converted = True __converted = True
# Handle commodity v2 # Handle commodity v3
if __json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2' + ('/test' if (__debugEDDN == True) else ''): if __json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' + ('/test' if (__debugEDDN == True) else ''):
if __converted == False: if __converted == False:
echoLogJSON(__message) echoLogJSON(__message)
echoLog('Receiving commodity-v2 message...') echoLog('Receiving commodity-v3 message...')
__authorised = False __authorised = False
__excluded = False __excluded = False