Skip to content

Commit cd2c527

Browse files
authored
Merge pull request #1 from answear/develop
Pickup point integration with Speedy.bg
2 parents 939c08e + 2a60245 commit cd2c527

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1602
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor/
2+
\.php_cs\.cache
3+
.phpunit.result.cache
4+
composer.lock
5+
/.idea

.php_cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(
5+
[
6+
'vendor',
7+
]
8+
)
9+
->in(__DIR__);
10+
11+
return PhpCsFixer\Config::create()
12+
->setRules(
13+
[
14+
'@Symfony' => true,
15+
'strict_param' => false,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'concat_space' => ['spacing' => 'one'],
18+
'phpdoc_align' => [],
19+
'phpdoc_summary' => false,
20+
'void_return' => false,
21+
'phpdoc_var_without_name' => false,
22+
'phpdoc_to_comment' => false,
23+
'single_line_throw' => false,
24+
]
25+
)
26+
->setFinder($finder);

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 answear.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Speedy.bg Bundle
2+
Speedy integration for Symfony.
3+
Documentation of the API can be found here: https://api.speedy.bg/web-api.html
4+
5+
## Installation
6+
7+
* install with Composer
8+
```
9+
composer require answear/speedy-pickup-point-bundle
10+
```
11+
12+
`Answear\SpeedyBundle\AnswearSpeedyBundle::class => ['all' => true],`
13+
should be added automatically to your `config/bundles.php` file by Symfony Flex.
14+
15+
## Setup
16+
17+
* provide required config data: `privateKey`
18+
19+
```yaml
20+
# config/packages/answear.yaml
21+
answear_speedy:
22+
username: 'your_username'
23+
password: 'your_password'
24+
language: 'BG'
25+
clientSystemId: 12345
26+
```
27+
28+
config will be passed to `\Answear\SpeedyBundle\ConfigProvider.php` class.
29+
30+
## Usage
31+
32+
### Find Office
33+
34+
```php
35+
use Answear\SpeedyBundle\Command\FindOffice;
36+
use Answear\SpeedyBundle\Request\FindOfficeRequest;
37+
38+
/** @var FindOffice $findOfficeCommand */
39+
$findOfficeResponse = $findOfficeCommand->findOffice(new FindOfficeRequest());
40+
```
41+
42+
43+
Final notes
44+
------------
45+
46+
Feel free to open pull requests with new features, improvements or bug fixes. The Answear team will be grateful for any comments.
47+

composer.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "answear/speedy-pickup-point-bundle",
3+
"description": "API Client for Speedy.bg.",
4+
"type": "symfony-bundle",
5+
"license": "MIT",
6+
"require": {
7+
"php": ">=7.4",
8+
"ext-json": "*",
9+
"guzzlehttp/guzzle": "^6.0",
10+
"marc-mabe/php-enum": "^3.0|^4.3",
11+
"symfony/http-kernel": "^4.4|^5.0",
12+
"symfony/serializer": "^4.4|^5.0",
13+
"webmozart/assert": "^1.3"
14+
},
15+
"require-dev": {
16+
"roave/security-advisories": "dev-master",
17+
"phpunit/phpunit": "^8.4",
18+
"symfony/phpunit-bridge": "^5.0",
19+
"phpro/grumphp": "^0.20",
20+
"friendsofphp/php-cs-fixer": "^2.16",
21+
"phpstan/phpstan": "^0.12.32",
22+
"phpstan/phpstan-webmozart-assert": "^0.12.2"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Answear\\SpeedyBundle\\": "src/"
27+
}
28+
},
29+
"autoload-dev": {
30+
"psr-4": {
31+
"Answear\\SpeedyBundle\\Tests\\": "tests/"
32+
}
33+
},
34+
"scripts": {
35+
"post-install-cmd": [
36+
"GrumPHP\\Composer\\DevelopmentIntegrator::integrate"
37+
],
38+
"post-update-cmd": [
39+
"GrumPHP\\Composer\\DevelopmentIntegrator::integrate"
40+
]
41+
},
42+
"extra": {
43+
"grumphp": {
44+
"config-default-path": "grumphp.yaml"
45+
}
46+
},
47+
"config": {
48+
"sort-packages": true
49+
}
50+
}

grumphp.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
grumphp:
2+
process_timeout: 120
3+
ascii:
4+
failed: ~
5+
succeeded: ~
6+
tasks:
7+
git_blacklist:
8+
keywords:
9+
- "die("
10+
- "var_dump("
11+
- "print_r("
12+
- "dump("
13+
- " dd("
14+
- "exit;"
15+
triggered_by: ["php"]
16+
git_commit_message:
17+
max_subject_width: 120
18+
phpcsfixer:
19+
allow_risky: true
20+
cache_file: ~
21+
config: './.php_cs'
22+
using_cache: true
23+
verbose: true
24+
phpstan:
25+
autoload_file: ~
26+
configuration: './phpstan.neon'
27+
level: 5
28+
force_patterns: []
29+
ignore_patterns: []
30+
triggered_by: ['php']

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
includes:
2+
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
3+
4+
parameters:
5+
level: 5
6+
paths:
7+
- %rootDir%/../../../src
8+
ignoreErrors:
9+
- message: '#.*NodeDefinition::children.*#'
10+
path: ./src/DependencyInjection
11+

phpunit.xml.dist

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
4+
bootstrap="./vendor/autoload.php"
5+
backupGlobals="false"
6+
beStrictAboutCoversAnnotation="true"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutTestsThatDoNotTestAnything="true"
9+
beStrictAboutTodoAnnotatedTests="true"
10+
colors="true"
11+
convertErrorsToExceptions="true"
12+
convertNoticesToExceptions="true"
13+
convertWarningsToExceptions="true"
14+
verbose="true"
15+
>
16+
<php>
17+
<ini name="error_reporting" value="-1"/>
18+
</php>
19+
20+
<testsuites>
21+
<testsuite name="Answear.com SpeedyBundle Test Suite">
22+
<directory>./tests</directory>
23+
</testsuite>
24+
</testsuites>
25+
26+
<listeners>
27+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
28+
</listeners>
29+
</phpunit>

src/AnswearSpeedyBundle.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\SpeedyBundle;
6+
7+
use Symfony\Component\HttpKernel\Bundle\Bundle;
8+
9+
class AnswearSpeedyBundle extends Bundle
10+
{
11+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\SpeedyBundle\Client;
6+
7+
use Answear\SpeedyBundle\ConfigProvider;
8+
use Answear\SpeedyBundle\Request\Request;
9+
10+
class AuthenticationDecorator
11+
{
12+
private ConfigProvider $configuration;
13+
14+
public function __construct(ConfigProvider $configuration)
15+
{
16+
$this->configuration = $configuration;
17+
}
18+
19+
public function decorate(Request $request): void
20+
{
21+
$request->setUserName($this->configuration->getUsername());
22+
$request->setPassword($this->configuration->getPassword());
23+
$request->setLanguage($this->configuration->getLanguage());
24+
$request->setClientSystemId($this->configuration->getClientSystemId());
25+
}
26+
}

0 commit comments

Comments
 (0)