Tutorial Extension  1.0.0
SellerDeck Extensions - Tutorial Extension
Public Member Functions | List of all members
CSDApiSoapJobs Class Reference

Public Member Functions

 __construct ($oSyncService=null, $sApiKey="")
 
 CommonCommand ($sApi, $sType, $aParameters=[], $sMode= '')
 
 ConfigurationReload ()
 
 BulkStockUpdate ($aProducts=[])
 
 BulkRefreshOrders ($aOrders=[])
 
 CommonLockAndUnlock ($sReference, $vItemOrGroup, $sLockOrUnlock="lock")
 
 ProductLockAndUnlock ($sProductReference, $sLockOrUnlock="lock")
 
 Lock ($sOrderNumber)
 
 Unlock ($sOrderNumber)
 

Detailed Description

Definition at line 14 of file CSDApiSoapJobs.php.

Constructor & Destructor Documentation

__construct (   $oSyncService = null,
  $sApiKey = "" 
)

__construct - Object constructor method

Initializes the member variables

public

Parameters
SyncService$oSyncServiceSync Service Object
Returns
void

Definition at line 36 of file CSDApiSoapJobs.php.

37  {
38  $this->m_sApiKey = $sApiKey;
39  $this->m_oSyncService = new CSDApiSoapClient($oSyncService, true);
40  }

Member Function Documentation

BulkRefreshOrders (   $aOrders = [])

BulkRefreshOrders - Bulk Refresh Orders

public

Parameters
array$aOrdersOrder list
Returns
string XML

Definition at line 126 of file CSDApiSoapJobs.php.

127  {
128  $aParameters = [];
129  foreach ($aOrders as $sOrderNumber)
130  {
131  $aParameters['order'][] = ['reference' => $sOrderNumber];
132  }
133  return $this->CommonCommand('order', 'display', $aParameters);
134  }
CommonCommand($sApi, $sType, $aParameters=[], $sMode= '')
BulkStockUpdate (   $aProducts = [])

BulkStockUpdate - Bulk Stock Update

public

Parameters
array$aProductsProduct list
Returns
string XML

Definition at line 97 of file CSDApiSoapJobs.php.

98  {
99  $aParameters = [];
100  foreach ($aProducts as $aProduct)
101  {
102  $aParameters['product'][] = [
103  'mode' => 'relative',
104  'prodref' => $aProduct['sProductReference'],
105  'stocktoupdate' => $aProduct['nQuantityOrdered'],
106  ];
107  if (!empty($aProduct['sPermutation']))
108  {
109  $aParameters['product'][] = [
110  'mode' => 'relative',
111  'prodref' => $aProduct['sPermutation'],
112  'stocktoupdate' => $aProduct['nQuantityOrdered'],
113  ];
114  }
115  }
116  return $this->CommonCommand('stock', 'update', $aParameters);
117  }
CommonCommand($sApi, $sType, $aParameters=[], $sMode= '')
CommonCommand (   $sApi,
  $sType,
  $aParameters = [],
  $sMode = '' 
)

CommonCommand - Common part of API calls

public

Parameters
string$sApiAPI
string$sTypeType
string$sApiKeyAPI Key
array$aParametersParameters
string$sModeMode: single/all
Returns
string XML

Definition at line 53 of file CSDApiSoapJobs.php.

54  {
55  $aRequest = [
56  'api' => $sApi,
57  'apikey' => $this->m_sApiKey,
58  'command' =>
59  [
60  'type' => $sType,
61  ],
62  ];
63  if (!empty($sMode))
64  {
65  $aRequest['command']['mode'] = $sMode;
66  }
67  if (!empty($aParameters))
68  {
69  $aRequest['command']['parameters'] = $aParameters;
70  }
71  $sXML = Helper\Array2XML::createXML('request', $aRequest, ['version' => "1"])->saveXML();
72  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addDebug($sXML);
73  $oReturnValue = $this->m_oSyncService->InvokeApi($sXML);
74  $aXML = Helper\XML2Array::createArray($oReturnValue);
75  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addDebug(print_r($oReturnValue, true));
76  return $aXML;
77  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
static & createXML($node_name, $arr=array(), $namespace=null)
Definition: Array2XML.php:62
static & createArray($input_xml)
Definition: XML2Array.php:49
CommonLockAndUnlock (   $sReference,
  $vItemOrGroup,
  $sLockOrUnlock = "lock" 
)

CommonLockAndUnlock - Common part of Lock and Unlock API calls

public

Parameters
string$sReferenceProduct Reference
array | string$vItemOrGroupItem definition
string$sLockOrUnlockAction: 'lock' or 'unlock'
Returns
string XML

Definition at line 145 of file CSDApiSoapJobs.php.

146  {
147  if (is_array($vItemOrGroup))
148  {
149  $aParameters = ['item' => $vItemOrGroup];
150  $sReference = arr_get($vItemOrGroup, 'reference', $sReference);
151  }
152  else
153  {
154  $aParameters['item']['group'] = $vItemOrGroup;
155  }
156  if ("unlock" == $sLockOrUnlock)
157  {
158  $aParameters['item']['editaction'] = 'claimed';
159  }
160  $aParameters['item']['reference'] = $sReference;
161  return $this->CommonCommand('sync', $sLockOrUnlock, $aParameters, 'single');
162  }
CommonCommand($sApi, $sType, $aParameters=[], $sMode= '')
ConfigurationReload ( )

ConfigurationReload - Configuration Reload API call

public

Returns
string XML

Definition at line 85 of file CSDApiSoapJobs.php.

86  {
87  return $this->CommonCommand('sdd', 'sdereloadconfig');
88  }
CommonCommand($sApi, $sType, $aParameters=[], $sMode= '')
Lock (   $sOrderNumber)

Lock - Locking an item in EC

public

Parameters
string$sOrderNumberOrder Number
Returns
string XML

Definition at line 201 of file CSDApiSoapJobs.php.

202  {
203  return $this->CommonOrderLockAndUnlock($sOrderNumber, "lock");
204  }
ProductLockAndUnlock (   $sProductReference,
  $sLockOrUnlock = "lock" 
)

ProductLockAndUnlock - Common part of Lock and Unlock API calls

public

Parameters
string$sProductReferenceProduct Reference
string$sLockOrUnlockAction: 'lock' or 'unlock'
Returns
string XML

Definition at line 172 of file CSDApiSoapJobs.php.

173  {
174  $aItem = [
175  'group' => 'content',
176  'content' => 'product',
177  ];
178  return $this->CommonLockAndUnlock($sProductReference, $aItem, $sLockOrUnlock);
179  }
CommonLockAndUnlock($sReference, $vItemOrGroup, $sLockOrUnlock="lock")
Unlock (   $sOrderNumber)

Unlock - Unlocking an item in EC

public

Parameters
string$sOrderNumberOrder Number
Returns
string XML

Definition at line 213 of file CSDApiSoapJobs.php.

214  {
215  return $this->CommonOrderLockAndUnlock($sOrderNumber, "unlock");
216  }

The documentation for this class was generated from the following file: