/** * @dataProvider mockProvider * @param Templates $obj */ public function testGetAll($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(TemplatesTest::getJson())); $params = array(); $result = $obj->getAll($params, $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
/** * Retrieves the template information of the merchant. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Templates */ public static function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($params, 'params'); $payLoad = ""; $allowedParams = array('fields' => 1); $json = self::executeCall("/v1/invoicing/templates/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall); $ret = new Templates(); $ret->fromJson($json); return $ret; }
<?php use PayPal\Api\Templates; require 'CreateInvoiceTemplate.php'; try { $templates = Templates::getAll(array("fields" => "all"), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get all Templates", "Templates", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get all Templates", "Templates", null, null, $templates); return $templates;