Skip to content

Commit

Permalink
Add Contatos namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mrprompt committed Dec 22, 2020
1 parent 5eadd4c commit 6506ca0
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/Contatos/Imobiliarias.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
namespace ImovelWeb\Contatos;

use ImovelWeb\Base\Base;

final class Imobiliarias extends Base
{
/**
* Todas as mensagens para um anúncio.
*
* @param int $imobiliaria
* @param int $anuncio
* @return mixed
*/
public function mensagensAnuncio(int $imobiliaria, int $anuncio)
{
return $this->request('GET', "imobiliarias/{$imobiliaria}/anuncios/{$anuncio}/mensagens");
}

/**
* Todas as mensagens para uma imobiliária.
*
* @param int $imobiliaria
* @return mixed
*/
public function mensagensImobiliaria(int $imobiliaria)
{
return $this->request('GET', "imobiliarias/{$imobiliaria}/mensagens");
}

/**
* Informação de um contato.
*
* @param int $imobiliaria
* @param int $contato
* @return mixed
*/
public function contatos(int $imobiliaria, int $contato)
{
return $this->request('GET', "imobiliarias/{$imobiliaria}/contatos/{$contato}");
}
}
27 changes: 27 additions & 0 deletions src/Contatos/Mensagem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace ImovelWeb\Contatos;

use ImovelWeb\Base\Base;

final class Mensagem extends Base
{
/**
* O smartLead de uma mensagem.
*
* @return mixed
*/
public function smartLead(int $id)
{
return $this->request('GET', "mensagen/{$id}/smartLead");
}

/**
* Uma mensagem pelo ID.
*
* @return mixed
*/
public function visualizar(int $id)
{
return $this->request('GET', "mensagens/{$id}");
}
}
1 change: 0 additions & 1 deletion src/Imobiliarias/Imobiliarias.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace ImovelWeb\Imobiliarias;

use GuzzleHttp\Exception\ClientException;
use ImovelWeb\Base\Base;

final class Imobiliarias extends Base
Expand Down
74 changes: 74 additions & 0 deletions tests/Contatos/ImobiliariasTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
namespace ImovelWeb\Tests\Contatos;

use GuzzleHttp\Psr7\Response;
use ImovelWeb\Contatos\Imobiliarias;
use ImovelWeb\Tests\Base\Base;

final class ImobiliariasTest extends Base
{
/**
* @test
*/
public function imobiliariasMensagensAnuncio()
{
$handleResponse = $this->fixture(__FUNCTION__, 'Responses');
$handlerStack = [new Response(200, [], $handleResponse)];

$this->client = $this->getClient($handlerStack);
$this->service = new Imobiliarias($this->client);

$result = $this->service->mensagensAnuncio(
$this->faker->randomNumber(4),
$this->faker->randomNumber(4)
);

$this->assertArrayHasKey('content', $result);
$this->assertArrayHasKey('number', $result);
$this->assertArrayHasKey('size', $result);
$this->assertArrayHasKey('total', $result);
}

/**
* @test
*/
public function imobiliariasMensagensImobiliaria()
{
$handleResponse = $this->fixture(__FUNCTION__, 'Responses');
$handlerStack = [new Response(200, [], $handleResponse)];

$this->client = $this->getClient($handlerStack);
$this->service = new Imobiliarias($this->client);

$result = $this->service->mensagensImobiliaria(
$this->faker->randomNumber(4),
$this->faker->randomNumber(4)
);

$this->assertArrayHasKey('content', $result);
$this->assertArrayHasKey('number', $result);
$this->assertArrayHasKey('size', $result);
$this->assertArrayHasKey('total', $result);
}

/**
* @test
*/
public function imobiliariasContatos()
{
$handleResponse = $this->fixture(__FUNCTION__, 'Responses');
$handlerStack = [new Response(200, [], $handleResponse)];

$this->client = $this->getClient($handlerStack);
$this->service = new Imobiliarias($this->client);

$result = $this->service->contatos(
$this->faker->randomNumber(4),
$this->faker->randomNumber(4)
);

$this->assertArrayHasKey('cuestionarios', $result);
$this->assertArrayHasKey('idContacto', $result);
$this->assertArrayHasKey('smartlead', $result);
}
}
53 changes: 53 additions & 0 deletions tests/Contatos/MensagemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
namespace ImovelWeb\Tests\Contatos;

use GuzzleHttp\Psr7\Response;
use ImovelWeb\Contatos\Mensagem;
use ImovelWeb\Tests\Base\Base;

final class MensagemTest extends Base
{
/**
* @test
*/
public function mensagemSmartLead()
{
$handleResponse = $this->fixture(__FUNCTION__, 'Responses');
$handlerStack = [new Response(200, [], $handleResponse)];

$this->client = $this->getClient($handlerStack);
$this->service = new Mensagem($this->client);

$result = $this->service->smartLead($this->faker->randomNumber(4));

$this->assertArrayHasKey('codigoMensaje', $result);
$this->assertArrayHasKey('mensaje', $result);
$this->assertArrayHasKey('smartlead', $result);
}

/**
* @test
*/
public function mensagemVisualizar()
{
$handleResponse = $this->fixture(__FUNCTION__, 'Responses');
$handlerStack = [new Response(200, [], $handleResponse)];

$this->client = $this->getClient($handlerStack);
$this->service = new Mensagem($this->client);

$result = $this->service->visualizar($this->faker->randomNumber(4));

$this->assertArrayHasKey('codigoAviso', $result);
$this->assertArrayHasKey('email', $result);
$this->assertArrayHasKey('fecha', $result);
$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('idAvisoNavplat', $result);
$this->assertArrayHasKey('idContacto', $result);
$this->assertArrayHasKey('idContactoAccion', $result);
$this->assertArrayHasKey('idMensaje', $result);
$this->assertArrayHasKey('nombre', $result);
$this->assertArrayHasKey('telefono', $result);
$this->assertArrayHasKey('textoMensaje', $result);
}
}
64 changes: 64 additions & 0 deletions tests/Contatos/Responses/imobiliariasContatos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"cuestionarios": [
{
"cuestionario": [
{
"pregunta": "string",
"respuesta": "string"
}
],
"tipoOperacion": "string"
}
],
"idContacto": 0,
"smartlead": {
"ambientes": {
"max": 0,
"min": 0
},
"antiguedad": {
"max": 0,
"min": 0
},
"banios": {
"max": 0,
"min": 0
},
"cantidadAvisosVistos": 0,
"contactos": 0,
"empezoABuscarHaceXDias": 0,
"habitaciones": {
"max": 0,
"min": 0
},
"porcentajeAvisosConExpensas": 0,
"porcentajeAvisosConGarage": 0,
"precio": {
"max": 0,
"min": 0,
"moneda": "string"
},
"rangoDeExpensas": {
"max": 0,
"min": 0
},
"superficieCubiertaXm2": {
"max": 0,
"min": 0
},
"superficieTotalXm2": {
"max": 0,
"min": 0
},
"tipoDeBusqueda": {
"operacion": "string",
"tipoPropiedad": "string"
},
"ubicacionesContactadas": [
{
"nombre": "string",
"porcentajeDeContactos": 0
}
]
}
}
21 changes: 21 additions & 0 deletions tests/Contatos/Responses/imobiliariasMensagensAnuncio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"content": [
{
"codigoAviso": "string",
"email": "string",
"fecha": "2020-12-21T16:36:02.880Z",
"id": 0,
"idAvisoNavplat": 0,
"idContacto": 0,
"idContactoAccion": 0,
"idMensaje": 0,
"nombre": "string",
"telefono": "string",
"textoMensaje": "string"
}
],
"number": 0,
"size": 0,
"total": 0
}

20 changes: 20 additions & 0 deletions tests/Contatos/Responses/imobiliariasMensagensImobiliaria.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"content": [
{
"codigoAviso": "string",
"email": "string",
"fecha": "2020-12-21T16:36:02.887Z",
"id": 0,
"idAvisoNavplat": 0,
"idContacto": 0,
"idContactoAccion": 0,
"idMensaje": 0,
"nombre": "string",
"telefono": "string",
"textoMensaje": "string"
}
],
"number": 0,
"size": 0,
"total": 0
}
54 changes: 54 additions & 0 deletions tests/Contatos/Responses/mensagemSmartLead.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"codigoMensaje": "string",
"mensaje": "string",
"smartlead": {
"ambientes": {
"max": 0,
"min": 0
},
"antiguedad": {
"max": 0,
"min": 0
},
"banios": {
"max": 0,
"min": 0
},
"cantidadAvisosVistos": 0,
"contactos": 0,
"empezoABuscarHaceXDias": 0,
"habitaciones": {
"max": 0,
"min": 0
},
"porcentajeAvisosConExpensas": 0,
"porcentajeAvisosConGarage": 0,
"precio": {
"max": 0,
"min": 0,
"moneda": "string"
},
"rangoDeExpensas": {
"max": 0,
"min": 0
},
"superficieCubiertaXm2": {
"max": 0,
"min": 0
},
"superficieTotalXm2": {
"max": 0,
"min": 0
},
"tipoDeBusqueda": {
"operacion": "string",
"tipoPropiedad": "string"
},
"ubicacionesContactadas": [
{
"nombre": "string",
"porcentajeDeContactos": 0
}
]
}
}
13 changes: 13 additions & 0 deletions tests/Contatos/Responses/mensagemVisualizar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"codigoAviso": "string",
"email": "string",
"fecha": "2020-12-21T16:36:02.892Z",
"id": 0,
"idAvisoNavplat": 0,
"idContacto": 0,
"idContactoAccion": 0,
"idMensaje": 0,
"nombre": "string",
"telefono": "string",
"textoMensaje": "string"
}

0 comments on commit 6506ca0

Please sign in to comment.