Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Apigee/ManagementAPI/Developer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which circumstances we get back "modifiedAt" instead of "lastModifiedAt"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's different on the object and on the response... I had to make sure it is compatible.

$developer->modifiedBy = array_key_exists('lastModifiedBy', $response) ? $response['lastModifiedBy'] : $response['modifiedBy'];;
if (array_key_exists('companies', $response)) {
$developer->companies = $response['companies'];
} else {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Apigee/Mint/BankDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
11 changes: 11 additions & 0 deletions Apigee/Mint/Developer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand Down