Skip to content

Commit

Permalink
initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
michubortek committed Jan 21, 2022
0 parents commit c81da19
Show file tree
Hide file tree
Showing 42 changed files with 3,924 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BaseLinkerShopsApi-master.zip
73 changes: 73 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash

echo -e "\e[92m######################################################################"
echo -e "\e[92m# #"
echo -e "\e[92m# Start BaseLinker ShopsAPI Builder #"
echo -e "\e[92m# #"
echo -e "\e[92m######################################################################"

echo -e "Release"
echo -e "\e[39m "
echo -e "\e[39m======================================================================"
echo -e "\e[39m "
echo -e "Step 1 of 6 \e[33mRemove old release\e[39m"
# Remove old release
rm -rf CrehlerBaseLinkerShopsApi CrehlerBaseLinkerShopsApi-*.zip
echo -e "\e[32mOK"

echo -e "\e[39m "
echo -e "\e[39m======================================================================"
echo -e "\e[39m "
echo -e "Step 2 of 6 \e[33mCopy files\e[39m"
rsync -av --progress . CrehlerBaseLinkerShopsApi --exclude CrehlerBaseLinkerShopsApi
echo -e "\e[32mOK"


echo -e "\e[39m "
echo -e "\e[39m======================================================================"
echo -e "\e[39m "
echo -e "Step 3 of 6 \e[33mGo to directory\e[39m"
cd CrehlerBaseLinkerShopsApi
echo -e "\e[32mOK"

echo -e "\e[39m "
echo -e "\e[39m======================================================================"
echo -e "\e[39m "
echo -e "Step 4 of 6 \e[33mDeleting unnecessary files\e[39m"
cd ..
( find ./CrehlerBaseLinkerShopsApi -type d -name ".git" && find ./CrehlerBaseLinkerShopsApi -name ".gitignore" && find ./CrehlerBaseLinkerShopsApi -name "yarn.lock" && find ./CrehlerBaseLinkerShopsApi -name ".php_cs.dist" && find ./CrehlerBaseLinkerShopsApi -name ".gitmodules" && find ./CrehlerBaseLinkerShopsApi -name "build.sh" ) | xargs rm -r
cd CrehlerBaseLinkerShopsApi/src/Resources
# rm -rf administration
cd ../../../
echo -e "\e[32mOK"


echo -e "\e[39m "
echo -e "\e[39m======================================================================"
echo -e "\e[39m "
echo -e "Step 5 of 6 \e[33mCreate ZIP\e[39m"
zip -rq CrehlerBaseLinkerShopsApi-master.zip CrehlerBaseLinkerShopsApi
echo -e "\e[32mOK"

echo -e "\e[39m "
echo -e "\e[39m======================================================================"
echo -e "\e[39m "
echo -e "Step 6 of 6 \e[33mClear build directory\e[39m"
rm -rf CrehlerBaseLinkerShopsApi
echo -e "\e[32mOK"


echo -e "\e[92m######################################################################"
echo -e "\e[92m# #"
echo -e "\e[92m# Build Complete #"
echo -e "\e[92m# #"
echo -e "\e[92m######################################################################"
echo -e "\e[39m "
echo " _____ _ _ ";
echo " / ____| | | | | ";
echo " | | _ __ ___| |__ | | ___ _ __ ";
echo " | | | '__/ _ \ '_ \| |/ _ \ '__|";
echo " | |____| | | __/ | | | | __/ | ";
echo " \_____|_| \___|_| |_|_|\___|_| ";
echo " ";
echo " ";
47 changes: 47 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "crehler/base-linker-shops-api",
"description": "Crehler BaseLinker Shops API",
"type": "shopware-platform-plugin",
"license": "proprietary",
"version": "1.0.31",
"authors": [
{
"name": "Crehler Sp. z o. o.",
"email": "support@crehler.com",
"homepage": "https://crehler.com",
"role": "Owner"
},
{
"name": "Michał Bortkiewicz",
"homepage": "https://github.com/michubortek",
"role": "Developer"
}
],
"support": {
"email": "support@crehler.com"
},
"autoload": {
"psr-4": {
"Crehler\\BaseLinkerShopsApi\\": "src/"
}
},
"require": {
"shopware/core": "6.4.*",
"shopware/storefront": "6.4.*"
},
"extra": {
"shopware-plugin-class": "Crehler\\BaseLinkerShopsApi\\CrehlerBaseLinkerShopsApi",
"plugin-icon": "src/Resources/config/plugin.png",
"copyright": "(c) by Crehler Sp. z o. o.",
"label": {
"de-DE": "Crehler BaseLinker Shops API",
"en-GB": "Crehler BaseLinker Shops API",
"pl-PL": "Crehler BaseLinker Shops API"
},
"manufacturerLink": {
"de-DE": "https://store.shopware.com/crehler.html",
"en-GB": "https://store.shopware.com/en/crehler.html",
"pl-PL": "https://store.shopware.com/en/crehler.html"
}
}
}
35 changes: 35 additions & 0 deletions src/Component/BaseLinker/StoreApiStruct/AssignArrayTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);

namespace Crehler\BaseLinkerShopsApi\Component\BaseLinker\StoreApiStruct;

/**
* Trait AssignArrayTrait
*/
trait AssignArrayTrait
{
/**
* @param array $options
*
* @return $this
*/
public function assign(array $options)
{
foreach ($options as $key => $value) {
if ($key === 'id' && method_exists($this, 'setId')) {
$this->setId($value);
continue;
}

try {
$this->$key = $value;
} catch (\Exception $error) {
// nth
}
}

return $this;

}


}
216 changes: 216 additions & 0 deletions src/Component/BaseLinker/StoreApiStruct/Order/OrderAddProduct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
<?php

namespace Crehler\BaseLinkerShopsApi\Component\BaseLinker\StoreApiStruct\Order;


/**
* Class OrderProduct
*/
class OrderAddProduct
{
/**
* identyfikator produktu w podłączonym sklepie
* @var int|null
*/
protected ?int $id;

/**
* identyfikator wariantu produktu (0 jeśli produkt główny)
* @var int|null
*/
protected ?int $variant_id;

/**
* SKU produktu (opcjonalnie)
* @var string|null
*/
protected ?string $sku;

/**
* nazwa produktu (używana jeśli nie można pobrać jej z bazy na podstawie id)
* @var string|null
*/
protected ?string $name;

/**
* jednostkowa cena brutto produktu
* @var float|null
*/
protected ?float $price;

/**
* akupiona ilość sztuk
* @var int|null
*/
protected ?int $quantity;

/**
* numer aukcji
* @var int|null
*/
protected ?int $auction_id;

/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}

/**
* @param int|null $id
* @return OrderAddProduct
*/
public function setId(?int $id): OrderAddProduct
{
$this->id = $id;
return $this;
}

/**
* @return int|null
*/
public function getVariantId(): ?int
{
return $this->variant_id;
}

/**
* @param int|null $variant_id
* @return OrderAddProduct
*/
public function setVariantId(?int $variant_id): OrderAddProduct
{
$this->variant_id = $variant_id;
return $this;
}

/**
* @return string|null
*/
public function getSku(): ?string
{
return $this->sku;
}

/**
* @param string|null $sku
* @return OrderAddProduct
*/
public function setSku(?string $sku): OrderAddProduct
{
$this->sku = $sku;
return $this;
}

/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}

/**
* @param string|null $name
* @return OrderAddProduct
*/
public function setName(?string $name): OrderAddProduct
{
$this->name = $name;
return $this;
}

/**
* @return float|null
*/
public function getPrice(): ?float
{
return $this->price;
}

/**
* @param float|null $price
* @return OrderAddProduct
*/
public function setPrice(?float $price): OrderAddProduct
{
$this->price = $price;
return $this;
}

/**
* @return int|null
*/
public function getQuantity(): ?int
{
return $this->quantity;
}

/**
* @param int|null $quantity
* @return OrderAddProduct
*/
public function setQuantity(?int $quantity): OrderAddProduct
{
$this->quantity = $quantity;
return $this;
}

/**
* @return int|null
*/
public function getAuctionId(): ?int
{
return $this->auction_id;
}

/**
* @param int|null $auction_id
* @return OrderAddProduct
*/
public function setAuctionId(?int $auction_id): OrderAddProduct
{
$this->auction_id = $auction_id;
return $this;
}

/**
* @param array $options
*
* @return $this
*/
public function assign(array $options)
{
foreach ($options as $key => $value) {
if ($key === 'id' && method_exists($this, 'setId')) {
$this->setId((int) $value);
continue;
}

if (in_array($key, [
'variant_id',
'quantity',
'auction_id',
])) {
$value = $value ? (int)$value : null;
}

if (in_array($key, [
'price'
])) {
$value = $value ? (float)$value : null;
}

try {
$this->$key = $value;
} catch (\Exception $error) {
// nth
}
}

return $this;

}
}
Loading

0 comments on commit c81da19

Please sign in to comment.