<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';
use Chadicus\Marvel\Api\Client;
use Chadicus\Marvel\Api\Entities\Comic;
$publicApiKey = getenv('PUBLIC_KEY');
$privateApiKey = getenv('PRIVATE_KEY');
$client = new Client($privateApiKey, $publicApiKey);
//24 is the id of Bendis.  312 is the id of Deodato
$comics = Comic::findAll($client, ['dateDescriptor' => 'thisWeek']);
foreach ($comics as $comic) {
    echo str_repeat('=', 80) . PHP_EOL;
    echo "ID: {$comic->getId()}\n";
    echo "DIGITAL ID: {$comic->getDigitalId()}\n";
    echo "TITLE: {$comic->getTitle()}\n";
    echo "ISSUE NUMBER: {$comic->getIssueNumber()}\n";
    echo "VARIANT DESCRIPTION: {$comic->getVariantDescription()}\n";
    echo "DESCRIPTION: {$comic->getDescription()}\n";
    echo "MODIFIED: {$comic->getModified()->format('Y-m-d')}\n";
    echo "ISBN: {$comic->getIsbn()}\n";
    echo "UPC: {$comic->getUpc()}\n";
    echo "DIAMOND CODE: {$comic->getDiamondCode()}\n";
    echo "EAN: {$comic->getEan()}\n";
    echo "ISSN: {$comic->getIssn()}\n";
    echo "FORMAT: {$comic->getFormat()}\n";
    echo "PAGE COUNT: {$comic->getPageCount()}\n";
    echo "RESOURCE URI: {$comic->getResourceURI()}\n";
    echo 'TEXT OBJECTS (' . count($comic->getTextObjects()) . "):\n";
    foreach ($comic->getTextObjects() as $textObject) {
        echo "\tTYPE: {$textObject->getType()}\n";
        echo "\tLANGUAGE: {$textObject->getLanguage()}\n";
Example #2
0
 /**
  * Verify query parameters are set properly with findAll().
  *
  * @test
  * @covers ::findAll
  *
  * @return void
  */
 public function findAllParametersSetProperly()
 {
     $now = new \DateTime();
     $toDate = new \DateTime('-2 days');
     $fromDate = new \DateTime('-3 days');
     $criteria = ['noVariants' => true, 'hasDigitalIssue' => false, 'modifiedSince' => $now->format('r'), 'series' => [2, 4, 6], 'events' => [1, 3, 5], 'stories' => [7, 8, 9], 'characters' => [2, 3, 4], 'creators' => [5, 6, 7], 'toDate' => $toDate->format('r'), 'fromDate' => $fromDate->format('r')];
     $adapter = new ComicAdapter();
     $client = new Client('not under test', 'not under test', $adapter);
     $comics = Comic::findAll($client, $criteria);
     $comics->next();
     $expectedParameters = ['noVariants' => 'true', 'hasDigitalIssue' => 'false', 'modifiedSince' => $now->format('c'), 'series' => '2,4,6', 'events' => '1,3,5', 'stories' => '7,8,9', 'characters' => '2,3,4', 'creators' => '5,6,7', 'dateRange' => "{$fromDate->format('c')},{$toDate->format('c')}"];
     foreach ($expectedParameters as $key => $value) {
         $this->assertSame($value, $adapter->parameters[$key]);
     }
 }