gadoma/walmart-api-php-client

Walmart Open API PHP client

1.0.4 2021-01-10 22:05 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:14:11 UTC


README

GitHub license Travis build status Coveralls test coverage SensioLabsInsight grade Packagist Packagist

Introduction

Welcome to the Walmart Open API PHP Client, a Composer package for interacting with the Walmart Open API.

This library is powered by Guzzle 6 thus requires PHP >= 5.5.0 to work.

Extensive PHPUnit tests are provided, the builds are handled by Travis-CI and test code coverage is calculated by Coveralls.io.

Contributing

If you notice any bugs or have an idea for improvements, feel free to submit a ticket to the project Issue Tracker.

Pull requests are welcome, just remember to submit them to the develop branch. Any PRs to the master branch will be rejected.

Installation

Composer

If you don't have Composer already available on your local system, install it first:

curl -sS https://getcomposer.org/installer | php

Manual installation

Create a composer.json file and add an entry in the "require" section:

{
    "require": {
        "gadoma/walmart-api-php-client": "^1.0"
    }
}

Run the below command afterwards:

php composer.phar install

Composer installation

Alternatively to the above method you can just run the following:

php composer.phar require gadoma/walmart-api-php-client:^1.0

Usage

Walmart API key

In order to use the Walmart Open API you need to obtain an API key. You can get it by registering a Walmart developer account.

Basic usage

// composer autoload
require 'vendor/autoload.php';

//API credentials
$apiKey = 'yourWalmartApiKey';

//Basic components used by the Services
$httpClient        = new \GuzzleHttp\Client();
$errorHandler      = new \WalmartApiClient\Exception\Handler\ApiExceptionHandler();
$transportService  = new \WalmartApiClient\Http\TransportService($httpClient, $errorHandler, $apiUrl);
$entityFactory     = new \WalmartApiClient\Factory\EntityFactory();
$collectionFactory = new \WalmartApiClient\Factory\CollectionFactory();

//Actual Services you will use for interacting with the API
$productService  = new \WalmartApiClient\Service\ProductService($transportService, $entityFactory, $collectionFactory);
$offerService    = new \WalmartApiClient\Service\OfferService($transportService, $entityFactory, $collectionFactory);
$reviewService   = new \WalmartApiClient\Service\ReviewService($transportService, $entityFactory, $collectionFactory);
$taxonomyService = new \WalmartApiClient\Service\TaxonomyService($transportService, $entityFactory, $collectionFactory);

LinkShare Publisher Id

It is possible to provide your LinkShare Publisher Id for URL tracking/attribution purposes. It is optional and you can read more about this subject on Walmart Affiliates website. To use your LinkShare Publisher Id with this library, just pass it to TransportService constructor in the process of creating the basic components, like shown below:

$apiKey = 'yourWalmartApiKey';
$linkSharePublisherId = 'yourId';

$httpClient        = new \GuzzleHttp\Client();
$errorHandler      = new \WalmartApiClient\Exception\Handler\ApiExceptionHandler();
$transportService  = new \WalmartApiClient\Http\TransportService($httpClient, $errorHandler, $apiUrl, $linkSharePublisherId);

Features

Each of the available Services is a wrapper for one or more Walmart Open API services. The available methods' declarations and descriptions can be found in the Service interfaces. Each of the methods returns either a single specific Entity (e.g. Product) or a Collection of Entities (e.g. Categories Collection).

Product service

Integrates with

Available methods

  • getById
  • getByUpc
  • getByIds
  • getBySearch
  • getAllBySearch
  • getPostbrowsedById
  • getRecommendedById
  • getTrending

Offer service

Integrates with

Available methods

  • getVod
  • getPreorder
  • getBestsellers
  • getRollback
  • getClearance
  • getSpecialbuy

Review service

Integrates with

Available methods

  • getReviews

Store service

Integrates with

Available methods

  • getStoresByCoordinates
  • getStoresByCity
  • getStoresByZip

Taxonomy service

Integrates with

Available methods

  • getCategories