mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-18 07:52:59 +03:00
Update examples
This commit is contained in:
parent
a733ff22ed
commit
eb137fbcba
@ -125,14 +125,14 @@ while (true)
|
||||
$converted = false;
|
||||
|
||||
// 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);
|
||||
echoLog('Receiving commodity-v1 message...');
|
||||
echoLog(' - Converting to v2...');
|
||||
|
||||
$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['message'] = array();
|
||||
@ -169,13 +169,13 @@ while (true)
|
||||
}
|
||||
|
||||
|
||||
// Handle commodity v2
|
||||
if($json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2' . (($debugEDDN === true) ? '/test' : ''))
|
||||
// Handle commodity v3
|
||||
if($json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' . (($debugEDDN === true) ? '/test' : ''))
|
||||
{
|
||||
if($converted === false)
|
||||
{
|
||||
echoLogJSON($message);
|
||||
echoLog('Receiving commodity-v2 message...');
|
||||
echoLog('Receiving commodity-v3 message...');
|
||||
}
|
||||
|
||||
$authorised = false;
|
||||
|
@ -5,23 +5,7 @@
|
||||
* 'uploaderID' => 'abcdef0123456789',
|
||||
* 'softwareName' => 'My Awesome Market Uploader',
|
||||
* '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(
|
||||
* 'Eranin',
|
||||
@ -55,19 +39,14 @@ class EDDN
|
||||
private static $_debug = true;
|
||||
|
||||
private static $_gateways = array(
|
||||
'http://eddn-gateway.elite-markets.net:8080/upload/',
|
||||
'http://eddn-gateway.ed-td.space:8080/upload/'
|
||||
'https://eddn.edcd.io:8080/upload/',
|
||||
);
|
||||
|
||||
private static $_schemas = array(
|
||||
'commodity-v1' => array(
|
||||
'production' => 'http://schemas.elite-markets.net/eddn/commodity/1',
|
||||
'test' => 'http://schemas.elite-markets.net/eddn/commodity/1/test'
|
||||
'commodity-v3' => array(
|
||||
'production' => 'https://eddn.edcd.io/schemas/commodity/3',
|
||||
'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;
|
||||
@ -92,22 +71,7 @@ class EDDN
|
||||
throw new Exception('Option "softwareVersion" is required.');
|
||||
}
|
||||
|
||||
public function publishCommodityV1($systemName, $stationName, $timestamp, array $commodity)
|
||||
{
|
||||
$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)
|
||||
public function publishCommodityV3($systemName, $stationName, $timestamp, array $commodities)
|
||||
{
|
||||
$schema = self::$_schemas['commodity-v2'][((self::$_debug === true) ? 'test' : 'production')];
|
||||
|
||||
|
@ -116,13 +116,13 @@ def main():
|
||||
|
||||
|
||||
# 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)
|
||||
echoLog('Receiving commodity-v1 message...')
|
||||
echoLog(' - Converting to v2...')
|
||||
echoLog(' - Converting to v3...')
|
||||
|
||||
__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['message'] = {}
|
||||
@ -157,11 +157,11 @@ def main():
|
||||
|
||||
__converted = True
|
||||
|
||||
# Handle commodity v2
|
||||
if __json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2' + ('/test' if (__debugEDDN == True) else ''):
|
||||
# Handle commodity v3
|
||||
if __json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' + ('/test' if (__debugEDDN == True) else ''):
|
||||
if __converted == False:
|
||||
echoLogJSON(__message)
|
||||
echoLog('Receiving commodity-v2 message...')
|
||||
echoLog('Receiving commodity-v3 message...')
|
||||
|
||||
__authorised = False
|
||||
__excluded = False
|
||||
|
@ -127,13 +127,13 @@ def main():
|
||||
|
||||
|
||||
# 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)
|
||||
echoLog('Receiving commodity-v1 message...')
|
||||
echoLog(' - Converting to v2...')
|
||||
echoLog(' - Converting to v3...')
|
||||
|
||||
__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['message'] = {}
|
||||
@ -168,11 +168,11 @@ def main():
|
||||
|
||||
__converted = True
|
||||
|
||||
# Handle commodity v2
|
||||
if __json['$schemaRef'] == 'http://schemas.elite-markets.net/eddn/commodity/2' + ('/test' if (__debugEDDN == True) else ''):
|
||||
# Handle commodity v3
|
||||
if __json['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' + ('/test' if (__debugEDDN == True) else ''):
|
||||
if __converted == False:
|
||||
echoLogJSON(__message)
|
||||
echoLog('Receiving commodity-v2 message...')
|
||||
echoLog('Receiving commodity-v3 message...')
|
||||
|
||||
__authorised = False
|
||||
__excluded = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user