public function testBuild()
 {
     // premium domain request should build us a PremiumDomain
     $data = (object) array('func' => 'premiumDomain', 'data' => (object) array('domain' => 'google.com', 'selected' => '.com;.net;.org', 'alldomains' => '.com;.net;.org'));
     $pd = RequestFactory::build('premiumDomain', 'array', $data);
     $this->assertTrue($pd instanceof opensrs\domains\lookup\PremiumDomain);
 }
Ejemplo n.º 2
0
 /**
  * Process an OpenSRS Request.
  * 
  * @param string $format input format (xml, json, array)
  * @param string $data   data 
  */
 public function process($format = '', $data = '')
 {
     if (empty($data)) {
         throw new Exception('OSRS Error - No data found.');
         return;
     }
     $dataArray = array();
     switch (strtolower($format)) {
         case 'array':
             $dataArray = $data;
             break;
         case 'json':
             $json = str_replace('\\"', '"', $data);
             //  Replace  \"  with " for JSON that comes from Javascript
             $dataArray = json_decode($json, true);
             break;
         case 'yaml':
             $dataArray = Spyc::YAMLLoad($data);
             break;
         default:
             $dataArray = $data;
     }
     // Convert associative array to object
     $dataObject = $this->array2object($dataArray);
     $classCall = null;
     $classCall = RequestFactory::build($dataObject->func, $format, $dataObject);
     return $classCall;
 }