Example #1
0
 public function testSendCustomersToRobin()
 {
     $this->markTestSkipped("This test hits the network, turn it on when you need to fully test the whole package");
     $seoShop = $this->getSeoshop();
     $robin = $this->getRobin();
     $customers = $seoShop->customers(['page' => 1, 'limit' => 1]);
     $robinCustomers = new Customers();
     foreach ($customers as $customer) {
         $date = $customer->createdAt;
         $robinCustomers->push(Customer::make($customer->email, $date, $customer->orders->count, $customer->orders->totalSpendFormatted(), Panel::make($customer->orders->count, $customer->orders->totalSpendFormatted())));
     }
     $result = $robin->customers($robinCustomers);
     $this->assertEquals("201", $result->getStatusCode());
 }
Example #2
0
 /**
  * @param null $id
  * @param array $options
  * @return Customers|\Robin\Connect\SEOShop\Models\Customer[]
  */
 public function customers($id = null, $options = [])
 {
     //reassign $id when it's an array
     if (is_array($id)) {
         list($id, $options) = [null, $id];
     }
     $customers = new Customers();
     if ($id == null) {
         foreach ($this->api->customers->get($id, $options) as $seoCustomer) {
             $customer = new SEOShopCustomer($this, $this->logger);
             $customers->push($customer->makeFromArray($seoCustomer));
         }
         return $customers;
     }
     $customer = $this->api->customers->get($id, $options);
     return (new SEOShopCustomer($this, $this->logger))->makeFromArray($customer);
 }
Example #3
0
 /**
  * @param $json
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function customers($json)
 {
     $customer = $this->customer->makeFromArray($json);
     $customers = Customers::make([$this->makeRobinCustomer($customer)]);
     try {
         return $this->robin->customers($customers);
     } catch (RobinSendFailedException $exception) {
         $this->error($customers, $exception, $customer);
         return new Response("", 500);
     }
 }
Example #4
0
 /**
  * @expectedException \Robin\Api\Exceptions\RobinSendFailedException
  */
 public function testThrowsExceptionWhenRequestFails()
 {
     $api = $this->getRealRobinClient();
     $api->customers(Customers::make(['this' => "should", 'trigger' => 'an', 'error']));
 }