Skip to content

Commit 253b5d3

Browse files
Merge pull request #23 from magmodules/release/1.6.0
Release/1.6.0
2 parents 331200c + cbf82d6 commit 253b5d3

File tree

7 files changed

+105
-12
lines changed

7 files changed

+105
-12
lines changed

Api/WebApi/RepositoryInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
interface RepositoryInterface
1616
{
1717

18+
/**
19+
* @return mixed
20+
*/
21+
public function getSettings(): array;
22+
1823
/**
1924
* @param int $entityId
2025
* @return mixed

Model/WebApi/Repository.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magmodules\Reloadify\Service\WebApi\Product;
1919
use Magmodules\Reloadify\Service\WebApi\Profiles;
2020
use Magmodules\Reloadify\Service\WebApi\Review;
21+
use Magmodules\Reloadify\Service\WebApi\Settings;
2122
use Magmodules\Reloadify\Service\WebApi\Variants;
2223

2324
/**
@@ -58,6 +59,10 @@ class Repository implements RepositoryInterface
5859
* @var Variants
5960
*/
6061
private $variants;
62+
/**
63+
* @var Settings
64+
*/
65+
private $settings;
6166
/**
6267
* @var RequestInterface
6368
*/
@@ -70,16 +75,17 @@ class Repository implements RepositoryInterface
7075
/**
7176
* Repository constructor.
7277
*
73-
* @param Category $category
74-
* @param Product $product
75-
* @param Language $language
76-
* @param Profiles $profiles
77-
* @param Order $order
78-
* @param Cart $cart
79-
* @param Review $review
80-
* @param Variants $variants
78+
* @param Category $category
79+
* @param Product $product
80+
* @param Language $language
81+
* @param Profiles $profiles
82+
* @param Order $order
83+
* @param Cart $cart
84+
* @param Review $review
85+
* @param Variants $variants
86+
* @param Settings $settings
8187
* @param RequestInterface $requestInterface
82-
* @param Json $json
88+
* @param Json $json
8389
*/
8490
public function __construct(
8591
Category $category,
@@ -90,6 +96,7 @@ public function __construct(
9096
Cart $cart,
9197
Review $review,
9298
Variants $variants,
99+
Settings $settings,
93100
RequestInterface $requestInterface,
94101
Json $json
95102
) {
@@ -101,10 +108,19 @@ public function __construct(
101108
$this->cart = $cart;
102109
$this->review = $review;
103110
$this->variants = $variants;
111+
$this->settings = $settings;
104112
$this->request = $requestInterface;
105113
$this->json = $json;
106114
}
107115

116+
/**
117+
* @inheritDoc
118+
*/
119+
public function getSettings(): array
120+
{
121+
return $this->settings->execute();
122+
}
123+
108124
/**
109125
* @inheritDoc
110126
*/

Service/WebApi/Profiles.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Exception\LocalizedException;
1717
use Magento\Newsletter\Model\Subscriber;
1818
use Magento\Store\Model\StoreManagerInterface;
19+
use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory as SubscriberCollection;
1920

2021
/**
2122
* Profiles web API service class
@@ -56,6 +57,8 @@ class Profiles
5657
*/
5758
private $addressRepository;
5859

60+
private $subscriberCollection;
61+
5962
/**
6063
* Profiles constructor.
6164
*
@@ -72,14 +75,16 @@ public function __construct(
7275
CustomerRepositoryInterface $customerRepository,
7376
SearchCriteriaBuilder $searchCriteriaBuilder,
7477
CustomerResource $customerResource,
75-
AddressRepository $addressRepository
78+
AddressRepository $addressRepository,
79+
SubscriberCollection $subscriberCollection
7680
) {
7781
$this->subscriber = $subscriber;
7882
$this->storeManager = $storeManager;
7983
$this->customerRepository = $customerRepository;
8084
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
8185
$this->customerResource = $customerResource;
8286
$this->addressRepository = $addressRepository;
87+
$this->subscriberCollection = $subscriberCollection;
8388
}
8489

8590
/**
@@ -97,6 +102,9 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
97102
$mainData = [
98103
"id" => $customer->getId(),
99104
"email" => $customer->getEmail(),
105+
"first_name" => $customer->getFirstname(),
106+
"middle_name" => $customer->getMiddlename(),
107+
"last_name" => $customer->getLastname(),
100108
"gender" => $this->getGender($customer),
101109
"active" => true,
102110
"subscribed_to_newsletter" => $this->isSubscribed($customer),
@@ -121,6 +129,17 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
121129

122130
$data[] = $mainData;
123131
}
132+
133+
$subscribers = $this->subscriberCollection->create()
134+
->addFieldToFilter('customer_id', ['eq' => 0]);
135+
foreach ($subscribers as $subscriber) {
136+
$data[] = [
137+
'id' => null,
138+
'email' => $subscriber->getSubscriberEmail(),
139+
'subscribed_to_newsletter' => $subscriber->getSubscriberStatus()
140+
];
141+
}
142+
124143
return $data;
125144
}
126145

Service/WebApi/Settings.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magmodules\Reloadify\Service\WebApi;
9+
10+
use Magmodules\Reloadify\Api\Config\RepositoryInterface as ConfigRepository;
11+
12+
/**
13+
* Settings web API service class
14+
*/
15+
class Settings
16+
{
17+
18+
/**
19+
* @var ConfigRepository
20+
*/
21+
private $configRepository;
22+
23+
/**
24+
* @param ConfigRepository $configRepository
25+
*/
26+
public function __construct(
27+
ConfigRepository $configRepository
28+
) {
29+
$this->configRepository = $configRepository;
30+
}
31+
32+
/**
33+
* @return array
34+
*/
35+
public function execute(): array
36+
{
37+
return [
38+
[
39+
"enabled" => $this->configRepository->isEnabled(),
40+
"extension_version" => $this->configRepository->getExtensionVersion(),
41+
"magento_version" => $this->configRepository->getMagentoVersion(),
42+
]
43+
];
44+
}
45+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magmodules/magento2-reloadify",
33
"description": "Reloadify extension for Magento 2",
44
"type": "magento2-module",
5-
"version": "1.5.8",
5+
"version": "1.6.0",
66
"license": [
77
"BSD-2-Clause"
88
],

etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<default>
1111
<magmodules_reloadify>
1212
<general>
13-
<version>v1.5.8</version>
13+
<version>v1.6.0</version>
1414
<enable>0</enable>
1515
<debug>0</debug>
1616
</general>

etc/webapi.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
1010

11+
<!-- Version Endpoints -->
12+
<route url="/V1/reloadify/settings" method="GET">
13+
<service class="Magmodules\Reloadify\Api\WebApi\RepositoryInterface" method="getSettings"/>
14+
<resources>
15+
<resource ref="Magmodules_Reloadify::webapi"/>
16+
</resources>
17+
</route>
18+
1119
<!-- Language Endpoints -->
1220
<route url="/V1/reloadify/languages" method="GET">
1321
<service class="Magmodules\Reloadify\Api\WebApi\RepositoryInterface" method="getLanguages"/>

0 commit comments

Comments
 (0)