public function testSubscriptions() { $sub = array(); $drop = Dropio_Drop::instance()->save(); for ($a = 0; $a < TEST_ITERATIONS; $a++) { $subscription = Dropio_Drop_Subscription::instance($drop)->set('type', 'pingback')->set('url', 'http://example.org/' . md5($a))->save(); $sub[$subscription->id] = $a; } $i = 0; $page = 1; while (($subscriptions = $drop->getSubscriptions($page)) && $subscriptions->getCount()) { foreach ($subscriptions as $subscription) { $i = $sub[$subscription->id]; $this->assertEquals('http://example.org/' . md5($i), $subscription->url); $this->assertEquals('pingback', $subscription->type); } $page++; } }
/** * Writes the subscription to the API. * * @return Dropio_Drop_Subscription */ function save() { $this->values['token'] = $this->drop->token(); $result = $this->drop->dropio_api->request('POST', 'drops/' . $this->drop->name . '/subscriptions', $this->values); return Dropio_Drop_Subscription::instance($this->drop)->loadFromArray($result); }
/** * Returns a Dropio_Asset_Set of assets. * * @param integer $page * @return Dropio_Drop */ function getSubscriptions($page = 1) { $result = $this->dropio_api->request('GET', 'drops/' . $this->name . '/subscriptions', array('page' => $page, 'token' => $this->token(), 'order' => $order)); $subscriptions = array(); foreach ($result['subscriptions'] as $subscription_array) { $subscription = new Dropio_Drop_Subscription($this); $subscriptions[$subscription_array['id']] = $subscription->loadFromArray($subscription_array); } return new Dropio_Drop_Subscription_Set($subscriptions, $result['total'], $result['page'], $result['per_page'], 'id'); }