Beispiel #1
0
 /**
  * Fetch profile details by business data
  *
  * @param Batch $batch The batch to add this to
  * @param string[] $parameters The parameters for request
  * @throws \Exception
  */
 public function fetchProfileDetailsByBusinessData(Batch $batch, $parameters)
 {
     if ($batch->hasBeenCommitted()) {
         throw new \Exception("Attempting to add task to a batch which has already been comitted!");
     }
     $parameters['batch-id'] = $batch->getBatchId();
     $this->api->post('/v4/ld/fetch-profile-details-by-business-data', $parameters);
 }
Beispiel #2
0
 /**
  * Create batch
  *
  * @param bool $stopJobOnError Should the batch be halted on error?
  * @throws \Exception
  */
 public function create($stopJobOnError = false)
 {
     $response = $this->api->post('/v4/batch', ['stop-on-job-error' => (int) $stopJobOnError]);
     if (!isset($response['success']) || !$response['success']) {
         throw new \Exception("Response was not successful.");
     }
     if (!isset($response['batch-id'])) {
         throw new \Exception("No batch ID found in response.");
     }
     $this->setBatchId($response['batch-id']);
 }
Beispiel #3
0
 public function send($title, $text, $from = NULL, $to, $parent_id = 0, $to_from = TRUE)
 {
     if (!is_array($to)) {
         $to = array($to);
     }
     if (!empty($to)) {
         if ($from !== NULL and $to_from === TRUE) {
             $to[] = $from;
         }
         $to = array_unique($to);
         $users = DB::select('id', 'email')->from('users')->where('id', 'IN', $to)->execute()->as_array('id', 'email');
         $message = Kses::filter($text, Kohana::$config->load('global')->get('allowed_html_tags'));
         $data = array('created_on' => date('Y-m-d H:i:s'), 'text' => $message, 'title' => $title, 'from_user_id' => $from);
         list($message_id, $rows) = DB::insert($this->table_name())->columns(array_keys($data))->values($data)->execute($this->_db);
         if ($message_id) {
             $insert = DB::insert('messages_users')->columns(array('status', 'user_id', 'message_id', 'parent_id'));
             foreach ($users as $id => $email) {
                 $insert->values(array('status' => self::STATUS_NEW, 'user_id' => (int) $id, 'message_id' => $message_id, 'parent_id' => (int) $parent_id));
                 self::clear_cache($id);
                 Observer::notify('send_message', (int) $id, $text);
             }
             $insert->execute($this->_db);
             if ($from !== NULL) {
                 Api::post('user-messages.mark_read', array('id' => $message_id, 'uid' => $from));
             }
             return $message_id;
         }
     }
     return FALSE;
 }
Beispiel #4
0
 public function get_list()
 {
     $this->get_get();
     $messages = $this->json['response'];
     $response_messages = array();
     foreach ($messages as $msg) {
         $msg = (object) $msg;
         if ($msg->is_read == Model_API_Message::STATUS_NEW) {
             Api::post('user-messages.mark_read', array('id' => $msg->id, 'uid' => Auth::get_id()));
         }
         $response_messages[] = (string) View::factory('messages/item')->set('message', (object) $msg);
     }
     $this->response($response_messages);
 }
Beispiel #5
0
 public function action_view()
 {
     $id = (int) $this->request->param('id');
     $user_id = Auth::get_id();
     $message = Api::get('user-messages.get_by_id', array('id' => $id, 'uid' => $user_id, 'fields' => 'author,title,is_read,created_on,text,is_starred'))->as_object();
     if (!$message->response) {
         throw new HTTP_Exception_404('Message not found');
     }
     if ($this->request->method() === Request::POST) {
         $this->auto_render = FALSE;
         $post = $this->request->post();
         $post['from_user_id'] = $user_id;
         $post['parent_id'] = $id;
         return $this->_send(Api::put('user-messages', $post), $id);
     }
     $read = Api::post('user-messages.mark_read', array('id' => $id, 'uid' => $user_id));
     $messages = Api::get('user-messages.get', array('uid' => $user_id, 'fields' => 'author,from_user_id,title,is_read,created_on,text,is_starred', 'pid' => $id))->as_object();
     $this->template->content = View::factory('messages/view', array('tpl' => View::factory('messages/item'), 'message' => $message->response, 'messages' => $messages->response, 'from_user' => ORM::factory('user', $message->response->from_user_id)));
     $this->set_title($message->response->title);
 }
Beispiel #6
0
<?php

error_reporting(E_ALL | E_STRICT);
include '../api.php';
$api = new Api('http://devapirn.loc/v1/');
$api->action('auth/signup');
$params = array('email' => '*****@*****.**', 'password' => 'password');
$api->params($params);
$api->raw();
$result = $api->post();
$api->debug(1);
print_r($result);
Beispiel #7
0
 /**
  *  Sends a reminder to sign to the user.
  *
  * @param string? $text     Optional, text to include in the reminder message.
  */
 public function remind($text = null)
 {
     $id = preg_replace("/[^A-Za-z0-9\\- ]/", '', $this->id);
     Api::post('signer/' . $id . '/send-reminder/', ['text' => $text]);
 }
<?php

require __DIR__ . '/credentials.php';
require __DIR__ . '/../facturama/Api.php';
$facturma = new Api(USER, PASSWORD);
$params = ["Address" => ["Street" => "St One ", "ExteriorNumber" => "15", "InteriorNumber" => "12", "Neighborhood" => "Lower Manhattan, ", "ZipCode" => "sample string 5", "Locality" => "sample string 6", "Municipality" => "sample string 7", "State" => "sample string 8", "Country" => "MX"], "Rfc" => "XEXX010101000", "Name" => "Test Test", "Email" => "*****@*****.**"];
$result = $facturma->post('Client', $params);
printf('<pre>%s<pre>', var_export($result, true));