Code Monkey home page Code Monkey logo

api-sdk-php's Introduction

Kaufland.de Onlineshop - API SDK for PHP Build Status

Latest Stable Version Coverage Status Total Downloads

PHP client for Kaufland.de Onlineshop API.

Install

Via Composer

$ composer require hitmeister/api-sdk

Via GitHub

$ git clone [email protected]:hitmeister/api-sdk-php.git

Quickstart

This section will give you a quick overview of the client and how the major functions work.

Create client

Before starting, you will need the API keys from your API settings page. Also please provide the name of your partner solution name to the setUserAgent() field.

Include the autoloader in your main project (if you haven’t already), and instantiate a new client.

require 'vendor/autoload.php';

use Hitmeister\Component\Api\ClientBuilder;

$client = ClientBuilder::create()
	->setClientKey('YOUR_CLIENT_KEY')
	->setClientSecret('YOUR_CLIENT_SECRET')
	->setUserAgent('YOUR_USER_AGENT')
	->build();

Namespaces overview

The client has a number of "namespaces", which generally expose API functionality. The namespaces correspond to the various API endpoints. This is a complete list of namespaces:

Namespace Functionality
attributes() Retrieve the attributes data
categories() Retrieve the categories data
claimMessages() Post messages to the claim DEPRECATED, use ticketMessages
claims() Retrieve and manage the claims DEPRECATED, use tickets
importFiles() To send inventory data for multiple items at once
items() Retrieve the product data
orders() Retrieve the orders data
orderInvoices() Retrieve and manage order invoices data
orderUnits() Retrieve and manage your order units
productData() Upload or change your product data for an EAN
productDataStatus() Retrieve the status of your product data
reports() Generate and retrieve summary reports
returns() Retrieve the returns from your sales
returnUnits() Accept, reject or repair returns from your sales
shipments() Add shipment information to order units
shippingGroups() Retrieve the shipping groups data
status() System status
subscriptions() Push notifications management
ticketMessages() Post messages to the tickets
tickets( ) Manage tickets, i.e. N-to-N relations between order-units and claims
warehouses() Warehouses management
units() To upload inventory data one item at a time

Retrieve the categories data

You can search for categories:

$categories = $client->categories()->find('handy');
foreach ($categories as $category) {
	echo "Category ID: {$category->id_category}\n";
	echo "Category Name: {$category->name}\n";
}

Or get the information about one of them:

$category = $client->categories()->get(1);
echo "Category ID: {$category->id_category}\n";
echo "Category Name: {$category->name}\n";

Retrieve the product data

Search for items:

$items = $client->items()->find('iphone');
foreach ($items as $item) {
	$eans = implode(',', $item->eans);
	echo "Item ID: {$item->id_item}\n";
	echo "Category ID: {$item->id_category}\n";
	echo "Title: {$item->title}\n";
	echo "EANs: {$eans}\n";
}

Also you can find the items by EAN:

$items = $client->items()->findByEan('0885909781652');

Send inventory data

According to the API documentation you have two options:

To upload your product data as CSV file

// Post the task to import your file. You will have the ID of the task.
$importFileId = $client->importFiles()
	->post('http://www.example.com/my_products.csv', 'PRODUCT_FEED');

// Retrieve the information about your task
$data = $client->importFiles()->get($importFileId);
echo "URL: {$data->uri}\n";
echo "Status: {$data->status}\n";

To update a single unit

// $result will be true or false
$result = $client->units()->update(10, ['condition' => 'new']);

Testing

$ composer test

License

The MIT License (MIT). Please see License File for more information.

api-sdk-php's People

Contributors

aazon avatar abdul-jabbar01 avatar ajibolam avatar annasweb avatar bbraun92 avatar benediktgeiger avatar brandtm avatar dariusbepunkt avatar datiswaken avatar digitalcrab avatar dominicwatts avatar duyhoan avatar etiennebruines avatar ffluche avatar jecknig avatar johnholiver avatar m074554n avatar mansurs avatar mschni2s avatar nastianovik avatar odombrovskyi-dev avatar p-solutions avatar phil-schreiber avatar philippkraetsch avatar radarlog avatar stunner2002 avatar tobiaswohlers avatar vuryss avatar yya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-sdk-php's Issues

GET /product-data/{ean}/ question

hello
When I use this 'GET /product-data/{ean}/' API, some eans return original_picture. original_url is a url, and some eans return a base64 string. Why is there such a difference? When the return is a base64 string, the response time is very long, I want to return only the url。
thank

{
  "ean": [
    "0794832213874"
  ],
  "category": [
    "nachthemden"
  ],
  "title": [
    "Damen V Ausschnitt Sling Nachtwäsche Sexy Spitze Einfarbig Schlafkleid Ärmellos Nachthemd mit Tanga-Slip XL (EU:48) Schwarz"
  ],
  "mpn": [],
  "list_price": [],
  "short_description": [],
  "description": [
    "<p><strong>Eigenschaften:</strong><br />\n❀V-Ausschnitt mit Spitze, Ärmellos, Kontrast Farbe Patchwork.<br />\n❀Die Falten auf der Brust machen dieses Nachthemd voll von sexy und lässigem französischen Stil.<br />\n❀Super weich, sehr angenehm auf der Haut. <br />\n❀Einfache Formen und klassische Stile, können Sie wählen, um es als Schlafkleid oder Freizeitkleidung frei zu tragen. Irgendeine Jahreszeit oder einfach für das Tragen um das Haus oder das Faulenzen.</p>\n\n<p><strong>Produktinformation:</strong><br />\n❀Material: 95% Polyester, 5% Elasthan<br />\n❀Länge: Kurze<br />\n❀Ausschnitt: V-Neck<br />\n❀Ärmellänge: Ärmellos<br />\n❀Jahreszeit: Frühling, Herbst, Sommer<br />\n❀Kleidungspflege: Handwäsche, Maschinenwaschbar</p>\n\n<p><strong>Größe:</strong><br />\n❀L(EU:46):Büste:96cm,Länge:98cm<br />\n❀XL(EU:48):Büste:102cm,Länge:99cm<br />\n❀2XL(EU:50):Büste:108cm,Länge:100cm<br />\n❀3XL(EU:52):Büste:116cm,Länge:101cm<br />\n❀4XL(EU:54):Büste:122cm,Länge:102cm<br />\n❀5XL(EU:56):Büste:128cm,Länge:103cm</p>\n\n<p><strong>Hinweis: </strong><br />\n1. Bitte vergleichen Sie vor dem Kauf mit Ihrer detaillierten Größe. <br />\n2. Aufgrund des Farbunterschieds zwischen verschiedenen Computern kann die Farbe des tatsächlichen Produkts geringfügig vom Bild abweichen. <br />\n3. Aufgrund der manuellen Messung bitte 1-3CM Fehler zulassen.</p>"
  ],
  "picture": [
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/2242d14f848364fa68eb91da8bdeae60.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/dee73545941088831336c3d48b7a52af.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/e501f678cba114fe3a40a766b129164d.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/06ed1c8296064ac7ec006cea5abe978c.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/a0743b6229ecb8f2294bbe25e52a7358.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/a9d7880d5f2a8932d6adafcb1d3ae546.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/f07d3180f7b4774153744626b9f4de1d.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/691e72e2f1056282bdab4ced0eb5f01a.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/be937e28d13fbc2fb589a5f7fdfb1dbf.jpg"
  ],
  "licence": [],
  "manufacturer": [
    "10001"
  ],
  "battery_disposal_instruction": [],
  "target": [
    "Damen"
  ],
  "colour": [
    "Schwarz"
  ],
  "pattern": [
    "Unifarben"
  ],
  "material_composition": [
    "95% Polyester, 5% Elasthan"
  ],
  "clothing_size": [
    "XL"
  ],
  "original_picture": [
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/2242d14f848364fa68eb91da8bdeae60.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/2242d14f848364fa68eb91da8bdeae60.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/dee73545941088831336c3d48b7a52af.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/dee73545941088831336c3d48b7a52af.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/e501f678cba114fe3a40a766b129164d.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/e501f678cba114fe3a40a766b129164d.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/06ed1c8296064ac7ec006cea5abe978c.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/06ed1c8296064ac7ec006cea5abe978c.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/a0743b6229ecb8f2294bbe25e52a7358.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/a0743b6229ecb8f2294bbe25e52a7358.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/a9d7880d5f2a8932d6adafcb1d3ae546.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/a9d7880d5f2a8932d6adafcb1d3ae546.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/f07d3180f7b4774153744626b9f4de1d.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/f07d3180f7b4774153744626b9f4de1d.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/691e72e2f1056282bdab4ced0eb5f01a.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/691e72e2f1056282bdab4ced0eb5f01a.jpg"
    },
    {
      "original_url": "https://media.real-onlineshop.de/images/items/original/be937e28d13fbc2fb589a5f7fdfb1dbf.jpg",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/be937e28d13fbc2fb589a5f7fdfb1dbf.jpg"
    }
  ]
}
{
  "ean": [
    "0794832212693"
  ],
  "category": [
    "sommerkleider"
  ],
  "title": [
    "Baby Mädchen Sommer Casual Bekleidung 2Stücke Rüschen Schulter Kurzarm Top+Blumendruck Shorts Kleidung Set Outfits 18-24 Monate (86-92) Grau"
  ],
  "mpn": [],
  "list_price": [],
  "short_description": [],
  "description": [
    "<p><strong>【Material】</strong> Hautfreundliches Baumwolle- und Polyestergewebe, atmungsaktiv, bietet Ihrem kleinen Baby ein weiches und angenehmes Gefühl.<br />\n<strong>【Süßes Design】</strong> Kurzarm Top: Grau Rüschen Baby Kurzarm Top;Blumendruck Shorts: Layer Volant dekorative, elastische Taille. Kommt<br />\n<strong>【Anlass】</strong> Ideal für den täglichen Gebrauch, Urlaub, Party, Fotografie, Babygeschenk und jedes andere besondere Festival.<br />\n<strong>【Größe】</strong>Geeignet für 0-6/6-12/12-18/18-24Monate Neugeborenes Baby Mädchen,Saison,Frühling/Sommer/Herbst/.<br />\n<strong>【Stil】</strong>Stilvoll,Neugeborenes Baby Mädchen Beiläufig Kleidung set.</p>\n\n<p><strong>Größe </strong><br />\n●Empfohlenes Alter: 0-6Monate(62-68),Länge:30cm,Bust:46cm,Hosenlänge:23cm<br />\n●Empfohlenes Alter: 6-12Monate(74-80),Länge:32cm,Bust:48cm,Hosenlänge:24cm<br />\n●Empfohlenes Alter: 12-18Monate(80-86),Länge:34cm,Bust:50cm,Hosenlänge:25cm<br />\n●Empfohlenes Alter: 18-24Monate(86-92),Länge:36cm,Bust:52cm,Hosenlänge:26cm</p>\n\n<p><strong>※Hinweis: </strong><br />\n1. Bitte vergleichen Sie vor dem Kauf mit Ihrer detaillierten Größe. <br />\n2. Aufgrund des Farbunterschieds zwischen verschiedenen Computern kann die Farbe des tatsächlichen Produkts geringfügig vom Bild abweichen. <br />\n3. Aufgrund der manuellen Messung bitte 1-3CM Fehler zulassen.</p>\n"
  ],
  "picture": [
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/432fe0686927879ae0ab8e35996565a5.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/25cb12911b890f674a1637268115002f.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/a886185483bbc980d6072f9f6c284903.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/a0e534dd9a9e7707b7eed299e25be4ac.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/afafdd18a21cc235f744bf8fae8819e7.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/4901280f3dd753eab563b0a61cd0b7f8.jpg",
    "http://pds-pictures-seller.s3.amazonaws.com/0794832212693/35693014/e5109caab81ed6840539a8b08b4ca608.jpg"
  ],
  "licence": [],
  "manufacturer": [
    "10002"
  ],
  "battery_disposal_instruction": [],
  "target": [
    "Kinder",
    "Mädchen"
  ],
  "colour": [
    "Grau"
  ],
  "pattern": [
    "Geblümt",
    "Blumen"
  ],
  "material_composition": [
    "95% Baumwolle"
  ],
  "clothing_size": [
    "86/92"
  ],
  "original_picture": [
       {
      "original_url": "data:image/jpeg;base64,/9j/4SUmRXhpZgAATU0AKxxxxx",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/2242d14f848364fa68eb91da8bdeae60.jpg"
    },
    {
      "original_url": "data:image/jpeg;base64,/9j/4SUmRXhpZgAATU0AKxxxxxxx",
      "uploaded_url": "http://pds-pictures-seller.s3.amazonaws.com/0794832213874/35693014/dee73545941088831336c3d48b7a52af.jpg"
    },
  ]
}

Broken import-files status|stats --& missing documentation

On POST import-files we got weird responses.

There are 2 different csv imports: product data and inventory data.
Product data csv type: PRODUCT_FEED, and inventory data type: 'DUMP | COMMAND

On both we get the same response format.
Most important, somewhere mentioned in the documentation, is the flag product_feed_async_done
The flag should be (int)1 if the import has been successfully completed.

The problem:
we are getting responses like:

{
  "id_import_file":          157459364,
  "uri":                     "https://host/path/to/file.csv",
  "status":                  "IMPORTED",
  "type":                    "DUMP",
  "note":                    "Import completed (2021-10-23 18:42:59)",
  "total_lines":             5315,
  "current_line":            43,
  "ts_created":              "2021-10-23 18:40:08",
  "ts_updated":              "2021-10-23 18:42:59",
  "ts_last_row_updated":     "2021-10-23 18:42:59",
  "ts_completed":            "2021-10-23 18:42:59",
  "error_count":             0,
  "product_feed_async_done": 0
}

Above example: status "IMPORTED", current_line stuck at 43, no error_count, and product_feed_async_done not 1.
Asked support and got the answer that this upload worked - they checked some random EANs.

{
  "id_import_file":          157459236,
  "uri":                     "https://host/path/to/file.csv",
  "status":                  "IMPORTED",
  "type":                    "PRODUCT_FEED",
  "note":                    "Import completed (2021-10-23 18:31:09)",
  "total_lines":             549,
  "current_line":            549,
  "ts_created":              "2021-10-23 18:30:04",
  "ts_updated":              "2021-10-23 18:31:09",
  "ts_last_row_updated":     "2021-10-23 18:31:09",
  "ts_completed":            "2021-10-23 18:31:28",
  "error_count":             4802,
  "product_feed_async_done": 1
}

Above example: status "IMPORTED", error_count more than total_lines, and product_feed_async_done is 1.

I just scrolled through all uploads and seems like all uploads with an error count have the done flag set to 1. Weird.


How do you determine if the upload was success?
We MUST know if all changes (stock, price, ...) have been made.

I guess you do not stop on first error. So instead of "all or none" its more like "do as much as possible".
Thats ok, but we need to know what lines|EANs failed.

Atm this is not possible to automate.

Missing 'Accept' Header

According to the documentation, the 'Accept' header must be set for all requests.

https://www.kaufland.de/api/v1/?page=rest-api

Required Headers
Each request must contain 4 headers:
Accept - All requests must contain an Accept header set to application/json.

If this is not set, the PATCH "https://www.kaufland.de/api/v1/units/xxxxxxxxxxxx/" call will not result in an HTTP 404, but in an HTTP 405. Also the response is then not a JSON, but an XML.

<html>
    <head>
        <title>405 Not Allowed</title>
    </head>
    <body>
        <center>
            <h1>405 Not Allowed</h1>
        </center>
        <hr>
        <center>nginx</center>
    </body>
</html>

Responding to a Ticket always returns a 404

it's possible that it's almost the same issue like #125 only difference it's for the post request.

I'm always getting resource not found. My tickets ids always start with 0011.

If I inspect the request, it turns the ticked it into an integer (zeros are being removed).

Deprecation Issue for php 8.1

This is the error i got when I create Object Of class : \Hitmeister\Component\Api\Transfers\OrderInvoiceAddTransfer
$data = new \Hitmeister\Component\Api\Transfers\OrderInvoiceAddTransfer();

Error : During inheritance of JsonSerializable: Uncaught ErrorException: Return type of Microsoft\Graph\Model\Entity::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed
image

POST /units/ and PATCH /units/{id_unit}/ are broken on the server

I am not actually using the PHP SDK. I am simply trying the swagger ui on https://www.kaufland.de/api/v1/?page=endpoints. If I send a POST to /units/ with the following JSON

{
"ean": "5050192667210",
"condition": "new",
"listing_price": 2399,
"minimum_price": 2399
}

I get return code 400
{
"message": " : minimum price cannot be bigger than listing price"
}

I can use any minimum_price I want the result is always the same. The same is true for the PATCH api endpoint. Even if I only want to patch the amount of an existing item unit the result is " : minimum price cannot be bigger than listing price".

generate_sample_data orders

the old api had a GET parameter which was used to generate sample data, namely generate_sample_data.

does the new api also has the ability?

alternatively, do you have a sandbox on which we can test our code against?

Find unit by id_offer only

I needed to find unit by id_offer only (no EAN) - so needed to add functionality to sdk

Happy to submit a PR

Just want to know whether you are interested in this sort of functionality

Shipping without tracking

On frontend you can ship order items without tracking. Via API this appears to be impossible.

The work around I found was to provide courier and a space character as tracking code. The API returns true so this appears acceptable.

Providing null value as tracking omits parameter from request body and therefore fails validation.

Coding standards

Have you considered writing code to a FIG coding standard

Either PSR-2 or perhaps PSR-12?

I use the sdk get warehouse data is null

$client = ClientBuilder::create()->setClientKey($client_key)->setClientSecret($client_seccret)->build();
$result = $client->warehouses()->find();

return data is null

warehouse_data

can you help me?

wrong delivery_time_expires value

fix the calculation of the delivery time expires and add field "order_sent_expires" with right calculation of time when the order has to be send.

Suddenly: Response header "Hm-Collection-Range" is missing.

Hello,

without modifying a file the following error appeared: Response header "Hm-Collection-Range" is missing.

After a little debugging we found that the header is now in lowercase:
"Hm-Collection-Range" -> "hm-collection-range"

I don't know why but it would be nice if you could change your code that the case doesn't matter.

Regards
Marcus

Is a product_feed downloaded multiple times?

Hi,

when I post an uri of my product csv to Hitmeister, do they keep an eye on my remote file or do they only look one time and then never again at my file? Do they trace my CRUD operations described in my remote file?

Regards

Endpoint Documnetation OrderUnit.Status Incomplete

Hi there,

according to you endpoint documentation the order unit status is one of the following values ['need_to_be_sent' or 'sent' or 'received' or 'cancelled' or 'sent_and_autopaid' or 'returned']. However the API also returns 'returned_paid'.

Regards
Michael

missing examples

do you have somewhere examples on how to use the api to e.g. retrieve orders?

atm I only have a REST based documentation which I can use to build my own client but at least some information on how to use this sdk would be very helpfull.

did I miss it somewhere?

PHP compatiblity

Part of your code is not compatible with 5.6 or lower

I recommend adjusting composer.json

I can submit a PR if required

docker run --rm -v $PWD:/code domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 5.6-7.3 --colors --warning-severity=0 --report=full,summary --extensions=php ./src

FILE: /code/src/Namespaces/ReturnsNamespace.php
----------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
  96 | ERROR | 'string' type declaration is not present in PHP
     |       | version 5.6 or earlier
  96 | ERROR | 'string' type declaration is not present in PHP
     |       | version 5.6 or earlier
 118 | ERROR | 'int' type declaration is not present in PHP version
     |       | 5.6 or earlier
 118 | ERROR | 'string' type declaration is not present in PHP
     |       | version 5.6 or earlier
 118 | ERROR | 'string' type declaration is not present in PHP
     |       | version 5.6 or earlier
----------------------------------------------------------------------

Time: 1.43 secs; Memory: 14MB


PHP CODE SNIFFER REPORT SUMMARY
----------------------------------------------------------------------
FILE                                                  ERRORS  WARNINGS
----------------------------------------------------------------------
/code/src/Namespaces/ReturnsNamespace.php             5       0
----------------------------------------------------------------------
A TOTAL OF 5 ERRORS AND 0 WARNINGS WERE FOUND IN 1 FILE
----------------------------------------------------------------------

order_units/seller response strips leading 0 from postcode

Hello,

My apologies: this issue concerns the server-side Hitmeister API, not this library, but I could not find anywhere else to report it. Please let me know if I should report this elsewhere.

When a customer has a postcode with a leading zero, such as 09117 the order_units/seller API call response returns 9117. Here's a partial print_r of the response:

Array
(
    [0] => stdClass Object
        (
            [id_order_unit] => 3145678........
            [id_order] => MFT....
            .....

            [billing_address] => stdClass Object
                (    
                    ....
                    [postcode] => 9117
                    ....
                    [country] => DE
                )

            [shipping_address] => stdClass Object
                (
                    ....
                    [postcode] => 9117
                    ....
                    [country] => DE
                )

I double checked that the invoice contains the proper postcode (it does).
We can work around this but I thought I'd mention the bug.

Thanks,
Kenney

Question regarding giving/receiving date/times from the API and their timezones

See for example:

'ts_created:from' => date(Request::DATE_TIME_FORMAT, $createdTime),

As far I see, this means that because it uses date('Y-m-d H:i:s', ...) it'll use the configured local timezone that may or may not be UTC.

I think that the unit tests are ran with the time zone configured as UTC, but I cannot find documentation on real.de end stating that the UTC time should be taken (and not, for example, 'Europe/Berlin' time).

Can anyone confirm that what real.de expects is a UTC date/time and not a German one?

In addition, once this is figured out, it might be best to mention this in the README.md file (that they should make sure their timezone matches what real.de expects)

API V2

I have received this Notification from Kaufland:
Your version of the Kaufland.de API connection will soon no longer be supported.
01/27/2023
Your API connection to Kaufland is currently running on an outdated API version. Support for this version will shortly be discontinued. Please switch to the new Kaufland Marketplace Seller API V2 by the end of February 2023. See the documentation\n\nAre you using a software interface? Please contact your service provider for further information.

Is this package going to be updated to Version 2?

ClientBuilder.php Unsafe usage of new static

I implemented this sdk in my project and ran some static tests. Picked up on this and I'm inclined to agree. Just a recommendation though.


Line ClientBuilder.php


47 Unsafe usage of new static().
💡 Consider making the class or the constructor final.


signature error

`<?php

  $method = "PATCH";
  $uri = "https://www.kaufland.de/api/v1/order-units/XXXXXXXXXXXX/send/";
  $body = null;
  $timestamp = time(); //time();
  $secretKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  
  $hmac = signRequest($method, $uri, $body, $timestamp, $secretKey);
  print("\n$hmac\n"); 
  
  function signRequest($method, $uri, $body, $timestamp, $secretKey)
  {
      $string = implode("\n", [
	      $method,
	      $uri,
	      $body,
	      $timestamp,
      ]);
  
      return hash_hmac('sha256', $string, $secretKey);
  }`

Hello, I use the API documentation to provide the sample code generated by the signature, and then initiate the request, always prompt signature error, I according to the requirements of the API format to fill in and launch a request, hope to know what causes, thanks

GET method is succeed,POST and PATCH method is Failed.

Kein Ergebnis $client->orderUnits()->find();

orderUnits()->find(); gibt keine Daten zurück. Wärend categories()->find('xyz'); ein Ergebnis gibt.

Ohne SDK über "/order-units/seller/" bekomme ich Daten.

Hat Jemand gleiches Problem?

... must be of the type array, null given

Here is a stacktrace from an order I received, which contains "NULL" in property "claim".
Is it a problem with the order, or in class "AbstractTransfer.php"? How will it be fixed?
Thanks :)

Argument 2 passed to Hitmeister\Component\Api\Transfers\AbstractTransfer::makeTransfer() must be of the type array, null given, called in .../api-sdk/src/Transfers/AbstractTransfer.php on line 107 and defined
#0 /api-sdk/src/Transfers/AbstractTransfer.php(153): error_handler(4096, 'Argument 2 pass...', '/home/COMPLEX/m...', 153, Array)
#1 /api-sdk/src/Transfers/AbstractTransfer.php(107): Hitmeister\Component\Api\Transfers\AbstractTransfer::makeTransfer('Hitmeister\\Comp...', NULL)
#2 /api-sdk/src/Transfers/AbstractTransfer.php(159): Hitmeister\Component\Api\Transfers\AbstractTransfer->fromArray(Array)
#3 /api-sdk/src/Cursor.php(185): Hitmeister\Component\Api\Transfers\AbstractTransfer::makeTransfer('\\Hitmeister\\Com...', Array)
#4 /api-sdk/src/Cursor.php(85): Hitmeister\Component\Api\Cursor->getCurrent()
#5 /scripts/hitmeister.php(94): Hitmeister\Component\Api\Cursor->current()
#6 {main}

My Code:

$client = ClientBuilder::create()
                               ->setClientKey(HITMEISTER_CLIENT_KEY)
                               ->setClientSecret(HITMEISTER_SECRET_KEY)
                               ->build();

        $hitmeisterOrders = $client->orderUnits()->find(array("need_to_be_sent"), NULL, date("Y-m-d H:i:s",time()-48*3600));

Get total reports/orders?

Is there a way to get the total amount of reports or orders or units, etc.? Would be handy for pagination purposes in case there are more items than limit.

id_unit should be exposed by the order unit model

The order unit model does not expose the unit ID. We do not use the offer ID property. The reference for a unit in our system is simply the unit ID. This means that we have to do an extra API call to the units endpoint to retrieve the unit ID, by searching for a unit with a certain item ID and unit condition. It would make more sense to expose the unit ID in the order unit model (like the condition, delivery time etc. of the unit are already exposed). Is this possible?

Edit: It would also make more sense to expose the unit as a sub-model of the order unit model (like the item), but that would be a breaking change.

[tickets::find] Field id_buyer has invalid value "0"

Calling method $client->tickets()->find()
without any params throws

Hitmeister\Component\Api\Exceptions\BadRequestException: Field id_buyer has invalid value "0" in /var/www/html/vendor/hitmeister/api-sdk/src/Middleware.php:94

Reason: the cast to int forces us to send a zero instead of null.
See https://github.com/hitmeister/api-sdk-php/blob/1.50.0/src/Namespaces/TicketsNamespace.php#L51

Tested via https://www.kaufland.de/api/v1/?page=endpoints#!/tickets/getSellerTickets
with no id (field empty): works
with "0" id: "message": "Field id_buyer has invalid value \"0\""

Was there a reason for the cast to int?


Temp fix (tested):

// Create client.
$client = ClientBuilder::create()
    ->setClientKey('YOUR_CLIENT_KEY')
    ->setClientSecret('YOUR_CLIENT_SECRET')
    ->setUserAgent('YOUR_USER_AGENT')
    ->build();

// Instead of using
// $client->tickets()->find()
// we use the
// $client->tickets()->buildFind()

// Default values.
$status = null;
$openReason = null;
$topic = null;
$buyerId = null;
$createdFrom = null;
$updatedFrom = null;
$sort = 'ts_created:desc';
$limit = 30;
$offset = 0;

// Use of ::buildFind() to be able to use $buyerId with NULL.
$r = $client->tickets()->buildFind()
    ->addParam('status', $status)
    ->addParam('open_reason', $openReason)
    ->addParam('topic', $topic)
    ->addParam('id_buyer', $buyerId)// Removed (int) casting.
    ->addDateTimeParam('ts_created:from', $createdFrom)
    ->addDateTimeParam('ts_updated:from', $updatedFrom)
    ->setSort($sort)
    ->setLimit($limit)
    ->setOffset($offset)
    ->find();

// Output.
foreach ($r as $item) {
    echo var_export($item->toArray(), true) . PHP_EOL;
}

Backend ids like "0012345" are getting forced to int before calls.

Just happen to me through ticket closing call.

Received ticket with id "00112556780"
But URI gets built with "112556780"

$client = ...
$endpoint = new \Hitmeister\Component\Api\Endpoints\Tickets\Get($client->getTransport());
$endpoint->setId($ticketId);

echo var_export($endpoint->getURI(), true) . PHP_EOL; die;
// tickets/112556780/

Problem:

public function getURI()
{
	if (empty($this->id)) {
		throw new RuntimeException('Required params id is not set');
	}
	return sprintf($this->getUriPattern(), $this->id);
}

protected function getUriPattern()
{
	return 'tickets/%d/';
}

Should have used %s instead of %d.

I guess this will and does happen to all other namespaces too.
I have seen the %d on all sprintf i looked at.


EDIT:

Temp fix: using the transport to perform the request with own uri

GET

$client = ...
$endpoint = new \Hitmeister\Component\Api\Endpoints\Tickets\Get($client->getTransport());
$endpoint->setId($ticketId);
#$result = $endpoint->performRequest(); nope, bugged
$result = $endpoint->getTransport()->performRequest(
    $endpoint->getMethod(),
    sprintf('tickets/%s', $ticketId),
    $endpoint->getParams(),
    $endpoint->getBody(),
    []
);

CLOSE

$client = ...
$endpoint = new \Hitmeister\Component\Api\Endpoints\Tickets\Close($client->getTransport());
$endpoint->setId($ticketId);
#$result = $endpoint->performRequest(); nope, bugged
$result = $endpoint->getTransport()->performRequest(
    $endpoint->getMethod(),
    sprintf('tickets/%s/close/', $ticketId),
    $endpoint->getParams(),
    $endpoint->getBody(),
    []
);

I can't create new product,can you help me

Since July 1, I have been using API to upload products and have been reporting errors. can you help me! I use "PUT /product-data/{ean}" add new product,return errr:
{ "item_ready": false, "update_status": "FAIL", "item_not_ready_reason": "PROCESSING_FAILED", "update_fail_reason": "UNKNOWN", "missing_attributes": "" }

upload data is:
{"ean":["4451602990613"],"title":["Durchmesser 165mm Diamant trockenes Blatt graues S\u00e4geblatt 165*20*40T 1 St\u00fcck"],"description":["<p>Beschreibung<\/p><p>Dieses Kreiss\u00e4ge blatt besteht aus hochwertigem Diamant material, hat eine hohe H\u00e4rte und ist langlebig. Scharfe Schneide f\u00fcr schnelle und reibungslose Schnitte.<\/p><p>Produkt merkmale: Dieses Kreiss\u00e4ge blatt besteht aus hochwertigem Diamant material mit hoher H\u00e4rte und ist w\u00e4hrend des Gebrauchs langlebig.<\/p><p>Dieses Kreiss\u00e4ge blatt besteht aus hochwertigem Diamant material mit hoher H\u00e4rte und ist w\u00e4hrend des Gebrauchs langlebig.<\/p><p>Dieses S\u00e4geblatt wird haupt s\u00e4chlich zum Drehen von Werkzeugen und zum Schneiden von Holz verwendet.<\/p><p>Die 40 gleichm\u00e4\u00dfig angeordneten Zacken sind sehr scharf, was einen schnellen und glatten Schnitt garantiert.<\/p><p>Scharfe Schneide, die einen schnellen und glatten Schneide effekt bietet.<\/p><p>Super hart, stabil, langlebig und effizient.<\/p><p>Hochpr\u00e4zises Schneiden, ordentlich geschnittene Streifen, glatte Abschnitte, lange Lebensdauer.<\/p><p>Spezifikation: Diamant<\/p><p>Material: Diamant<\/p><p>Au\u00dfen durchmesser: 165mm\/6,50 Zoll<\/p><p>Innen durchmesser: 20mm\/0,79 Zoll<\/p><p>Z\u00e4hne. 40T<\/p><p>Gewicht: 220g<\/p><p>Verpackung enthalten<\/p><p><\/p><p>1 x Kreiss\u00e4ge blatt<\/p><p><\/p>"],"picture":["https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/00c1029e900bf045ab6fe940431352cb.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/a4389243dc796ecd6d8d9d16e528e8dc.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/daeb224a9bef8f9c6baa75e742855d58.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/6f0b3c6749594fb66906ceb844db6240.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/f2061d9febef5661cea78615f2c0dc33.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/e8f55e5549556e1ad4d3e17b6768bdb9.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/5496532ef449be82bae7b9162c805581.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/e896eccbfb522cccd0a8468e4900fb37.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/6fe4e131db11162c3b4b8ce537d15f51.jpg","https:\/\/xtd-static.oss-cn-shenzhen.aliyuncs.com\/product\/20210702\/3ef39c0f83c68397dbf49aeb502e8447.jpg"],"category":["werkzeug"],"manufacturer":["re-Mon-rich"],"additional_attributes":[{"attribute":"list_price","value":["1234ct"]}]}

Response header "Hm-Collection-Range" is missing - in Order Units with api sandbox keys

I try find order units over api sandbox keys from kaufland.de like this

$this->getClient()->orderUnits()->find('open', null, null, null, 'ts_created:desc', 30, 0); but it throws ServerException Response header "Hm-Collection-Range" is missing

After debugging on Hitmeister\Component\Api\Helper\Response::extractCursorPosition I see some json data in body and this headers

Array
(
    [Server] => Array
        (
            [0] => nginx
        )

    [Date] => Array
        (
            [0] => Tue, 17 Aug 2021 06:20:21 GMT
        )

    [Content-Type] => Array
        (
            [0] => application/json
        )

    [Transfer-Encoding] => Array
        (
            [0] => chunked
        )

    [Connection] => Array
        (
            [0] => keep-alive
        )

    [Set-Cookie] => Array
        (
            [0] => PHPSESSID=2jh1koq29eqo67sta43s3p4vr9; path=/
            [1] => x-storefront=de; Domain=.kaufland.de; Path=/; SameSite=none; Secure
        )

    [Expires] => Array
        (
            [0] => Thu, 19 Nov 1981 08:52:00 GMT
        )

    [Cache-Control] => Array
        (
            [0] => no-store, no-cache, must-revalidate
        )

    [Pragma] => Array
        (
            [0] => no-cache
        )

    [X-Hm-Sandbox-Mode] => Array
        (
            [0] => 1
        )

    [X-Backend] => Array
        (
            [0] => shop-api-backend03
        )

    [Age] => Array
        (
            [0] => 0
        )

    [X-Cache] => Array
        (
            [0] => MISS
        )

    [Accept-Ranges] => Array
        (
            [0] => bytes
        )

    [Content-Security-Policy] => Array
        (
            [0] => default-src https: 'unsafe-inline' 'unsafe-eval' data: blob:
        )

    [Referrer-Policy] => Array
        (
            [0] => strict-origin-when-cross-origin
        )

    [Strict-Transport-Security] => Array
        (
            [0] => max-age=63072000
        )

    [X-Content-Type-Options] => Array
        (
            [0] => nosniff
        )

    [X-Frame-Options] => Array
        (
            [0] => SAMEORIGIN
        )

    [X-XSS-Protection] => Array
        (
            [0] => 1
        )

)

Is problem with sandbox api keys? How else can I test the implementation?

Prestashop module, sdk not working (Cursor class)

Hi, i'm using real prestashop module, it uses hitmeister sdk for php.
We've moved the module from one to another prestashop server (same prestashop, same website) but this sdk gives error in his Cursor.php class.

test

We have 2 identical servers, but this works only in the older one, maybe the problem is a php library that is missing? Or composer packages not getting loaded?

/orders/{id_order}/ Endpoint: faulty behaviour on real.de

According to your documentation:

To get the units in each order, you must query the orders individually via the /orders/{id_order}/ endpoint.

Im using your API on Real.DE but using the endpoint /orders/{id_order} just returns a single json object containing the fields id_order and ts_created. Didn't I understood something right? I thought the query should send me the appropriate order units related to the queried id_order.

I looked up your provided php SDK but couldn't find a hint for a function searching for order units with given id_order.

Regards,
Michael

Method /product-data/{ean} returns no result

When trying to check product data with following code:

use Hitmeister\Component\Api\ClientBuilder;

$api_instance = ClientBuilder::create()
				->setClientKey($settings['client_key'])
				->setClientSecret($settings['secret_key'])
				->build();
$productData = $api_instance->productData();
$data = $productData->get($ean);

I get null as result. When executing same method via sandbox or standalone cURL request correct result is returned.

client->units->get() Get all untis

I want to get all units, but there is no method to do this.
This is the only way to do: units()->get(id_item);
The documation allows it.
You can get a list of all of your own units by sending a GET request to the /units/seller/ endpoint. Note: it can take several minutes for units to show up in this list after they are created.

how upsert a new item with new ean code?

hi, i try upload a new item with new ean, this ean not exist on real.de database!

my code:

`

$namespace = new ProductDataNamespace($client->getTransport());
$pd = $client->productData($client->getTransport());

$data = [
"ean" => [$newEan],
"category" => ['angelruten'],
"title" => [$neve],
"picture" => ["https://racvarosihorgaszbolt.hu/public/upload/termek_kepek/bot/pergeto/nevis-ryder-baitcast-240m-20-50gr-horgaszbot-1691-240.jpg","http://pds-pictures-seller.s3.amazonaws.com/5998214360810/34274624/383fef385c40dc73e8c9185c52fa5985.jpg"],
"description"=> ["this is description"],
"mpn" => [],
"short_description" => [],
"list_price" => [],
"manufacturer"=> []
];
$try = $namespace->upsert($newEan, ProductDataTransfer::make($data));
print_r($try);
`
it upload a new product but its not valid and havent image and description and category,
its just have title and ean code!

please help thanks

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.