blob: ce7135cd06385b669c0ff521405d1f98d0b9657f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<?php
/**
* Contains code related to web services support.
*
* @file
* @author Niklas Laxström
* @license GPL-2.0+
*/
/**
* Mutable objects that represents a HTTP(S) query.
* NB: Too lazy to make TranslationQueryFactory to make this class immutable.
* @since 2015.02
*/
class TranslationQuery {
protected $url;
protected $timeout = 0;
protected $method = 'GET';
protected $params = array();
protected $body;
// URL is mandatory, so using it here
public static function factory( $url ) {
$obj = new TranslationQuery();
$obj->url = $url;
return $obj;
}
/**
* Make this a POST request with given data.
*
* @param string $data
* @return $this
*/
public function postWithData( $data ) {
$this->method = 'POST';
$this->body = $data;
return $this;
}
public function queryParamaters( array $params ) {
$this->params = $params;
return $this;
}
public function timeout( $timeout ) {
$this->timeout = $timeout;
return $this;
}
public function getTimeout() {
return $this->timeout;
}
public function getUrl() {
return $this->url;
}
public function getMethod() {
return $this->method;
}
public function getQueryParameters() {
return $this->params;
}
public function getBody() {
return $this->body;
}
}
|