Skip to content

Commit

Permalink
Added runtimeType and monetizationConfig property to check monetizati…
Browse files Browse the repository at this point in the history
…on status in Apigee X (#145)
  • Loading branch information
phdhiren authored May 18, 2021
1 parent 7edb43c commit 906b132
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 4 deletions.
30 changes: 27 additions & 3 deletions src/Api/Management/Entity/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Apigee\Edge\Entity\Property\EnvironmentsPropertyAwareTrait;
use Apigee\Edge\Entity\Property\NamePropertyAwareTrait;
use Apigee\Edge\Entity\Property\PropertiesPropertyAwareTrait;
use Apigee\Edge\Entity\Property\RuntimeTypeAwareTrait;
use Apigee\Edge\Structure\AddonsConfig;
use Apigee\Edge\Structure\PropertiesProperty;

/**
Expand All @@ -35,6 +37,7 @@ class Organization extends Entity implements OrganizationInterface
use CommonEntityPropertiesAwareTrait;
use EnvironmentsPropertyAwareTrait;
use NamePropertyAwareTrait;
use RuntimeTypeAwareTrait;
use PropertiesPropertyAwareTrait;

protected const TYPES = [
Expand All @@ -45,6 +48,11 @@ class Organization extends Entity implements OrganizationInterface
/** @var string */
protected $type;

/**
* @var \Apigee\Edge\Structure\AddonsConfig|null
*/
protected $addonsConfig = null;

/**
* Organization constructor.
*
Expand All @@ -59,15 +67,15 @@ public function __construct(array $values = [])
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getType(): ?string
{
return $this->type;
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function setType(string $type): void
{
Expand All @@ -78,10 +86,26 @@ public function setType(string $type): void
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getTypes(): array
{
return self::TYPES;
}

/**
* {@inheritdoc}
*/
public function getAddonsConfig(): ?AddonsConfig
{
return $this->addonsConfig;
}

/**
* {@inheritdoc}
*/
public function setAddonsConfig(AddonsConfig $addonsConfig): void
{
$this->addonsConfig = $addonsConfig;
}
}
15 changes: 14 additions & 1 deletion src/Api/Management/Entity/OrganizationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Apigee\Edge\Entity\Property\EnvironmentsPropertyInterface;
use Apigee\Edge\Entity\Property\NamePropertyInterface;
use Apigee\Edge\Entity\Property\PropertiesPropertyInterface;
use Apigee\Edge\Entity\Property\RuntimeTypeInterface;
use Apigee\Edge\Structure\AddonsConfig;

/**
* Interface OrganizationInterface.
Expand All @@ -34,7 +36,8 @@ interface OrganizationInterface extends
DisplayNamePropertyInterface,
EnvironmentsPropertyInterface,
NamePropertyInterface,
PropertiesPropertyInterface
PropertiesPropertyInterface,
RuntimeTypeInterface
{
/**
* @return string|null
Expand All @@ -54,4 +57,14 @@ public function setType(string $type): void;
* @return array
*/
public function getTypes(): array;

/**
* @return \Apigee\Edge\Structure\AddonsConfig|null
*/
public function getAddonsConfig(): ?AddonsConfig;

/**
* @param \Apigee\Edge\Structure\AddonsConfig $addonsConfig
*/
public function setAddonsConfig(AddonsConfig $addonsConfig): void;
}
46 changes: 46 additions & 0 deletions src/Entity/Property/RuntimeTypeAwareTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Apigee\Edge\Entity\Property;

/**
* Trait RuntimeTypeAwareTrait.
*
* @see \Apigee\Edge\Entity\Property\RuntimeTypeInterface
*/
trait RuntimeTypeAwareTrait
{
/** @var string|null */
protected $runtimeType;

/**
* {@inheritdoc}
*/
public function getRuntimeType(): ?string
{
return $this->runtimeType;
}

/**
* {@inheritdoc}
*/
public function setRuntimeType(string $runtimeType): void
{
$this->runtimeType = $runtimeType;
}
}
35 changes: 35 additions & 0 deletions src/Entity/Property/RuntimeTypeInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Apigee\Edge\Entity\Property;

/**
* Interface RuntimeTypeInterface.
*/
interface RuntimeTypeInterface
{
/**
* @return string
*/
public function getRuntimeType(): ?string;

/**
* @param string $runtimeType
*/
public function setRuntimeType(string $runtimeType): void;
}
44 changes: 44 additions & 0 deletions src/Structure/AddonsConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Apigee\Edge\Structure;

/**
* Class AddonsConfig.
*/
final class AddonsConfig extends BaseObject
{
/** @var \Apigee\Edge\Structure\MonetizationConfig */
protected $monetizationConfig;

/**
* {@inheritdoc}
*/
public function getMonetizationConfig(): ?MonetizationConfig
{
return $this->monetizationConfig;
}

/**
* {@inheritdoc}
*/
public function setMonetizationConfig(MonetizationConfig $monetizationConfig): void
{
$this->monetizationConfig = $monetizationConfig;
}
}
44 changes: 44 additions & 0 deletions src/Structure/MonetizationConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Apigee\Edge\Structure;

/**
* Class MonetizationConfig.
*/
final class MonetizationConfig extends BaseObject
{
/** @var bool */
protected $enabled;

/**
* {@inheritdoc}
*/
public function getEnabled(): ?bool
{
return $this->enabled;
}

/**
* {@inheritdoc}
*/
public function setEnabled(bool $enabled): void
{
$this->enabled = $enabled;
}
}

3 comments on commit 906b132

@mxr576
Copy link
Contributor

@mxr576 mxr576 commented on 906b132 May 18, 2021

Choose a reason for hiding this comment

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

@phdhiren @cnovak I see that newly added ApigeeX related codes do not have test coverage therefore they reduce the accumulated test coverage of this library. Can we start requiring test coverage for every new change before they get merged?

@raakesh-blokhra
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @mxr576, hope all is well with you.
Yes, as Chris mentioned on the other issue yesterday, we're going to add test coverage for the existing code, and make it a practice to add test cases for code changes along with submitted PRs going forward. Thank you for your positive feedback all along.

@mxr576
Copy link
Contributor

@mxr576 mxr576 commented on 906b132 May 19, 2021

Choose a reason for hiding this comment

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

Hi,
Yes, I know that was for the Apigee Edge module and this the PHP API client which had much better test coverage even in the early days, that is the reason why I try to call attention to this. It is much easier to test the code in PHP API client than a Drupal module.

Thanks for the quick reply, I hope you are well too.

Please sign in to comment.