A "Channel" is an online shop, a marketplace or a website that has shopping cart functionality. e.g. Shopify, Magento or WooCommerce.
A "Connector" makes it possible to sync data between a Channel and Stock2Shop.
This repository has a Demo API which can be run locally. It mimics how a "real" Channel might behave.
To set up the Demo API and tests, run the following commands in sequence.
git clone https://github.com/stock2shop/connector.git
cd connector
composer install
Set your environment.
cp env.sample .env
Edit the .env
file accordingly.
Start the Demo API locally. The API uses the file system to store information, it has no database.
Binaries for Mac, linux and windows have been included in the
demo_store
directory The demo API is built in Go, instructions to build are below but are not required to run the project.
./demo_store/bin/mac /path/to/your/data/dir
Run your tests
./vendor/bin/phpunit
Your tests should pass. You can view the products saved on the Demo API by looking in the data dir. You can also view the logs depending on where you configured this.
Data is passed between applications using Data Transfer Objects DTOs.
The interface to send ChannelProducts to a Channel can be found here.
For our system to verify that the products exist on the channel, there are two methods available, get and getByCode
Channel Products are sent in batches to the channel and the connector updates the channel as efficiently as possible.
- PHP version 8.1
- Use strict types
declare(strict_types=1);
- Use PSR-12 standards
- Setup
php-cs-fixer
in your IDE to enforce coding standards
Using go modules for dependencies, the following commands should be run in the connector/demo_store
directory.
List all modules
go list -m all
Add missing and remove unused modules
go mod tidy
Copy dependencies to vendor dir
go mod vendor
In the demo_store
first build the program
go build -o build/<EXECUTABLE_NAME>