Skip to content

A basic address validation bundle for Symfony2 using Deyde API

Notifications You must be signed in to change notification settings

enriquesomolinos/addressValidationBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DeydeDataQBundle (Deyde data quality bundle)

The DeydeDataQBundle adds support for the deyde data quality services. In this version only supports the address normalization service.

Installation

  1. Download DeydeDataQBundle
  2. Enable the Bundle

Step 1: Install DeydeDataQBundle with composer

Run the following composer require command:

$ php composer.phar require deyde/dataqbundle:dev-master

Step 2: Enable the bundle

Finally, enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Deyde\DataQBundle\DeydeDataQBundle(),
    );
}

Configuration

You will have to set your basic configuration to use de deyde services.

Minimal configuration

# app/config/config.yml
deyde_address_validation:
        deyde_user: test
        deyde_password: password

Where desde_user is your deyde user account and deyde_password is your account password.

Note: deyde_user and deyde_password are the only required configuration params.

Use behind a proxy

deyde_address_validation:
        deyde_user: test
        deyde_password: password
        proxy:
            address: ip_machine:port
            user: proxy_user
            password: proxy_pass

Note: use this configuration when you are behind a proxy.

Modify the Deyde base url

If Deyde changes their services host there's not problem. It's possible to change this via configuration file.

deyde_address_validation:
        deyde_user: test
        deyde_password: password
        deyde_base_url: https://deyde.es/

Note: by default, the url is https://ws.deyde.com.es/

Modify the address validation service url

If Deyde changes the address validation service url there's not problem. It's possible to change this via configuration file.

_deyde_address_validation:
        deyde_user: test
        deyde_password: password
        address_validation_service_url: deyde-autoCompletion/domicilio-nuevo

Note: by default, the url is deyde-autoCompletion/domicilio

Modify the product_list_parameter

The product list parameter determines what kind of products are selected.

By deafult its value is 'es,dom,cod'. You can change its value via configuration file.

deyde_address_validation:
        deyde_user: test
        deyde_password: password
        product_list_parameter: pt,dom,cod

Note: At this moment 'es,dom,cod' and 'pt,dom,cod' values are supported.

Complete Configuration File

Finally we show a complete configuration file, fully overwritten its values.

deyde_address_validation:
        deyde_user: test
        deyde_password: password
        deyde_base_url: https://ws.deyde.com.es/
        address_validation_service_url: deyde-autoCompletion/domicilio
        product_list_parameter: es,dom,cod
        proxy:
            address: ip_machine:port
            user: proxy_user
            password: proxy_pass

Use

service = $this->get('deyde_address_validation_service');
$service->validateAddress("Calle mayor 2 2800 madrid");

The most commond response is like follows:

{
  "codigoPoblacion" : "28079000000",
  "codigoPostal" : "28013",
  "codigoVia" : "2807903981",
  "indicadorDyf" : "4",
  "indicadorEstadoCodificacion" : "F",
  "indicadorEstadoFiabilidad" : "7",
  "mujeres" : 1712655,
  "municipio" : "MADRID",
  "nombreVia" : "MAYOR",
  "numeroVia" : "0002",
  "poblacion" : "MADRID",
  "provincia" : "MADRID",
  "restoVia" : "",
  "tipoVia" : "",
  "varones" : 1494592
}

Note:In case that Deyde service is down, the bundle throws a ServiceNotAvalaibleException.

Test

Test are under DeydeDataQBundle/test directory. Launch them is simple, just run the next command from DeydeDataQBundle/test directory:

phpunit --bootstrap bootstrap.php Deyde/Tests/DeydeAddressValidatorTest

About

A basic address validation bundle for Symfony2 using Deyde API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages