/**
  * {@inheritdoc}
  *
  * @param LinkInterface $link   A link instance
  * @param string        $domain The domain to use, optional (bit.ly | j.mp | bitly.com)
  *
  * @throws InvalidApiResponseException
  */
 public function shorten(LinkInterface $link, $domain = null)
 {
     $client = $this->createClient();
     $request = $client->get(sprintf('/v3/shorten?access_token=%s&longUrl=%s&domain=%s', $this->auth->getAccessToken(), urlencode($link->getLongUrl()), $domain), array(), $this->options);
     $response = $this->validate($request->send()->getBody(true));
     $link->setShortUrl($response->data->url);
 }
 /**
  * {@inheritdoc}
  */
 public function shorten(LinkInterface $link)
 {
     $client = $this->createClient();
     $request = $client->post($this->getUri(), array('Content-Type' => 'application/json'), json_encode(array('longUrl' => $link->getLongUrl())), $this->options);
     $response = $this->validate($request->send()->getBody(true));
     $link->setShortUrl($response->id);
 }