jplarar/enviapaqueteria-bundle

A simple Symfony2 bundle for Envia API.

2.1.0 2020-09-04 16:33 UTC

This package is auto-updated.

Last update: 2024-04-04 23:58:32 UTC


README

A simple Symfony2 bundle for the API for Envia Paqueteria API.

Setup

Step 1: Download JplararEnviapaqueteriaBundle using composer

Add SES Bundle in your composer.json:

{
    "require": {
        "jplarar/enviapaqueteria-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update "jplarar/enviapaqueteria-bundle"

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Jplarar\EnviapaqueteriaBundle\EnviapaqueteriaBundle()
    );
}

Step 3: Add configuration

# app/config/config.yml
jplarar_enviapaqueteria:
        enviapaqueteria_keys:
              enviapaqueteria_user:    %enviapaqueteria_user%
              enviapaqueteria_password: %enviapaqueteria_password%
              enviapaqueteria_environment: %enviapaqueteria_environment% # 'prod' or 'dev'

Usage

Using service

<?php
        $enviapaqueteriaClient = $this->get('enviapaqueteria_client');
?>

##Example

###Generate Quote

<?php 
    $quotes = $enviapaqueteriaClient->quote(
                    $origin = [
                        "representative" => "Origen test",
                        "company" => "Origen Empresa",
                        "email" => "correo@pruebas.com",
                        "phone" => "8111234567",
                        "country" => "MX",
                        "address1" => "av vasconcelos",
                        "address2" => "1400",
                        "addressExtra" => "enfrente de office depot",
                        "zipCode" => "66240"
                    ], 
                    $destination = [
                        "representative" => "Destino test",
                        "company" => "Origen Empresa",
                        "email" => "correo@pruebas.com",
                        "phone" => "8111234567",
                        "country" => "MX",
                        "address1" => "av vasconcelos",
                        "address2" => "1400",
                        "addressExtra" => "enfrente de office depot",
                        "zipCode" => "66240"
                    ], 
                    $options = [
                        "content" => "vestido",
                        "insurance" => 0,
                        "value" => "",
                        "height" => 10,
                        "width" => 10,
                        "length" => 10,
                        "weight" => 2,
                        "amount" => 1,
                        "collection" => null,
                        "collection_time" => "",
                        "collection_time_limit" => "",
                        "collection_date" => ""
                    ]
            );
            
    $shipping = $enviapaqueteriaClient->create(
                    $provider = [
                        "name" => "fedex",
                        "service" => "FEDEX_EXPRESS_SAVER"   
                     ],
                    $origin = [
                        "representative" => "Origen test",
                        "company" => "Origen Empresa",
                        "email" => "correo@pruebas.com",
                        "phone" => "8111234567",
                        "country" => "MX",
                        "address1" => "av vasconcelos",
                        "address2" => "1400",
                        "addressExtra" => "enfrente de office depot",
                        "zipCode" => "66240"
                    ], 
                    $destination = [
                        "representative" => "Destino test",
                        "company" => "Origen Empresa",
                        "email" => "correo@pruebas.com",
                        "phone" => "8111234567",
                        "country" => "MX",
                        "address1" => "av vasconcelos",
                        "address2" => "1400",
                        "addressExtra" => "enfrente de office depot",
                        "zipCode" => "66240"
                    ], 
                    $options = [
                        "content" => "vestido",
                        "insurance" => 0,
                        "value" => "",
                        "height" => 10,
                        "width" => 10,
                        "length" => 10,
                        "weight" => 2,
                        "amount" => 1,
                        "collection" => null,
                        "collection_time" => "",
                        "collection_time_limit" => "",
                        "collection_date" => "",
                        "file" => "PDF",
                        "paper" => "PAPER_7X4.75",
                    ]
                );
?>