예제 #1
0
 /**
  * Gets connector from array
  *
  * @param array $item
  * @return Connector
  */
 protected function getConnectorObject(array $item)
 {
     $object = new Connector();
     $object->setId($this->getStr($item, 'id'));
     $object->setName($this->getVal($item, 'name'));
     $object->setType($this->getVal($item, 'type'));
     $object->setDescription($this->getVal($item, 'description'));
     $object->setCategory($this->getVal($item, 'category'));
     $object->setCategories($this->getVal($item, 'categories'));
     $object->setUrl($this->getVal($item, 'url'));
     $object->setCompatibleComponents($this->getVal($item, 'compatible_components'));
     $object->setLogoUrls($this->getVal($item, 'logo_urls'));
     $object->setImageUrls($this->getVal($item, 'image_urls'));
     $object->setRankingLevel($this->getVal($item, 'ranking_level'));
     $object->setLanguages($this->getVal($item, 'languages'));
     if (!empty($item['meta'])) {
         $meta = new ConnectorMeta();
         if (!empty($item['meta']['solved_problems'])) {
             $solvedProblems = [];
             foreach ($item['meta']['solved_problems'] as $problem) {
                 $solvedProblems[] = new ConnectorMetaProblem($this->getVal($problem, 'question'), $this->getVal($problem, 'answer'));
             }
             $meta->setSolvedProblems($solvedProblems);
         }
         $meta->setTargetRevenue($this->getVal($item['meta'], 'target_revenue'));
         $meta->setTargetAvgOrderValue($this->getVal($item['meta'], 'target_avg_order_value'));
         $meta->setTargetTransactions($this->getVal($item['meta'], 'target_transactions'));
         $meta->setTargetCountries($this->getVal($item['meta'], 'target_countries'));
         $meta->setEffortIntegration($this->getVal($item['meta'], 'effort_integration'));
         $meta->setEffortMaintenance($this->getVal($item['meta'], 'effort_maintenance'));
         if (isset($item['meta']['pricing_free_trial'])) {
             $meta->setPricingFreeTrial($item['meta']['pricing_free_trial']);
         }
         $meta->setPricingContractLength($this->getVal($item['meta'], 'pricing_contract_length'));
         $meta->setPricingPriceInfo($this->getVal($item['meta'], 'pricing_price_info'));
         $meta->setMonthlyPrice($this->getVal($item['meta'], 'monthly_price'));
         $meta->setYearlyPrice($this->getVal($item['meta'], 'yearly_price'));
         $meta->setCurrency($this->getVal($item['meta'], 'currency'));
         $meta->setAvailableSince($this->getVal($item['meta'], 'available_since'));
         $meta->setOrigin($this->getVal($item['meta'], 'origin'));
         $object->setMeta($meta);
     }
     return $object;
 }
예제 #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;
 }