Code Monkey home page Code Monkey logo

frenet-php's Introduction

Frenet PHP SDK

This is the official PHP SDK for Integration with Frenet API.

Build Status Codacy Badge Codacy Badge

About

This is the official SDK (Software Development Kit) for Frenet API. This SDK is intended to help with PHP systems and Frenet API.

Installation

Installing using composer

To install using composer you'll need to have composer installed on your computer so you will be able to install this SDK into your project easily.

Once you have composer installed you just need to require this SDK:

> composer require frenet/frenet-php

Usage

To start using this SDK into your PHP system is really simple. Take a look in the example right below on how it's really easy to use:

<?php

/**
 * First we need to require the composer autoloader.
 */
require_once './vendor/autoload';

/**
 * This is your token from FRENET API.
 */
$token = '<YOUR TOKEN COMES RIGHT HERE>';

/** @var \Frenet\ApiInterface $api */
$api = \Frenet\ApiFactory::create($token);

/**
 * Here we will create a quote request for sending to API.
 * 
 * @var \Frenet\Command\Shipping\QuoteInterface $quote
 */
$quote = $api->shipping()->quote()
    ->setRecipientCountry('BR')
    ->setSellerPostcode('13015300')
    ->setRecipientPostcode('04011060')
    ->setShipmentInvoiceValue(100.87)
    ->addShippingItem('CWZ_75673_P', 1, 2.1, 14, 20, 15, 'Accessories')
    ->addShippingItem('CWZ_75673_F', 1, 2.1, 14, 20, 17, 'Accessories');

/**
 * The method `execute()` sends the request and parse the body result to a object type.
 * 
 * @var \Frenet\ObjectType\Entity\Shipping\QuoteInterface $result 
 */
$result = $quote->execute();
$services = $result->getShippingServices();

/** @var Frenet\ObjectType\Entity\Shipping\Quote\ServiceInterface $service */
foreach ($services as $service) {
    $price        = $service->getShippingPrice();
    $carrier      = $service->getCarrier();
    $deliveryTime = $service->getDeliveryTime();
    $responseTime = $service->getResponseTime();
    
    /** Do anything you want with this quotation. */
}

frenet-php's People

Contributors

tiagosampaio avatar jbohme avatar ivanaugustobd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.