magento2-docker/app/code/IpSupply/SyncOrder/Helper.php

63 lines
1.5 KiB
PHP
Executable File

<?php
namespace IpSupply\SyncOrder;
final class Helper
{
public const API_KEY = 'IpSupply@123';
public const PREFIX = 'IpSupply_SyncOrder';
static function getForm()
{
$data = [
'url' => '',
'token' => ''
];
$config = \IpSupply\SyncOrder\Config\Getter::get('config');
if ($config) {
$data = json_decode($config, true);
}
return [
[
'label' => 'API',
'name' => 'url',
'value' => $data['url'] ?? ''
],
[
'label' => 'Token',
'name' => 'token',
'value' => $data['token'] ?? ''
]
];
}
static function responseOk(array $data)
{
header('HTTP/1.1 200 Ok');
header('Accept: application/json');
header('Content-Type: application/json');
die(json_encode($data));
}
static function responseFail(array $data)
{
header('HTTP/1.1 400 Bad request');
header('Accept: application/json');
header('Content-Type: application/json');
die(json_encode($data));
}
static function responseMethodFail()
{
header('HTTP/1.1 400 bad request');
header('Accept: application/json');
header('Content-Type: application/json');
die(json_encode([
'status' => false,
'message' => 'Param ?method=... not exist!'
]));
}
}