/** * Test executing requests to Beepsend API */ public function testExecute() { $connector = \Mockery::mock(new Curl()); $connector->shouldReceive('call')->withAnyArgs()->once()->andReturn(array('info' => array('http_code' => 200, 'Content-Type' => 'application/json'), 'response' => json_encode(array('msg' => 'Welcome to Beepsend!')))); $request = new Request('SomeSecretToken', $connector); $response = $request->execute('/'); $this->assertEquals('Welcome to Beepsend!', $response['msg']); }
/** * Upload contacts stored in a csv file to some group * @param string $file Path to csv file * @param int $groupId Group id * @link http://api.beepsend.com/docs.html#contacts-upload More informations about file formating * @return array */ public function upload($file, $groupId) { if (!file_exists($file)) { throw new FileNotFound('File you are trying to upload doesn\'t exists!'); } /* Read file data */ $data = file_get_contents($file); $response = $this->request->upload($this->actions['groups'] . $groupId . $this->actions['upload'], $data); return $response; }
/** * Search for groups * @param string $query Will search entries with matching name * @return array */ public function groups($query) { $data = array('query' => $query); $response = $this->request->execute($this->actions['groups'], 'GET', $data); return $response; }
/** * Recive list of recipient numbers which can receive mobile originated messages * @return array */ public function recipientNumbers() { $response = $this->request->execute($this->actions['numbers'], 'GET'); return $response; }
/** * Compare pricelist revisions from given connection and return their diff as csv file. * @param int $revision1 * @param int $revision2 * @param midex $connection * @return array */ public function downloadDiff($revision1, $revision2, $connection) { $response = $this->request->download($connection . '.csv', $this->actions['pricelists'] . $connection . '/' . $revision1 . '..' . $revision2 . $this->actions['diff'] . '.csv', 'GET'); return $response; }
/** * Get customer data * @return array */ public function get() { $response = $this->request->execute($this->actions['data'], 'GET'); return $response; }
/** * Delete external email for notifications to wallet. * @param int $walletId Wallet id * @param int $emailId Email id * @return array */ public function deleteNotificationEmail($walletId, $emailId) { $response = $this->request->execute($this->actions['wallets'] . $walletId . $this->actions['notifications'] . $emailId, 'DELETE'); return $response; }
/** * Validate HLR request * @param int $msisdn Msisdn that we are looking HLR request * @param string $connection Connection id * @return array */ public function validate($msisdn, $connection = 'me') { $response = $this->request->execute($this->actions['validate'], 'POST', array('msisdn' => $msisdn, 'connection' => $connection)); return $response; }
/** * After changing your phone number. An SMS will be sent out asking you to verify the change. Use the unique hash to verify. * @param string $hash * @return array */ public function verifyPhone($hash) { $response = $this->request->execute($this->actions['users'] . $this->actions['phone'] . '/' . $hash, 'GET'); return $response; }
/** * List all messages sent back and forth in to a single contact/number. * @param string $id * @return array */ public function fullConversation($id, $options = array()) { $response = $this->request->execute($this->actions['conversations'] . $id, 'GET', $options); return $response; }