Exemplo n.º 1
0
 /**
  * Gets link from array
  *
  * @param array $item
  * @return Link
  */
 protected function getLinkObject(array $item)
 {
     $object = new Link();
     $object->setId($this->getStr($item, 'id'));
     $object->setExpiresIn($this->getVal($item, 'expires_in'));
     if (is_array($item['connections'])) {
         $connections = [];
         foreach ($item['connections'] as $subItem) {
             $connection = new Connection();
             $connection->setId($this->getVal($subItem, 'id'));
             $connection->setConnectorId($this->getStr($subItem, 'connector_id'));
             $connection->setStatus($this->getVal($subItem, 'status'));
             $connections[] = $connection;
         }
         $object->setConnections($connections);
     }
     return $object;
 }
Exemplo n.º 2
0
 /**
  * Setup method
  */
 protected function setUp()
 {
     $this->identity = $this->getMockBuilder('Itembase\\ConnectAPI\\Service\\IdentityInterface')->getMockForAbstractClass();
     $this->identity->expects($this->any())->method('getAccessToken')->willReturn(self::ACCESS_TOKEN);
     $this->identity->expects($this->any())->method('getClientId')->willReturn(self::CLIENT_ID);
     $this->client = $this->getMockBuilder('GuzzleHttp\\ClientInterface')->getMockForAbstractClass();
     $this->serializer = \JMS\Serializer\SerializerBuilder::create()->build();
     $this->stream = $this->getMockBuilder('Psr\\Http\\Message\\StreamInterface')->getMockForAbstractClass();
     $this->response = $this->getMockBuilder('Psr\\Http\\Message\\ResponseInterface')->getMockForAbstractClass();
     $this->response->expects($this->any())->method('getBody')->willReturn($this->stream);
     $this->connect = new Connect($this->identity, Connect::URL_SANDBOX, $this->client);
     $this->clientOptions = ['verify' => false, 'timeout' => Connect::CLIENT_TIMEOUT, 'connect_timeout' => Connect::CLIENT_CONNECT_TIMEOUT, 'headers' => ['Content-Type' => 'application/json']];
     $this->clientOptionsClient = $this->clientOptions;
     $this->clientOptionsClient['headers']['X-IB-CLIENTID'] = self::CLIENT_ID;
     $this->clientOptionsToken = $this->clientOptions;
     $this->clientOptionsToken['headers']['Authorization'] = 'Bearer ' . self::ACCESS_TOKEN;
     $meta1 = new ConnectorMeta();
     $meta1->setSolvedProblems([new ConnectorMetaProblem('Every shop owner is looking for...', 'Channable is...')]);
     $meta1->setTargetRevenue(1000);
     $meta1->setTargetAvgOrderValue(20);
     $meta1->setTargetTransactions(200);
     $meta1->setTargetCountries(10);
     $meta1->setEffortIntegration('small');
     $meta1->setEffortMaintenance('medium');
     $meta1->setPricingFreeTrial(true);
     $meta1->setPricingContractLength('20 months');
     $meta1->setPricingPriceInfo('12 EUR in the first 12 months');
     $meta1->setMonthlyPrice(12);
     $meta1->setYearlyPrice(144);
     $meta1->setCurrency('EUR');
     $meta1->setAvailableSince('2014-01-01');
     $meta1->setOrigin('Berlin');
     $connector1 = new Connector();
     $connector1->setId('71229cde76d1959107b2abd40700e061f081dec9');
     $connector1->setName('Channable');
     $connector1->setType('solution');
     $connector1->setDescription('Channable is the perfect solution...');
     $connector1->setCategory('traffic');
     $connector1->setCategories(null);
     $connector1->setUrl('https://www.channable.com');
     $connector1->setCompatibleComponents(['d1857f4f8f21a99ccde55881403142fd4f7f91db', '07058bed713f86256857fbf0ee13bcb8e11b2130']);
     $connector1->setLogoUrls(['https://www.channable.com/wp-content/themes/channable/media/logo_channable.png']);
     $connector1->setImageUrls(['https://www.channable.de/wp-content/themes/channable/media/laptop.png']);
     $connector1->setRankingLevel('1');
     $connector1->setLanguages(['en']);
     $connector1->setMeta($meta1);
     $this->connectors[] = $connector1;
     $meta2 = new ConnectorMeta();
     $meta2->setSolvedProblems([new ConnectorMetaProblem('If?', 'Then...')]);
     $meta2->setTargetRevenue(1000);
     $meta2->setTargetAvgOrderValue(20);
     $meta2->setTargetTransactions(200);
     $meta2->setTargetCountries(10);
     $meta2->setEffortIntegration('small');
     $meta2->setEffortMaintenance('medium');
     $meta2->setPricingFreeTrial(false);
     $meta2->setPricingContractLength('12 months');
     $meta2->setPricingPriceInfo('10 EUR');
     $meta2->setMonthlyPrice(10);
     $meta2->setYearlyPrice(120);
     $meta2->setCurrency('EUR');
     $meta2->setAvailableSince('2016-01-01');
     $meta2->setOrigin('Berlin');
     $connector2 = new Connector();
     $connector2->setId('2');
     $connector2->setName('MySol');
     $connector2->setType('solution');
     $connector2->setDescription('MySol is...');
     $connector2->setCategory('traffic');
     $connector2->setCategories(null);
     $connector2->setUrl('https://www.mysol.com');
     $connector2->setCompatibleComponents([]);
     $connector2->setLogoUrls([]);
     $connector2->setImageUrls([]);
     $connector2->setRankingLevel(null);
     $connector2->setLanguages(['en']);
     $connector2->setMeta($meta2);
     $this->connectors[] = $connector2;
     $connection1 = new Connection();
     $connection1->setId('1234');
     $connection1->setConnectorId('1');
     $connection1->setStatus('ok');
     $this->connections[] = $connection1;
     $connection2 = new Connection();
     $connection2->setId('5678');
     $connection2->setConnectorId('2');
     $connection2->setStatus(null);
     $this->connections[] = $connection2;
     $this->meta = new ConnectionMeta();
     $this->meta->setDisplayName("Connection name");
     $link1 = new Link();
     $link1->setId('1');
     $link1->setExpiresIn(3600);
     $link1->setConnections([$this->connections[0]]);
     $this->links[] = $link1;
     $link2 = new Link();
     $link2->setId('2');
     $link2->setExpiresIn(60);
     $link2->setConnections([$this->connections[1]]);
     $this->links[] = $link2;
 }