Skip to content

Commit

Permalink
Added option to attach a custom license to an email. Code cleanup to …
Browse files Browse the repository at this point in the history
…better fit newer Magento and PHP 8 Standards
  • Loading branch information
TobiasLufinity committed Oct 13, 2022
1 parent 52b4a96 commit c453ccb
Show file tree
Hide file tree
Showing 33 changed files with 1,868 additions and 1,840 deletions.
4 changes: 2 additions & 2 deletions Api/CategoryRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function save(

/**
* Retrieve Category
* @param string $usageId
* @param string $categoryId
* @return \DevStone\UsageCalculator\Api\Data\CategoryInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getById($usageId);
public function getById($categoryId);

/**
* Retrieve Category matching the specified criteria.
Expand Down
52 changes: 52 additions & 0 deletions Api/Data/UsageCustomerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace DevStone\UsageCalculator\Api\Data;

interface UsageCustomerInterface
{

/**
* @return int
*/
public function getId();

/**
* @param int $entity_id
* @return UsageCustomerInterface
*/
public function setId(int $entity_id);

/**
* @return int
*/
public function getUsageId(): int;

/**
* @param int $usageId
* @return UsageCustomerInterface
*/
public function setUsageId(int $usageId): UsageCustomerInterface;

/**
* @return int
*/
public function getCustomerId(): int;

/**
* @param int $customerId
* @return UsageCustomerInterface
*/
public function setCustomerId(int $customerId): UsageCustomerInterface;
/**
* @return string
*/
public function getPendingCustomerEmail(): string;

/**
* @param string $pendingCustomerEmail
* @return UsageCustomerInterface
*/
public function setPendingCustomerEmail(string $pendingCustomerEmail): UsageCustomerInterface;
}
27 changes: 27 additions & 0 deletions Api/Data/UsageCustomerSearchResultsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace DevStone\UsageCalculator\Api\Data;

use Magento\Framework\Api\SearchResultsInterface;

interface UsageCustomerSearchResultsInterface extends SearchResultsInterface
{

/**
* Get UsageCustomer list.
* @return UsageCustomerInterface[]
*/
public function getItems();

/**
* Set entity_id list.
* @param UsageCustomerInterface[] $items
* @return $this
*/
public function setItems(array $items);
}
7 changes: 6 additions & 1 deletion Api/Data/UsageInterface.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?php

declare(strict_types=1);

namespace DevStone\UsageCalculator\Api\Data;

/**
* @method getName()
* @method getMaxUsage()
*/
interface UsageInterface
{
const NAME = 'name';
Expand All @@ -19,7 +24,7 @@ public function getId();
* @return \DevStone\UsageCalculator\Api\Data\UsageInterface
*/
public function setId($usageId);

/**
* Get list of product options
*
Expand Down
95 changes: 95 additions & 0 deletions Api/UsageCustomerRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace DevStone\UsageCalculator\Api;

use DevStone\UsageCalculator\Api\Data\UsageCustomerInterface;
use DevStone\UsageCalculator\Api\Data\UsageCustomerSearchResultsInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\SearchResultsInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;

interface UsageCustomerRepositoryInterface
{

/**
* Save UsageCustomer
* @param UsageCustomerInterface $usageCustomer
* @return UsageCustomerInterface
* @throws LocalizedException
*/
public function save(
UsageCustomerInterface $usageCustomer
): UsageCustomerInterface;

/**
* Retrieve UsageCustomer
* @param int $usageCustomerId
* @return UsageCustomerInterface
* @throws LocalizedException
*/
public function get(int $usageCustomerId): UsageCustomerInterface;

/**
* Retrieve UsageCustomer
* @param int $usageId
* @param int $customerId
* @return UsageCustomerInterface
* @throws LocalizedException
*/
public function getByUsageAndCustomer(int $usageId, int $customerId): ?UsageCustomerInterface;

/**
* Retrieve UsageCustomer
* @param int $usageId
* @param string $email
* @return UsageCustomerInterface
* @throws LocalizedException
*/
public function getByUsageAndEmail(int $usageId, string $email): ?UsageCustomerInterface;

/**
* Retrieve UsageCustomer matching the specified criteria.
* @param SearchCriteriaInterface $searchCriteria
* @return SearchResultsInterface
* @throws LocalizedException
*/
public function getList(
SearchCriteriaInterface $searchCriteria
): SearchResultsInterface;

/**
* Delete UsageCustomer
* @param UsageCustomerInterface $usageCustomer
* @return bool true on success
* @throws LocalizedException
*/
public function delete(
UsageCustomerInterface $usageCustomer
): bool;

/**
* Delete UsageCustomers
* @param SearchCriteriaInterface $searchCriteria
* @return bool true on success
* @throws LocalizedException
*/
public function deleteList(
SearchCriteriaInterface $searchCriteria
): bool;

/**
* Delete UsageCustomer by ID
* @param int $usageCustomerId
* @return bool true on success
* @throws NoSuchEntityException
* @throws LocalizedException
*/
public function deleteById(int $usageCustomerId): bool;
}

41 changes: 24 additions & 17 deletions Api/UsageRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,61 @@
namespace DevStone\UsageCalculator\Api;


use DevStone\UsageCalculator\Api\Data\UsageInterface;
use DevStone\UsageCalculator\Api\Data\UsageSearchResultsInterface;
use DevStone\UsageCalculator\Model\Usage;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;

interface UsageRepositoryInterface
{


/**
* Save Usage
* @param \DevStone\UsageCalculator\Api\Data\UsageInterface $usage
* @return \DevStone\UsageCalculator\Api\Data\UsageInterface
* @throws \Magento\Framework\Exception\LocalizedException
* @param UsageInterface $usage
* @return UsageInterface
* @throws LocalizedException
*/
public function save(
\DevStone\UsageCalculator\Api\Data\UsageInterface $usage
UsageInterface $usage
);

/**
* Retrieve Usage
* @param string $usageId
* @return \DevStone\UsageCalculator\Api\Data\UsageInterface
* @throws \Magento\Framework\Exception\LocalizedException
* @param int $usageId
* @return UsageInterface
* @throws LocalizedException
*/
public function getById($usageId);
public function getById(int $usageId): UsageInterface;

/**
* Retrieve Usage matching the specified criteria.
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \DevStone\UsageCalculator\Api\Data\UsageSearchResultsInterface
* @throws \Magento\Framework\Exception\LocalizedException
* @param SearchCriteriaInterface $searchCriteria
* @return UsageSearchResultsInterface
* @throws LocalizedException
*/
public function getList(
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
SearchCriteriaInterface $searchCriteria
);

/**
* Delete Usage
* @param \DevStone\UsageCalculator\Api\Data\UsageInterface $usage
* @param UsageInterface $usage
* @return bool true on success
* @throws \Magento\Framework\Exception\LocalizedException
* @throws LocalizedException
*/
public function delete(
\DevStone\UsageCalculator\Api\Data\UsageInterface $usage
UsageInterface $usage
);

/**
* Delete Usage by ID
* @param string $usageId
* @return bool true on success
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
* @throws NoSuchEntityException
* @throws LocalizedException
*/
public function deleteById($usageId);
}
Loading

0 comments on commit c453ccb

Please sign in to comment.