Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed Jan 9, 2019
1 parent 9185858 commit 6f2d3d0
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 62 deletions.
2 changes: 2 additions & 0 deletions Block/Adminhtml/LiquidFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public function __construct(StoreManagerInterface $storeManager)

/**
* @param $subject
*
* @return string
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function price($subject)
{
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/AbstractManageHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public function __construct(
HookFactory $hookFactory,
Registry $coreRegistry,
Context $context
)
{
){
$this->hookFactory = $hookFactory;
$this->coreRegistry = $coreRegistry;

Expand Down
3 changes: 2 additions & 1 deletion Controller/Adminhtml/AbstractManageLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ abstract class AbstractManageLogs extends Action

/**
* AbstractManageHooks constructor.
*
* @param HistoryFactory $historyFactory
* @param Registry $coreRegistry
* @param Context $context
Expand All @@ -60,7 +61,7 @@ public function __construct(
)
{
$this->historyFactory = $historyFactory;
$this->coreRegistry = $coreRegistry;
$this->coreRegistry = $coreRegistry;

parent::__construct($context);
}
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/Logs/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function __construct(
Registry $coreRegistry,
Context $context,
PageFactory $resultPageFactory
)
{
){
parent::__construct($historyFactory, $coreRegistry, $context);

$this->resultPageFactory = $resultPageFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/Logs/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class Index extends Action
public function __construct(
Context $context,
PageFactory $resultPageFactory
)
{
){
parent::__construct($context);

$this->resultPageFactory = $resultPageFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/Logs/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public function __construct(
Context $context,
LayoutFactory $resultLayoutFactory

)
{
){
parent::__construct($hookFactory, $coreRegistry, $context);

$this->resultLayoutFactory = $resultLayoutFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/Logs/Replay.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function __construct(
Context $context,
HookFactory $hookFactory,
Data $helperData
)
{
){
parent::__construct($historyFactory, $coreRegistry, $context);

$this->hookFactory = $hookFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function __construct(
Registry $coreRegistry,
Context $context,
PageFactory $resultPageFactory
)
{
){
parent::__construct($hookFactory, $coreRegistry, $context);

$this->resultPageFactory = $resultPageFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class Index extends Action
public function __construct(
Context $context,
PageFactory $resultPageFactory
)
{
){
parent::__construct($context);

$this->resultPageFactory = $resultPageFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/InlineEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function __construct(
Context $context,
JsonFactory $jsonFactory,
HookFactory $hookFactory
)
{
){
$this->jsonFactory = $jsonFactory;
$this->hookFactory = $hookFactory;

Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/MassDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function __construct(
Context $context,
Filter $filter,
CollectionFactory $collectionFactory
)
{
){
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;

Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/MassStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function __construct(
Context $context,
Filter $filter,
CollectionFactory $collectionFactory
)
{
){
parent::__construct($context);

$this->filter = $filter;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/NewAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class NewAction extends Action
public function __construct(
Context $context,
ForwardFactory $resultForwardFactory
)
{
){
parent::__construct($context);

$this->resultForwardFactory = $resultForwardFactory;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Adminhtml/ManageHooks/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public function __construct(
Registry $coreRegistry,
Context $context,
Data $helperData
)
{
){
parent::__construct($hookFactory, $coreRegistry, $context);

$this->helperData = $helperData;
Expand Down
3 changes: 3 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ public function getBasicAuthHeader($username, $password)
/**
* @param $item
* @param $hookType
*
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function sendObserver($item, $hookType)
{
Expand Down Expand Up @@ -363,6 +365,7 @@ public function sendMail($sendTo, $mes, $emailTemplate, $storeId)

/**
* @return int
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getStoreId()
{
Expand Down
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ This is really practical in stores with Sales and Customer Care departments whic

### Send leads/customer data to CRM or Email Marketing tools

![Imgur](https://i.imgur.com/SuRp9eA.png)

Webhook is a supportive tool to CRM or Email Marketing systems used in e-commerce businesses. The data of customers or orders or any related updates is necessary to be sent instantly to these systems. Then, the stores can appoint quickly sales actions accordingly.

![Imgur](https://i.imgur.com/SuRp9eA.png)


### Log requests and response

Status and error messages of hooks can be updated quickly via hook logs. Admin can quickly preview the response of Log ID easily.
Expand All @@ -93,15 +95,15 @@ Clean logs daily when the total reaches a specific number.
Resend replaced requests after fixing errors.


## 6. Full features list
## 6. Full feature list

### General Configuration
- Enable/ Disable the module
- Set time to send abandoned carts notice
- Send alert emails when errors occur
- Choose email template
- Set total number for logs
- Clean logs on a daily basis
- Clean logs on a daily basis

### Manage Hooks
- Set name for a new hook
Expand All @@ -124,10 +126,9 @@ Resend replaced requests after fixing errors.
### 7.1 How to configure

Login to the **Magento Admin**, choose `Store > Settings > Configuration > Mageplaza Extensions > Webhook`.

![Imgur](https://i.imgur.com/lb28XMh.png)

- **Enable**: Select `Yes` to enable the module and `No` to disable.
- **Enable**:Select `Yes` to enable the module and `No` to disable.
- **Abandoned Cart After (minutes)**: Set minutes for Abandoned Cart. Recommend period time: 1, 6, 10, 12, 24
- **Keep logs**: Automatically clean log if it reaches this number. It will be done daily.
- **Alert on Error**: Select “Yes” to send error notice via emails. To avoid sending to spam box, [SMTP](https://www.mageplaza.com/magento-2-smtp/) should be installed.
Expand All @@ -136,6 +137,7 @@ Login to the **Magento Admin**, choose `Store > Settings > Configuration > Magep
![Imgur](https://i.imgur.com/j4ZnDaI.png)

- **Send to**: Input email addresses to receive error notice.

- **Email Template**: Follow `Marketing > Email Templates > Add New Template` to create your wished templates. You can select Default Mageplaza Webhook Email Template(Default).


Expand Down Expand Up @@ -172,17 +174,17 @@ Select **Trigger events** (New Order, New Product, Update Product, Delete Produc

![Imgur](https://i.imgur.com/lhaspGa.gif)

- **Payload URL**:
- **Payload URL**:

- Select **Insert Variable** button to insert variable. For example: Method **POST**: https://domain.freshsales.io/api/leads, **GET**: https://domain.freshsales.io/leads/view/4000831345, or https://domain.freshsales.io/leads/view/4000831345new_shipment={inserted variable}
- Select **Insert Variable** button to insert variable. For example: Method **POST**: https://domain.freshsales.io/api/leads, **GET**: https://domain.freshsales.io/leads/view/4000831345 or https://domain.freshsales.io/leads/view/4000831345 new_shipment={inserted variable}

- Domain is the API account name. To sign up API account, follow the link: https://www.freshworks.com/freshsales-crm/.

- Domain is the API account name. To sign up API account, follow the link: https://www.freshworks.com/freshsales-crm/.
Find more about API [here](https://www.freshsales.io/api/#introduction).

- This is a required field, not allow leaving blank

- **Method** : Select method to send HTTP request. If leave this blank, the default method will be GET

- GET: get data from the server
- POST: create new object
- PUT: Update the object
Expand All @@ -191,17 +193,15 @@ Find more about API [here](https://www.freshsales.io/api/#introduction).
- CONNECT: Converts the requested connection into a transparent TCP / IP tunnel, usually to facilitate SSL encryption (HTTPS) through an unencrypted HTTP proxy.
- OPTIONS: Describe the options. An OPTIONS request should return data describing what other methods and operations the server supports at certain URLs.
- TRACE: Repeat the request so that customers can see any changes or additions (if any) that have been made by the intermediate servers.
- PATCH: Apply a modified part to an object.
- PATCH: Apply a modified part to an object.

- **Authentication**: Select the type of data access authentication you want from the server. When you submit a request, you typically have to include parameters to make sure the request has access and returns the data you want. You should leave this field blank to limit access.

![Imgur](https://i.imgur.com/C9mvIJi.png)

- **Basic**: Display 2 Username and Password fields. Fill in the information to authenticate access.

`Note`: In the process of being strictly enforced throughout the entire data cycle to SSL for security, authentication is transmitted over unsafe lines.

- **Digest**: Fill out some credentials below:

- **Basic**: Display 2 Username and Password fields. Fill in the information to authenticate access.
- **Note**: In the process of being strictly enforced throughout the entire data cycle to SSL for security, authentication is transmitted over unsafe lines.
- **Digest**: Fill out some credentials below:


![Imgur](https://i.imgur.com/TbH4AvX.png)
Expand All @@ -214,7 +214,7 @@ Find more about API [here](https://www.freshsales.io/api/#introduction).

![Imgur](https://i.imgur.com/CKSNQkS.png)

- **Body**: For methods like POST or PUT, you need to add content to the body section to send the request. Click `Insert Variable` to select the variable.
- **Body**: For methods like POST or PUT, you need to add content to the body section to send the request. Click `Insert Variable` to select the variable.

### 7.3 Hook Logs

Expand All @@ -226,6 +226,7 @@ This section will record Webhooks change logs such as Name, Status, Entity, Mess

#### View logs


Click view to view the log details

![Imgur](https://i.imgur.com/yCsaTIO.png)
Expand All @@ -237,6 +238,3 @@ You need to run the following command to install the library:
```
composer require liquid/liquid
```



2 changes: 1 addition & 1 deletion USER-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- User Guide: https://docs.mageplaza.com/webhook/index.html
- Product page: https://www.mageplaza.com/magento-2-webhook/
- FAQs: https://www.mageplaza.com/faqs/
- Get Support: https://mageplaza.freshdesk.com/ or [email protected]
- Get Support: https://www.mageplaza.com/contact.html or [email protected]
- Changelog: https://www.mageplaza.com/releases/webhook
- License agreement: https://www.mageplaza.com/LICENSE.txt

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "mageplaza/module-webhook",
"description": "Magento 2 Webhook Extension",
"require": {
"mageplaza/module-core": "^1.4.0"
"mageplaza/module-core": "^1.4.0",
"liquid/liquid": "^1.4.8"
},
"type": "magento2-module",
"version": "1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion etc/adminhtml/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Mageplaza_Webhook::webhook" title="Webhook" module="Mageplaza_Webhook" sortOrder="45" resource="Mageplaza_Webhook::webhook" parent="Mageplaza_Core::menu" dependsOnConfig="mp_webhook/general/enabled" dependsOnModule="Mageplaza_Webhook"/>
<add id="Mageplaza_Webhook::webhook" title="Webhook" module="Mageplaza_Webhook" sortOrder="46" resource="Mageplaza_Webhook::webhook" parent="Magento_Backend::system"/>
<add id="Mageplaza_Webhook::manage_hooks" title="Manage Hooks" module="Mageplaza_Webhook" sortOrder="20" action="mpwebhook/managehooks" resource="Mageplaza_Webhook::manage_hooks" parent="Mageplaza_Webhook::webhook"/>
<add id="Mageplaza_Webhook::logs" title="Logs" module="Mageplaza_Webhook" sortOrder="20" action="mpwebhook/logs" resource="Mageplaza_Webhook::logs" parent="Mageplaza_Webhook::webhook"/>
<add id="Mageplaza_Webhook::configuration" title="Configuration" module="Mageplaza_Webhook" sortOrder="1000" action="adminhtml/system_config/edit/section/mp_webhook" resource="Mageplaza_Webhook::configuration" parent="Mageplaza_Webhook::webhook"/>
</menu>
</config>
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<general>
<enabled>1</enabled>
<abandoned_time>10</abandoned_time>
<keep_log>10</keep_log>
</general>
</mp_webhook>
</default>
Expand Down
10 changes: 6 additions & 4 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ qop,qop
"Client Nonce","Client Nonce"
Opaque,Opaque
Header,Header
Content-type,Content-type
"Content Type","Content Type"
Body,Body
"Supports <a href=""https://shopify.github.io/liquid/"" target=""_blank"">Liquid template</a>","Supports <a href=""https://shopify.github.io/liquid/"" target=""_blank"">Liquid template</a>"
"General Information","General Information"
Expand Down Expand Up @@ -79,6 +79,8 @@ Words,Words
"Encode Url","Encode Url"
Price,Price
"If Empty","If Empty"
Success,Success
Error,Error
"Log ID","Log ID"
Entity,Entity
Response,Response
Expand Down Expand Up @@ -129,12 +131,12 @@ Delete,Delete
Webhook,Webhook
Logs,Logs
Enable,Enable
"Abandoned Cart After (minutes)","Abandoned Cart After (minutes)"
"Recommend period time: 1, 6, 10, 12, 24","Recommend period time: 1, 6, 10, 12, 24"
"Abandoned Cart After","Abandoned Cart After"
"Please specify value in hours. Recommend: 1, 6, 10, 12, 24","Please specify value in hours. Recommend: 1, 6, 10, 12, 24"
"Alert on Error","Alert on Error"
"To avoid going to spambox, you should install <a href=""https://www.mageplaza.com/magento-2-smtp/"" target=""_blank"">SMTP</a>","To avoid going to spambox, you should install <a href=""https://www.mageplaza.com/magento-2-smtp/"" target=""_blank"">SMTP</a>"
"Keep logs","Keep logs"
"Automatically clean log if it reachs this number. It will be done daily.","Automatically clean log if it reachs this number. It will be done daily."
"The number of logs will be kept in each hook. If it reaches this number, the old logs will be removed. If empty or zero, no limitation.","The number of logs will be kept in each hook. If it reaches this number, the old logs will be removed. If empty or zero, no limitation."
"Send To","Send To"
"Separated by comma (,)","Separated by comma (,)"
"Email Template","Email Template"
Expand Down
19 changes: 9 additions & 10 deletions view/adminhtml/templates/hook/body.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ $fieldClass .= ($addOn) ? ' with-addon' : '';
$fieldClass .= ($element->getRequired()) ? ' _required' : '';
$fieldClass .= ($note) ? ' with-note' : '';

$fieldAttributes = $fieldId . ' class="' . $fieldClass . '" '
. $block->getUiId('form-field', $element->getId());
$fieldAttributes = $fieldId . ' class="' . $fieldClass . '" ' . $block->getUiId('form-field', $element->getId());
$modifiersData = $block->getModifier() ? \Mageplaza\Webhook\Helper\Data::jsonEncode($block->getModifier()) : '{}';
?>

Expand Down Expand Up @@ -106,7 +105,7 @@ $modifiersData = $block->getModifier() ? \Mageplaza\Webhook\Helper\Data::jsonE
<a id="ox_variable_item-head" href="#ox_variable_item-link"
onclick="Fieldset.toggleCollapse('ox_variable_item'); return false;"><?= __('Item Attribute') ?></a>
</div>
<input id="ox_provider_item-state" type="hidden">
<input id="ox_variable_item-state" value="1" type="hidden">

<fieldset class="config admin__collapsible-block admin__scope-old" id="ox_variable_item">
<?php foreach ($attrCollection as $attr) : ?>
Expand All @@ -133,11 +132,11 @@ $modifiersData = $block->getModifier() ? \Mageplaza\Webhook\Helper\Data::jsonE
</script>
</div>
<script type="text/x-magento-init">
{
"*": {
"Mageplaza_Webhook/js/hook/initActionsTab":{
"modifiersData": <?= $modifiersData ?>
}
}
}
{
"*": {
"Mageplaza_Webhook/js/hook/initActionsTab":{
"modifiersData": <?= $modifiersData ?>
}
}
}
</script>

0 comments on commit 6f2d3d0

Please sign in to comment.