Skip to content

buzyka/printful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Printful

INSTALLATION

Repository should be cloned to the local machine with already installed composer.

Then, go to the working directory run composer install command

composer install

COMPONENTS

app\Cache - implementation of caching mechanism app\Printful - implementation of printful API-client app\Printful\Method\ShippingRate - implementation Shipping Rate method

test - php unit tests

HOW TO USE?

Example using implemented Shipping rate with cache mechanism:

require_once __DIR__ . '/vendor/autoload.php';

// Crate and set folder for cache storage
$cacheStorage = __DIR__ . '/tmp';
if (!is_dir($cacheStorage)){
    mkdir($cacheStorage);
}

// Declare API Key
$apiKey = '77qn9aax-qrrm-idki:lnh0-fm2nhmp0yca7';

// Initialize method instance and set cache
$shippingRate = new \App\Printful\Method\ShippingRate(
    $apiKey,
    \App\Cache\AppCache::init('File', ['storage' => $cacheStorage])
);

// Define request details
$shippingRate->address = '11025 Westlake Dr';
$shippingRate->city = 'Charlotte';
$shippingRate->countryCode = 'US';
$shippingRate->stateCode = 'NC';
$shippingRate->zip = '28273';
$shippingRate->addItem(7679, 2);

// Print response
print_r($shippingRate->calculate());

PHP UNIT TESTS

Running all tests

php ./vendor/bin/phpunit tests

Running Shipping rate tests

php ./vendor/bin/phpunit tests/Printful/Method/ShippingRateTest.php

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages