-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Paazl/1.6.0
1.6.0
- Loading branch information
Showing
20 changed files
with
344 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Paazl\CheckoutWidget\Api\Webapi; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Paazl\CheckoutWidget\Api\Data\CheckQuoteResultInterface; | ||
|
||
/** | ||
* Interface CheckShippingOptionInterface | ||
*/ | ||
interface CheckShippingOptionInterface | ||
{ | ||
/** | ||
* @param string $cartId | ||
* @return CheckQuoteResultInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function get($cartId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Paazl\CheckoutWidget\Api\Webapi; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Paazl\CheckoutWidget\Api\Data\CheckQuoteResultInterface; | ||
|
||
/** | ||
* Interface CheckShippingOptionInterface | ||
*/ | ||
interface GuestCheckShippingOptionInterface | ||
{ | ||
/** | ||
* @param int $cartId | ||
* @return CheckQuoteResultInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function get($cartId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
/** | ||
* Copyright © 2019 Paazl. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Paazl\CheckoutWidget\Model\Api; | ||
|
||
use Exception; | ||
use Magento\Framework\HTTP\Client\Curl; | ||
|
||
/** | ||
* Class CurlExtra | ||
* | ||
* Provide PUT and DEL methods | ||
*/ | ||
class CurlExtra extends Curl | ||
{ | ||
|
||
/** | ||
* Make PUT request using curl | ||
* Magento has no built in support for 'put' | ||
* | ||
* @param string $uri | ||
* @param array|string $params | ||
* @return void | ||
* | ||
* @throws Exception | ||
*/ | ||
public function put($uri, $params) | ||
{ | ||
$this->makePutRequest($uri, $params); | ||
} | ||
|
||
/** | ||
* Make DEL request using curl | ||
* Magento has no built in support for 'delete' | ||
* | ||
* @param string $uri | ||
* | ||
* @return void | ||
*/ | ||
public function del($uri) | ||
{ | ||
$this->makeRequest("DELETE", $uri); | ||
} | ||
|
||
/** | ||
* @param string $uri | ||
* @param string|array $params | ||
* @throws Exception | ||
*/ | ||
protected function makePutRequest($uri, $params) | ||
{ | ||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
$this->_ch = curl_init(); | ||
$this->curlOption(CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP | CURLPROTO_FTPS); | ||
$this->curlOption(CURLOPT_URL, $uri); | ||
$this->curlOption(CURLOPT_POSTFIELDS, is_array($params) ? http_build_query($params) : $params); | ||
$this->curlOption(CURLOPT_CUSTOMREQUEST, 'PUT'); | ||
$this->curlOption(CURLOPT_RETURNTRANSFER, true); | ||
|
||
if (count($this->_headers)) { | ||
$heads = []; | ||
foreach ($this->_headers as $k => $v) { | ||
$heads[] = $k . ': ' . $v; | ||
} | ||
$this->curlOption(CURLOPT_HTTPHEADER, $heads); | ||
} | ||
|
||
if (count($this->_cookies)) { | ||
$cookies = []; | ||
foreach ($this->_cookies as $k => $v) { | ||
$cookies[] = "{$k}={$v}"; | ||
} | ||
$this->curlOption(CURLOPT_COOKIE, implode(";", $cookies)); | ||
} | ||
|
||
if ($this->_timeout) { | ||
$this->curlOption(CURLOPT_TIMEOUT, $this->_timeout); | ||
} | ||
|
||
if ($this->_port != 80) { | ||
$this->curlOption(CURLOPT_PORT, $this->_port); | ||
} | ||
|
||
$this->curlOption(CURLOPT_RETURNTRANSFER, 1); | ||
$this->curlOption(CURLOPT_HEADERFUNCTION, [$this, 'parseHeaders']); | ||
|
||
if (count($this->_curlUserOptions)) { | ||
foreach ($this->_curlUserOptions as $k => $v) { | ||
$this->curlOption($k, $v); | ||
} | ||
} | ||
|
||
$this->_headerCount = 0; | ||
$this->_responseHeaders = []; | ||
|
||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
$this->_responseBody = curl_exec($this->_ch); | ||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
$err = curl_errno($this->_ch); | ||
if ($err) { | ||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
$this->doError(curl_error($this->_ch)); | ||
} | ||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
curl_close($this->_ch); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.