Example #1
0
 public function updateUser($uid, $data)
 {
     $userData = $this->getUser($uid);
     unset($userData['accountSetting']['login']);
     unset($userData['accountSetting']['email']);
     unset($userData['accountSetting']['effectiveIpWhitelist']);
     $userData['accountSetting'] = array_merge($userData['accountSetting'], $data);
     $this->client->put("/gdc/account/profile/{$uid}", $userData);
 }
Example #2
0
 public function update($options = [])
 {
     $data = Client::put(static::endpoint() . '/' . $this->id(), $this->payload(), $options);
     if (count($data) > 0) {
         $data = json_decode($data, true);
     }
     return $this->parse($data);
 }
Example #3
0
 /**
  * assert that putting a fetched resource fails
  *
  * @param string $url    url
  * @param Client $client client to use
  *
  * @return void
  */
 public function assertPutFails($url, $client)
 {
     $client->request('GET', $url);
     $client->put($url, $client->getResults());
     $response = $client->getResponse();
     $this->assertEquals(405, $response->getStatusCode());
     $this->assertEquals('GET, HEAD, OPTIONS', $response->headers->get('Allow'));
 }
Example #4
0
 public function testHighFrequencyPut()
 {
     $this->subject->useTube('test');
     for ($i = 0; $i < 10000; $i++) {
         $this->subject->put(0, 0, 100, 'test' . $i);
     }
     $result = $this->subject->statsTube('test');
     $this->assertEquals(10000, $result['current-jobs-urgent']);
 }
Example #5
0
 /**
  * @param string $endpoint
  * @param array  $data
  * @param string $comment
  * @param array  $attachments
  *
  * @return array
  */
 private function update($endpoint, $data, $comment, $attachments)
 {
     if ($comment) {
         $data['comment'] = $comment;
     }
     foreach ($attachments as $index => $attachment) {
         $data['attachment-' . $index] = fopen($attachment, 'r');
     }
     return $this->client->put(sprintf('projects/%d/issues/%d/%s', $this->projectId, $this->id, $endpoint), $data);
 }
Example #6
0
 /**
  * Either create a new job in the provided queue with the provided attributes,
  * or move that job into that queue. If the job is being serviced by a worker,
  * subsequent attempts by that worker to either `heartbeat` or `complete` the
  * job should fail and return `false`.
  *
  * The `priority` argument should be negative to be run sooner rather than
  * later, and positive if it's less important. The `tags` argument should be
  * a JSON array of the tags associated with the instance and the `valid after`
  * argument should be in how many seconds the instance should be considered
  * actionable.
  *
  * @param string $klass     The class with the 'performMethod' specified in the data.
  * @param string $jid       specified job id, if false is specified, a jid will be generated.
  * @param mixed  $data      array of parameters for job.
  * @param int    $delay     specify delay to run job.
  * @param int    $retries   number of retries allowed.
  * @param bool   $replace   false to prevent the job from being replaced if it is already running
  * @param int    $priority  a greater priority will execute before jobs of lower priority
  * @param array  $resources a list of resource identifiers this job must acquire before being processed
  * @param float  $interval  the minimum number of seconds required to transpire before the next instance of this job can run
  * @param array  $tags
  * @param array  $depends   a list of JIDs this job must wait on before executing
  *
  * @return string|float the job identifier or the time remaining before the job expires if the job is already running
  */
 public function put($klass, $jid, $data, $delay = 0, $retries = 5, $replace = true, $priority = 0, $resources = [], $interval = 0.0, $tags = [], $depends = [])
 {
     return $this->client->put(null, $this->name, $jid ?: Qless::guidv4(), $klass, json_encode($data, JSON_UNESCAPED_SLASHES), $delay, 'priority', $priority, 'tags', json_encode($tags, JSON_UNESCAPED_SLASHES), 'retries', $retries, 'depends', json_encode($depends, JSON_UNESCAPED_SLASHES), 'resources', json_encode($resources, JSON_UNESCAPED_SLASHES), 'replace', $replace ? 1 : 0, 'interval', $interval);
 }
Example #7
0
<?php

/**
 * beanstalk: A minimalistic PHP beanstalk client.
 *
 * Copyright (c) 2009-2015 David Persson
 *
 * Distributed under the terms of the MIT License.
 * Redistributions of files must retain the above copyright notice.
 */
namespace Beanstalk;

/**
 * A small benchmark to test throughput.
 */
$host = getenv('TEST_BEANSTALKD_HOST');
$port = getenv('TEST_BEANSTALKD_PORT');
if (!$host || !$port) {
    throw new \RuntimeException('TEST_BEANSTALKD_HOST and/or TEST_BEANSTALKD_PORT env variables not defined.');
}
$connection = new Connection($host, $port, false);
if (!$connection->connect()) {
    throw new \RuntimeException("Unable to connect to a running beanstalkd server at {$host}:{$port}.");
}
$client = new Client($connection);
for ($i = 0; $i < 100000; $i++) {
    $client->put(1024, 0, 60, $i);
}
Example #8
0
 public function testPutEvent()
 {
     Client::relateIQ(GlobalVar::KEY, GlobalVar::SECRET);
     Client::endpoint('https://api.relateiq.com/v2/events');
     Client::headers(["Content-type" => "application/json", "Accept" => "application/json"]);
     $data = ["subject" => "Support Ticket #12345: How do I create an event?", "body" => "Just called Tim and walked him through how to create an event with the new API.\n-James.", "participantIds" => [["type" => "email", "value" => "*****@*****.**"], ["type" => "email", "value" => "*****@*****.**"], ["type" => "phone", "value" => "8001235555"]]];
     $res = Client::put('', $data, []);
     $this->assertEquals(204, $res->code);
 }
Example #9
0
 public function testResponseBody()
 {
     $client = new Client($this->testUrl);
     $client->get();
     $this->assertEquals('OK', $client->getStatusMessage());
     $client = new Client($this->testUrl);
     $client->post();
     $this->assertEquals('OK', $client->getStatusMessage());
     $client = new Client($this->testUrl);
     $client->put();
     $this->assertEquals('OK', $client->getStatusMessage());
     $client = new Client($this->testUrl);
     $client->patch();
     $this->assertEquals('OK', $client->getStatusMessage());
     $client = new Client($this->testUrl);
     $client->delete();
     $this->assertEquals('OK', $client->getStatusMessage());
     // TODO Why it gives OK?
     $client = new Client($this->testUrl);
     $client->head();
     //$this->assertEquals('', $client->getStatusMessage());
     $client = new Client($this->testUrl);
     $client->options();
     $this->assertEquals('OK', $client->getStatusMessage());
 }
Example #10
0
 public function update($options = [])
 {
     $data = (array) Client::put(self::endpoint(), static::payload(), $options);
     return $this;
 }
Example #11
0
 /**
  * Update the name of a company
  *
  * @param string $newName
  * @return array
  */
 public function updateName($newName)
 {
     return $this->client->put('companies/' . $this->id, ['company_name' => $newName]);
 }
Example #12
0
 /**
  * Tests a malfunctional server.
  */
 public function testPoolError()
 {
     $this->setExpectedException('\\Jyxo\\Webdav\\Exception');
     $client = new Client(array('127.0.0.1:5555'));
     $client->put($this->file, 'test');
 }