Giter VIP home page Giter VIP logo

zbozicz's Introduction

Build Status

Pokročilé měření konverzí Zboží.cz

Vychází z https://github.com/seznam/zbozi-konverze, ale přidává lepší možnost integrace do větších systémů. Namespace, asynchronní odesílání objednávek atd.

Odeslání objednávky

<?php

use Soukicz\Zbozicz\Client;
use Soukicz\Zbozicz\Order;
use Soukicz\Zbozicz\CartItem;

$client = new Client(1234567890, "fedcba9876543210123456789abcdef", true);

$order = new Order('OBJ21101');
$order
    ->setEmail('[email protected]')
    ->setDeliveryType('PPL')
    ->addCartItem((new CartItem)
        ->setId('ABC1')
        ->setName('NAZEV PRODUKTU')
        ->setUnitPrice(1000)
        ->setQuantity(2)
    )
    ->addCartItem((new CartItem)
        ->setId('ABC2')
        ->setName('NAZEV PRODUKTU')
        ->setUnitPrice(2000)
    );

$client->sendOrder($order);

Paralelní odeslání objednávek

Je možné vytvořit si jen PSR-7 request a data následně odeslat například přes Guzzle. Lze tak jednoduše odesílat objednávky hromadně paralelně.

<?php
use Soukicz\Zbozicz\Client;
use Soukicz\Zbozicz\Order;
use Soukicz\Zbozicz\CartItem;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Client\Pool;

$client = new Client(1234567890, "fedcba9876543210123456789abcdef", true);
$requests = [];
foreach($orders as $order){
    $requests[$order->geId()] = $client->createRequest($order);
}

$httpClient = new \GuzzleHttp\Client();
$pool = new Pool($httpClient, $requests, [
    'concurrency' => 5,
    'fulfilled' => function (Response $response, $index) {
        echo "Order '$index' accepted\n";
    },
    'rejected' => function ($reason, $index) {
        echo "Order '$index' not accepted: " . $reason . "\n";
    },
]);

zbozicz's People

Contributors

soukicz avatar vojtasvoboda avatar machy8 avatar fifal avatar matej21 avatar janmarek avatar milous avatar vitkutny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.