Skip to content

Commit 8d18fc9

Browse files
committed
update1.0.2
1 parent 2a460b8 commit 8d18fc9

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
/**
4+
* Landofcoder
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Landofcoder.com license that is
9+
* available through the world-wide-web at this URL:
10+
* https://landofcoder.com/terms
11+
*
12+
* DISCLAIMER
13+
*
14+
* Do not edit or add to this file if you wish to upgrade this extension to newer
15+
* version in the future.
16+
*
17+
* @category Landofcoder
18+
* @package Lof_SellerMessageGraphQl
19+
* @copyright Copyright (c) 2021 Landofcoder (https://www.landofcoder.com/)
20+
* @license https://landofcoder.com/terms
21+
*/
22+
23+
declare(strict_types=1);
24+
25+
namespace Lof\MarketplaceGraphQl\Model\Resolver\Customer;
26+
27+
use Magento\Framework\GraphQl\Config\Element\Field;
28+
use Magento\Framework\GraphQl\Query\ResolverInterface;
29+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
30+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
31+
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
32+
use Lof\MarketPlace\Api\CustomerMessageRepositoryInterface;
33+
34+
class DeleteMessage implements ResolverInterface
35+
{
36+
/**
37+
* @var CustomerMessageRepositoryInterface
38+
*/
39+
private $customerMessageRepository;
40+
41+
/**
42+
* @param CustomerMessageRepositoryInterface $customerMessageRepository
43+
*/
44+
public function __construct(
45+
CustomerMessageRepositoryInterface $customerMessageRepository
46+
) {
47+
$this->customerMessageRepository = $customerMessageRepository;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function resolve(
54+
Field $field,
55+
$context,
56+
ResolveInfo $info,
57+
array $value = null,
58+
array $args = null
59+
) {
60+
if (!$context->getExtensionAttributes()->getIsCustomer()) {
61+
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
62+
}
63+
if (!($args['message_id']) || !isset($args['message_id'])) {
64+
throw new GraphQlInputException(__('"message_id" value should be specified'));
65+
}
66+
$data = $this->customerMessageRepository->deleteMessage($context->getUserId(), (int)$args['message_id']);
67+
68+
return [
69+
"code" => $data ? 0 : 1,
70+
"message" => $data ? "The message was delete successfully!" : "Error when delete the message."
71+
];
72+
}
73+
}

etc/schema.graphqls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ type Mutation {
125125

126126
customerReplyMessage(input: ReplyMessageInput!): SellerMessageDetail @resolver(class:"\\Lof\\MarketplaceGraphQl\\Model\\Resolver\\Customer\\ReplyMessage") @doc(description: "Customer reply Messaage")
127127

128+
customerDeleteMessage(message_id: Int!): MarketplaceOuput @resolver(class:"\\Lof\\MarketplaceGraphQl\\Model\\Resolver\\Customer\\DeleteMessage") @doc(description: "Customer delete Messaage by id")
129+
128130
sellerReplyMessage(input: SellerReplyMessageInput!): SellerMessageDetail @resolver(class:"\\Lof\\MarketplaceGraphQl\\Model\\Resolver\\Seller\\ReplyMessage") @doc(description: "Seller reply Messaage")
129131
}
130132

0 commit comments

Comments
 (0)