public function testIterator() { $rawTemplates = ['user' => [['id' => 1, 'name' => 'template1'], ['id' => 2, 'name' => 'template2']], 'gallery' => [['id' => 3, 'name' => 'template3']]]; $expected = [['origin_id' => 1, 'name' => 'template1', 'type' => 'user'], ['origin_id' => 2, 'name' => 'template2', 'type' => 'user'], ['origin_id' => 3, 'name' => 'template3', 'type' => 'gallery']]; $this->client->expects($this->once())->method('getTemplates')->with($this->isType('array'))->will($this->returnValue($rawTemplates)); $actual = []; foreach ($this->iterator as $key => $value) { $actual[$key] = $value; } $this->assertEquals($expected, $actual); }
/** * {@inheritdoc} */ public function initIterator() { $templatesList = (array) $this->client->getTemplates($this->parameters); $this->iterator = new \CallbackFilterIterator(new FlattenIterator($templatesList, 'type', false), function (&$current) { if (is_array($current)) { $current['origin_id'] = $current['id']; unset($current['id']); } return true; }); }
/** * Read one line from export response, if read success converts line to associative array according to export data * format. * * @return array|null */ protected function read() { if (!$this->body) { $response = $this->client->export($this->methodName, $this->parameters); $this->body = $response->getBody(); $this->body->seek(0); if ($this->useFirstLineAsHeader) { $line = $this->getLineData(); if ($line) { $this->header = $line; } } } return $this->getResponseItem(); }
/** * @link http://apidocs.mailchimp.com/api/2.0/lists/static-segment-members-del.php * * @param array $args * * @return array */ public function deleteStaticSegmentMembers(array $args) { return $this->client->deleteStaticSegmentMembers($args); }