示例#1
0
 function testCallbackFieldsInvalidResponse()
 {
     $client = new Zipmark_Client('wrong_identifier', 'wrong_secret');
     $headerFile = loadFile('callback/headers_invalid.json');
     $bodyFile = loadFile('callback/body.json');
     // Headers should be an array
     $headers = json_decode($headerFile[0], true);
     // Body should be a JSON string
     $body = $bodyFile[0];
     $callback = new Zipmark_Callback($client, $headers, $body);
     $this->assertFalse($callback->isValid());
     $this->assertNull($callback->event());
     $this->assertNull($callback->objectType());
     $this->assertNull($callback->object());
 }
示例#2
0
 private function _parseBody()
 {
     $parsedBody = json_decode($this->_phpRequest['body'], true);
     if (is_array($parsedBody) && array_key_exists('callback', $parsedBody)) {
         $callback = $parsedBody['callback'];
         $this->_callbackFields['event'] = $callback['event'];
         $this->_callbackFields['type'] = Zipmark_Callback::decamelize($callback['object_type']);
         $objectArray = array($this->objectType() => $callback['object']);
         $this->_callbackFields['object'] = Zipmark_Resource::fromJson(json_encode($objectArray), $this->_client);
     } else {
         throw new Zipmark_Error("Body does not contain valid content.");
     }
 }