diff --git a/Apigee/ManagementAPI/Developer.php b/Apigee/ManagementAPI/Developer.php index 4c99a2b..c9b5ba5 100644 --- a/Apigee/ManagementAPI/Developer.php +++ b/Apigee/ManagementAPI/Developer.php @@ -369,7 +369,8 @@ public function setPageSize($size) */ public function __construct(OrgConfig $config) { - $this->init($config, '/o/' . rawurlencode($config->orgName) . '/developers'); + $this->organizationName = $config->orgName; + $this->init($config, '/o/' . rawurlencode($this->organizationName) . '/developers'); $this->blankValues(); $this->pageSize = self::MAX_ITEMS_PER_PAGE; } @@ -408,18 +409,21 @@ protected static function loadFromResponse(Developer &$developer, array $respons $developer->firstName = $response['firstName']; $developer->lastName = $response['lastName']; $developer->userName = $response['userName']; - $developer->organizationName = $response['organizationName']; $developer->status = $response['status']; $developer->attributes = array(); if (array_key_exists('attributes', $response) && is_array($response['attributes'])) { - foreach ($response['attributes'] as $attribute) { - $developer->attributes[$attribute['name']] = @$attribute['value']; + foreach ($response['attributes'] as $key => $attribute) { + if (is_array($attribute)) { + $developer->attributes[$attribute['name']] = array_key_exists('value', $attribute) ? $attribute['value'] : null; + } else { + $developer->attributes[$key]= $attribute; + } } } $developer->createdAt = $response['createdAt']; $developer->createdBy = $response['createdBy']; - $developer->modifiedAt = $response['lastModifiedAt']; - $developer->modifiedBy = $response['lastModifiedBy']; + $developer->modifiedAt = array_key_exists('lastModifiedAt', $response) ? $response['lastModifiedAt'] : $response['modifiedAt']; + $developer->modifiedBy = array_key_exists('lastModifiedBy', $response) ? $response['lastModifiedBy'] : $response['modifiedBy'];; if (array_key_exists('companies', $response)) { $developer->companies = $response['companies']; } else { @@ -467,6 +471,9 @@ public function validate($email = null) * previous email value. * * @throws \Apigee\Exceptions\ParameterException + * In case of an invalid email, firstName, lastName or userName parameter. + * @throws \Apigee\Exceptions\ResponseException + * If there was a response error other than 404. */ public function save($forceUpdate = false, $oldEmail = null) { @@ -699,7 +706,6 @@ public function blankValues() $this->firstName = null; $this->lastName = null; $this->userName = null; - $this->organizationName = null; $this->status = null; $this->attributes = array(); $this->createdAt = null; diff --git a/Apigee/Mint/BankDetail.php b/Apigee/Mint/BankDetail.php index 6d053e8..4cd82fb 100644 --- a/Apigee/Mint/BankDetail.php +++ b/Apigee/Mint/BankDetail.php @@ -145,7 +145,7 @@ public function loadFromRawData($data, $reset = false) } } - public function save($save_method) + public function save($save_method = 'auto') { if ($this->id == null) { $this->post(null, $this->__toString()); diff --git a/Apigee/Mint/Developer.php b/Apigee/Mint/Developer.php index d089eb4..98b7a07 100644 --- a/Apigee/Mint/Developer.php +++ b/Apigee/Mint/Developer.php @@ -137,6 +137,17 @@ public function __construct(OrgConfig $config) $this->initValues(); } + /** + * Upon unserialization re-initialize the object. + */ + public function __wakeup() + { + // Re-initialize the organization configuration. + $config = devconnect_default_org_config($this->config->orgName); + $base_url = '/mint/organizations/' . rawurlencode($config->orgName) . '/developers'; + $this->init($config, $base_url); + } + /** * {@inheritdoc} */