Completed
Push — master ( 9e09e5...ce4c72 )
by Joao
02:53
created
src/ByJG/WebService/BaseService.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -7,60 +7,60 @@
 block discarded – undo
7 7
  */
8 8
 abstract class BaseService
9 9
 {
10
-    protected $URL         = "http://www.byjg.com.br/site/webservice.php/ws/";
11
-    protected $_username   = "";
12
-    protected $_password   = "";
13
-    protected $_service    = "";
14
-    protected $_curlParams = [];
10
+	protected $URL         = "http://www.byjg.com.br/site/webservice.php/ws/";
11
+	protected $_username   = "";
12
+	protected $_password   = "";
13
+	protected $_service    = "";
14
+	protected $_curlParams = [];
15 15
 
16
-    /**
17
-     *
18
-     * @param string $username
19
-     * @param string $password
20
-     */
21
-    public function __construct($username, $password, $curlParams = [CURLOPT_TIMEOUT => 5])
22
-    {
23
-        $this->_username   = $username;
24
-        $this->_password   = $password;
25
-        $this->_curlParams = $curlParams;
26
-    }
16
+	/**
17
+	 *
18
+	 * @param string $username
19
+	 * @param string $password
20
+	 */
21
+	public function __construct($username, $password, $curlParams = [CURLOPT_TIMEOUT => 5])
22
+	{
23
+		$this->_username   = $username;
24
+		$this->_password   = $password;
25
+		$this->_curlParams = $curlParams;
26
+	}
27 27
 
28
-    protected function conectarServer($httpmethod, $params)
29
-    {
30
-        $params["httpmethod"] = $httpmethod;
31
-        $params["usuario"]    = $this->_username;
32
-        $params["senha"]      = $this->_password;
28
+	protected function conectarServer($httpmethod, $params)
29
+	{
30
+		$params["httpmethod"] = $httpmethod;
31
+		$params["usuario"]    = $this->_username;
32
+		$params["senha"]      = $this->_password;
33 33
 
34
-        $url = $this->URL . $this->_service;
34
+		$url = $this->URL . $this->_service;
35 35
 
36
-        $webRequest = new \ByJG\Util\WebRequest($url);
36
+		$webRequest = new \ByJG\Util\WebRequest($url);
37 37
 
38
-        foreach ($this->_curlParams as $param => $value) {
39
-            $webRequest->setCurlOption($param, $value);
40
-        }
38
+		foreach ($this->_curlParams as $param => $value) {
39
+			$webRequest->setCurlOption($param, $value);
40
+		}
41 41
 
42
-        $response = $webRequest->post($params);
42
+		$response = $webRequest->post($params);
43 43
 
44
-        $firstData = explode('|', $response);
45
-        $result    = array(
46
-            'status' => $firstData[0],
47
-            'raw'    => $response
48
-        );
44
+		$firstData = explode('|', $response);
45
+		$result    = array(
46
+			'status' => $firstData[0],
47
+			'raw'    => $response
48
+		);
49 49
 
50
-        if (isset($firstData[1])) {
51
-            $parsedData = explode(', ', $firstData[1]);
50
+		if (isset($firstData[1])) {
51
+			$parsedData = explode(', ', $firstData[1]);
52 52
 
53
-            if (!isset($parsedData[1])) {
54
-                $parsedData[0] = null;
55
-                $parsedData[1] = $firstData[1];
56
-            }
53
+			if (!isset($parsedData[1])) {
54
+				$parsedData[0] = null;
55
+				$parsedData[1] = $firstData[1];
56
+			}
57 57
 
58
-            $result['data'] = array(
59
-                "code" => $parsedData[0],
60
-                "info" => $parsedData[1]
61
-            );
62
-        }
58
+			$result['data'] = array(
59
+				"code" => $parsedData[0],
60
+				"info" => $parsedData[1]
61
+			);
62
+		}
63 63
 
64
-        return $result;
65
-    }
64
+		return $result;
65
+	}
66 66
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         $params["usuario"]    = $this->_username;
32 32
         $params["senha"]      = $this->_password;
33 33
 
34
-        $url = $this->URL . $this->_service;
34
+        $url = $this->URL.$this->_service;
35 35
 
36 36
         $webRequest = new \ByJG\Util\WebRequest($url);
37 37
 
Please login to merge, or discard this patch.
src/ByJG/WebService/Cep.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -13,97 +13,97 @@
 block discarded – undo
13 13
 class Cep extends BaseService
14 14
 {
15 15
 
16
-    /**
17
-     *
18
-     * @param string $username
19
-     * @param string $password
20
-     */
21
-    public function __construct($username, $password)
22
-    {
23
-        parent::__construct($username, $password);
24
-        $this->_service = "cep";
25
-    }
26
-
27
-    /**
28
-     * Obter a versão do WebService
29
-     * 
30
-     * @return string
31
-     */
32
-    public function obterVersao()
33
-    {
34
-        return $this->conectarServer("obterversao", array());
35
-    }
36
-
37
-    protected function parseCep($linha, $cep)
38
-    {
39
-        $inc = $cep ? 1 : 0;
40
-
41
-        $info   = explode(', ', $linha);
42
-        $result = array(
43
-            'logradouro' => str_replace('OK|', '', isset($info[0 + $inc]) ? $info[0 + $inc] : ""),
44
-            'bairro'     => isset($info[1 + $inc]) ? $info[1 + $inc] : "",
45
-            'cidade'     => isset($info[2 + $inc]) ? $info[2 + $inc] : "",
46
-            'uf'         => isset($info[3 + $inc]) ? $info[3 + $inc] : "",
47
-            'ibge'       => isset($info[4 + $inc]) ? $info[4 + $inc] : ""
48
-        );
49
-
50
-        if ($cep) {
51
-            $result['cep'] = $info[0];
52
-        }
53
-
54
-        return $result;
55
-    }
56
-
57
-    /**
58
-     * Obter o Logradouro à partir de um CEP
59
-     *
60
-     * @param string $cep
61
-     * @return string
62
-     */
63
-    public function obterLogradouro($cep)
64
-    {
65
-        $params = array(
66
-            "cep" => $cep
67
-        );
68
-
69
-        $result = $this->conectarServer("obterlogradouroauth", $params);
70
-        if ($result['status'] == 'OK') {
71
-            $result['data']['code'] = 0;
72
-
73
-            $result['data']['info'] = $this->parseCep($result['raw'], false);
74
-        }
75
-
76
-        return $result;
77
-    }
78
-
79
-    /**
80
-     * Retorna o CEP à partir do nome do logradouro, localidade e unidade federativa. Esse método requer autenticação de usuário. Se autenticado, retorna as 20 primeiras linhas encontradas.
81
-     *
82
-     * @param string $logradouro
83
-     * @param string $localidade
84
-     * @param string $uf
85
-     * @return string
86
-     */
87
-    public function obterCEP($logradouro, $localidade, $uf)
88
-    {
89
-        $params = array(
90
-            "logradouro" => $logradouro,
91
-            "localidade" => $localidade,
92
-            "UF"         => $uf
93
-        );
94
-
95
-        $result = $this->conectarServer("obtercepauth", $params);
96
-
97
-        if ($result["status"] == 'OK') {
98
-            $result['data']['code'] = 0;
99
-
100
-            $info                   = explode('|', $result['raw']);
101
-            $result['data']['info'] = array();
102
-            foreach (array_slice($info, 2) as $linha) {
103
-                $result['data']['info'][] = $this->parseCep($linha, true);
104
-            }
105
-        }
106
-
107
-        return $result;
108
-    }
16
+	/**
17
+	 *
18
+	 * @param string $username
19
+	 * @param string $password
20
+	 */
21
+	public function __construct($username, $password)
22
+	{
23
+		parent::__construct($username, $password);
24
+		$this->_service = "cep";
25
+	}
26
+
27
+	/**
28
+	 * Obter a versão do WebService
29
+	 * 
30
+	 * @return string
31
+	 */
32
+	public function obterVersao()
33
+	{
34
+		return $this->conectarServer("obterversao", array());
35
+	}
36
+
37
+	protected function parseCep($linha, $cep)
38
+	{
39
+		$inc = $cep ? 1 : 0;
40
+
41
+		$info   = explode(', ', $linha);
42
+		$result = array(
43
+			'logradouro' => str_replace('OK|', '', isset($info[0 + $inc]) ? $info[0 + $inc] : ""),
44
+			'bairro'     => isset($info[1 + $inc]) ? $info[1 + $inc] : "",
45
+			'cidade'     => isset($info[2 + $inc]) ? $info[2 + $inc] : "",
46
+			'uf'         => isset($info[3 + $inc]) ? $info[3 + $inc] : "",
47
+			'ibge'       => isset($info[4 + $inc]) ? $info[4 + $inc] : ""
48
+		);
49
+
50
+		if ($cep) {
51
+			$result['cep'] = $info[0];
52
+		}
53
+
54
+		return $result;
55
+	}
56
+
57
+	/**
58
+	 * Obter o Logradouro à partir de um CEP
59
+	 *
60
+	 * @param string $cep
61
+	 * @return string
62
+	 */
63
+	public function obterLogradouro($cep)
64
+	{
65
+		$params = array(
66
+			"cep" => $cep
67
+		);
68
+
69
+		$result = $this->conectarServer("obterlogradouroauth", $params);
70
+		if ($result['status'] == 'OK') {
71
+			$result['data']['code'] = 0;
72
+
73
+			$result['data']['info'] = $this->parseCep($result['raw'], false);
74
+		}
75
+
76
+		return $result;
77
+	}
78
+
79
+	/**
80
+	 * Retorna o CEP à partir do nome do logradouro, localidade e unidade federativa. Esse método requer autenticação de usuário. Se autenticado, retorna as 20 primeiras linhas encontradas.
81
+	 *
82
+	 * @param string $logradouro
83
+	 * @param string $localidade
84
+	 * @param string $uf
85
+	 * @return string
86
+	 */
87
+	public function obterCEP($logradouro, $localidade, $uf)
88
+	{
89
+		$params = array(
90
+			"logradouro" => $logradouro,
91
+			"localidade" => $localidade,
92
+			"UF"         => $uf
93
+		);
94
+
95
+		$result = $this->conectarServer("obtercepauth", $params);
96
+
97
+		if ($result["status"] == 'OK') {
98
+			$result['data']['code'] = 0;
99
+
100
+			$info                   = explode('|', $result['raw']);
101
+			$result['data']['info'] = array();
102
+			foreach (array_slice($info, 2) as $linha) {
103
+				$result['data']['info'][] = $this->parseCep($linha, true);
104
+			}
105
+		}
106
+
107
+		return $result;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
 
41 41
         $info   = explode(', ', $linha);
42 42
         $result = array(
43
-            'logradouro' => str_replace('OK|', '', isset($info[0 + $inc]) ? $info[0 + $inc] : ""),
44
-            'bairro'     => isset($info[1 + $inc]) ? $info[1 + $inc] : "",
45
-            'cidade'     => isset($info[2 + $inc]) ? $info[2 + $inc] : "",
46
-            'uf'         => isset($info[3 + $inc]) ? $info[3 + $inc] : "",
47
-            'ibge'       => isset($info[4 + $inc]) ? $info[4 + $inc] : ""
43
+            'logradouro' => str_replace('OK|', '', isset($info[0+$inc]) ? $info[0+$inc] : ""),
44
+            'bairro'     => isset($info[1+$inc]) ? $info[1+$inc] : "",
45
+            'cidade'     => isset($info[2+$inc]) ? $info[2+$inc] : "",
46
+            'uf'         => isset($info[3+$inc]) ? $info[3+$inc] : "",
47
+            'ibge'       => isset($info[4+$inc]) ? $info[4+$inc] : ""
48 48
         );
49 49
 
50 50
         if ($cep) {
Please login to merge, or discard this patch.
src/ByJG/WebService/Sms.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -13,117 +13,117 @@
 block discarded – undo
13 13
 class Sms extends BaseService
14 14
 {
15 15
 
16
-    /**
17
-     *
18
-     * @param string $username
19
-     * @param string $password
20
-     */
21
-    public function __construct($username, $password, $curlParams = [CURLOPT_TIMEOUT => 5])
22
-    {
23
-        parent::__construct($username, $password, $curlParams);
24
-        $this->_service = "sms";
25
-    }
16
+	/**
17
+	 *
18
+	 * @param string $username
19
+	 * @param string $password
20
+	 */
21
+	public function __construct($username, $password, $curlParams = [CURLOPT_TIMEOUT => 5])
22
+	{
23
+		parent::__construct($username, $password, $curlParams);
24
+		$this->_service = "sms";
25
+	}
26 26
 
27
-    /**
28
-     * Obter a versão do WebService
29
-     *
30
-     * @return string
31
-     */
32
-    public function obterVersao()
33
-    {
34
-        return $this->conectarServer("obterversao", array());
35
-    }
27
+	/**
28
+	 * Obter a versão do WebService
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function obterVersao()
33
+	{
34
+		return $this->conectarServer("obterversao", array());
35
+	}
36 36
 
37
-    /**
38
-     * Enviar um SMS
39
-     *
40
-     * @param string $ddd
41
-     * @param string $celular
42
-     * @param string $mensagem
43
-     * @return string
44
-     */
45
-    public function enviarSMS($ddd, $celular, $mensagem)
46
-    {
47
-        $params = array(
48
-            "ddd"      => $ddd,
49
-            "celular"  => $celular,
50
-            "mensagem" => utf8_encode($mensagem)
51
-        );
37
+	/**
38
+	 * Enviar um SMS
39
+	 *
40
+	 * @param string $ddd
41
+	 * @param string $celular
42
+	 * @param string $mensagem
43
+	 * @return string
44
+	 */
45
+	public function enviarSMS($ddd, $celular, $mensagem)
46
+	{
47
+		$params = array(
48
+			"ddd"      => $ddd,
49
+			"celular"  => $celular,
50
+			"mensagem" => utf8_encode($mensagem)
51
+		);
52 52
 
53
-        return $this->conectarServer("enviarsms", $params);
54
-    }
55
-    //
53
+		return $this->conectarServer("enviarsms", $params);
54
+	}
55
+	//
56 56
 
57
-    /**
58
-     * Envia SMS para um lista.
59
-     * Os números da lista deve ter o seguinte formato: DDPPPPNNNN Onde DD é o DDD, PPPPNNNN é o número do celular.
60
-     *
61
-     * @param array $lista
62
-     * @param strign $mensagem
63
-     * @return string
64
-     */
65
-    public function enviarListaSMS($lista, $mensagem)
66
-    {
67
-        $params = array(
68
-            "lista"    => implode('|', $lista),
69
-            "mensagem" => $mensagem
70
-        );
57
+	/**
58
+	 * Envia SMS para um lista.
59
+	 * Os números da lista deve ter o seguinte formato: DDPPPPNNNN Onde DD é o DDD, PPPPNNNN é o número do celular.
60
+	 *
61
+	 * @param array $lista
62
+	 * @param strign $mensagem
63
+	 * @return string
64
+	 */
65
+	public function enviarListaSMS($lista, $mensagem)
66
+	{
67
+		$params = array(
68
+			"lista"    => implode('|', $lista),
69
+			"mensagem" => $mensagem
70
+		);
71 71
 
72
-        return $this->conectarServer("enviarListaSMS", $params);
73
-    }
72
+		return $this->conectarServer("enviarListaSMS", $params);
73
+	}
74 74
 
75
-    /**
76
-     * Agenda o envio de SMS.
77
-     * Data no formato YYYY/MM/DD.
78
-     * Hora no formato HH:MM.
79
-     * Periodo: Unidade de Repeticao (H - Horas, D - Dias).
80
-     * Frequencia: O intervalo em 'periodos' entre as repetições.
81
-     * Repeticoes: número de vezes a repetir o envio. Deixar vazio periodo, frequencia e repeticoes caso não queira repeticoes.
82
-     *
83
-     * @param string $ddd
84
-     * @param string $celular
85
-     * @param string $mensagem
86
-     * @param string $data
87
-     * @param string $hora
88
-     * @param string $periodo
89
-     * @param int $frequencia
90
-     * @param int $repeticoes
91
-     * @return string
92
-     */
93
-    public function agendarEnvio($ddd, $celular, $mensagem, $data, $hora, $periodo = "", $frequencia = "",
94
-        $repeticoes = "")
95
-    {
96
-        $params = array(
97
-            "ddd"        => $ddd,
98
-            "celular"    => $celular,
99
-            "mensagem"   => utf8_encode($mensagem),
100
-            "data"       => $data,
101
-            "hora"       => $hora,
102
-            "periodo"    => $periodo,
103
-            "frequencia" => $frequencia,
104
-            "repeticoes" => $repeticoes
105
-        );
75
+	/**
76
+	 * Agenda o envio de SMS.
77
+	 * Data no formato YYYY/MM/DD.
78
+	 * Hora no formato HH:MM.
79
+	 * Periodo: Unidade de Repeticao (H - Horas, D - Dias).
80
+	 * Frequencia: O intervalo em 'periodos' entre as repetições.
81
+	 * Repeticoes: número de vezes a repetir o envio. Deixar vazio periodo, frequencia e repeticoes caso não queira repeticoes.
82
+	 *
83
+	 * @param string $ddd
84
+	 * @param string $celular
85
+	 * @param string $mensagem
86
+	 * @param string $data
87
+	 * @param string $hora
88
+	 * @param string $periodo
89
+	 * @param int $frequencia
90
+	 * @param int $repeticoes
91
+	 * @return string
92
+	 */
93
+	public function agendarEnvio($ddd, $celular, $mensagem, $data, $hora, $periodo = "", $frequencia = "",
94
+		$repeticoes = "")
95
+	{
96
+		$params = array(
97
+			"ddd"        => $ddd,
98
+			"celular"    => $celular,
99
+			"mensagem"   => utf8_encode($mensagem),
100
+			"data"       => $data,
101
+			"hora"       => $hora,
102
+			"periodo"    => $periodo,
103
+			"frequencia" => $frequencia,
104
+			"repeticoes" => $repeticoes
105
+		);
106 106
 
107
-        return $this->conectarServer("agendarEnvio", $params);
108
-    }
107
+		return $this->conectarServer("agendarEnvio", $params);
108
+	}
109 109
 
110
-    /**
111
-     * Obter os recursos disponíveis para envio de SMS
112
-     *
113
-     * @return string
114
-     */
115
-    public function recursos()
116
-    {
117
-        return $this->conectarServer("recursos", array());
118
-    }
110
+	/**
111
+	 * Obter os recursos disponíveis para envio de SMS
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public function recursos()
116
+	{
117
+		return $this->conectarServer("recursos", array());
118
+	}
119 119
 
120
-    /**
121
-     * Obter a quantidade de créditos disponíveis para envio de SMS
122
-     *
123
-     * @return string
124
-     */
125
-    public function creditos()
126
-    {
127
-        return $this->conectarServer("creditos", array());
128
-    }
120
+	/**
121
+	 * Obter a quantidade de créditos disponíveis para envio de SMS
122
+	 *
123
+	 * @return string
124
+	 */
125
+	public function creditos()
126
+	{
127
+		return $this->conectarServer("creditos", array());
128
+	}
129 129
 }
Please login to merge, or discard this patch.