Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Merge 49f4049 into 578ef0b
Browse files Browse the repository at this point in the history
  • Loading branch information
ravanscafi committed Sep 4, 2017
2 parents 578ef0b + 49f4049 commit 0849374
Show file tree
Hide file tree
Showing 39 changed files with 1,315 additions and 1,559 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
@@ -0,0 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/phpunit.xml export-ignore
/tests export-ignore
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
vendor/*
build
vendor
composer.lock
9 changes: 4 additions & 5 deletions .travis.yml
@@ -1,16 +1,15 @@
language: php

php:
- 5.4
- 5.5
- 7.0
- 7.1

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev
- composer install

script:
- mkdir -p build/logs
- phpunit -c phpunit.xml.dist
- phpunit --coverage-clover=build/logs/clover.xml

after_script:
- php vendor/bin/coveralls -v
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at gguitte@leroymerlin.com.br. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2014-2017 Leroy Merlin Brasil

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
97 changes: 48 additions & 49 deletions README.md
@@ -1,70 +1,69 @@
Laravel Axado API
=================

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/?branch=master)
[![Coverage Status](https://coveralls.io/repos/leroy-merlin-br/laravel-axado-api/badge.png?branch=master)](https://coveralls.io/r/leroy-merlin-br/laravel-axado-api?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/badges/build.png?b=master)](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/build-status/master)
[![Build Status](https://travis-ci.org/leroy-merlin-br/laravel-axado-api.svg)](https://travis-ci.org/leroy-merlin-br/laravel-axado-api)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/?branch=master) [![Coverage Status](https://coveralls.io/repos/leroy-merlin-br/laravel-axado-api/badge.png?branch=master)](https://coveralls.io/r/leroy-merlin-br/laravel-axado-api?branch=master) [![Build Status](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/badges/build.png?b=master)](https://scrutinizer-ci.com/g/leroy-merlin-br/laravel-axado-api/build-status/master) [![Build Status](https://travis-ci.org/leroy-merlin-br/laravel-axado-api.svg)](https://travis-ci.org/leroy-merlin-br/laravel-axado-api) [![StyleCI](https://styleci.io/repos/24239026/shield?branch=master)](https://styleci.io/repos/24239026)

A wrapper to Axado API.

## Get started

Add this package into your `composer.json`.
A wrapper to Axado API.

> "leroy-merlin-br/laravel-axado-api" : "~1.0"
## Instalation

Run `composer update`
To get started, install Laravel Axado API via the Composer package manager:

> composer update
```bash
composer require leroy-merlin-br/laravel-axado-api
```

## Setup

### Uses in your class VolumeTrait and VolumeInterface

For example:

class Stub implements Axado\Volume\VolumeInterface {
use Axado\Volume\VolumeTrait;

public function getSku() { return "123"; }
public function getQuantity() { return 10; }
public function getPriceUnit() { return 10.5; }
public function getHeight() { return 10; }
public function getLength() { return 10; }
public function getWidth() { return 10; }
public function getWeight() { return 10; }
}


### Setting the Token API.

Make your `Product` class implement `VolumeInterface`.
Optionally, you can use `VolumeTrait` too. For example:

```php
class Product implements Axado\Volume\VolumeInterface {
use Axado\Volume\VolumeTrait;

public function getSku() { return "123"; }
public function getQuantity() { return 10; }
public function getPriceUnit() { return 10.5; }
public function getHeight() { return 10; }
public function getLength() { return 10; }
public function getWidth() { return 10; }
public function getWeight() { return 10; }
}
```

## Usage

- Setting the Token API.
```php
\Axado\Shipping::$token = "your-token";
```

### Creating a new Shipping

$shipping = new Axado\Shipping;

- Creating a new Shipping
```php
$shipping = new Axado\Shipping();
$shipping->setPostalCodeOrigin('04661100');
$shipping->setPostalCodeDestination('13301430');
$shipping->setTotalPrice('40');
$shipping->setAditionalDays('10');
$shipping->setAditionalPrice('12.6');

### Adding Volume
$shipping->setAdditionalDays('10');
$shipping->setAdditionalPrice('12.6');
```

$volume = new Stub;
- Adding Volume
```php
$volume = new Product();
$shipping->addVolume($volume);
```

### Getting all quotations

- Getting all quotations
```php
$shipping->quotations();
```

### Get costs and deadline

$shipping->getCosts(); // in reais
$shipping->getDeadline(); // in days

### Marking the last quotation as contracted

$shipping->flagAsContracted();
- Getting costs and deadline
```php
$shipping->getCosts(); // in reais
$shipping->getDeadline(); // in days
```
24 changes: 15 additions & 9 deletions composer.json
@@ -1,7 +1,7 @@
{
"name": "leroy-merlin-br/laravel-axado-api",
"description": "A consumer for axado API.",
"keywords": ["axado","laravel","shipping", "brazil", "laravel","illuminate"],
"description": "A consumer for Axado API.",
"keywords": ["axado","laravel","shipping","brazil","cep","quotation","frete","brasil"],
"license": "MIT",
"authors": [
{
Expand All @@ -19,15 +19,21 @@
],
"autoload": {
"psr-4": {
"Axado\\" : "src/LeroyMerlin/Axado"
},
"classmap": [
"tests/TestCase.php"
]
"Axado\\" : "src"
}
},
"autoload-dev": {
"psr-4": {
"Axado\\" : "tests"
}
},
"require": {
"php": ">=7.0",
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.2",
"mockery/mockery": "dev-master",
"mockery/mockery": "^0.9",
"phpunit/phpunit": "^6.0",
"satooshi/php-coveralls": "dev-master"
},
"config": {
Expand Down
58 changes: 0 additions & 58 deletions example.php

This file was deleted.

8 changes: 7 additions & 1 deletion phpunit.xml
Expand Up @@ -12,7 +12,13 @@
>
<testsuites>
<testsuite>
<directory suffix=".php">./tests/LeroyMerlin/Axado</directory>
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
22 changes: 0 additions & 22 deletions phpunit.xml.dist

This file was deleted.

9 changes: 9 additions & 0 deletions src/Exception/DestinationNotFoundException.php
@@ -0,0 +1,9 @@
<?php
namespace Axado\Exception;

/**
* Exception thrown when Axado request does not find given destination CEP.
*/
class DestinationNotFoundException extends ShippingException
{
}
9 changes: 9 additions & 0 deletions src/Exception/OriginNotFoundException.php
@@ -0,0 +1,9 @@
<?php
namespace Axado\Exception;

/**
* Exception thrown when Axado request does not find given origin CEP.
*/
class OriginNotFoundException extends ShippingException
{
}
10 changes: 10 additions & 0 deletions src/Exception/QuotationNotFoundException.php
@@ -0,0 +1,10 @@
<?php
namespace Axado\Exception;

/**
* Exception to throw when Axado request do not returns a quotation for the
* given CEP.
*/
class QuotationNotFoundException extends ShippingException
{
}
Expand Up @@ -3,5 +3,6 @@

use Exception;

class ShippingException extends Exception {
class ShippingException extends Exception
{
}

0 comments on commit 0849374

Please sign in to comment.