Skip to content

Commit

Permalink
feat: v0.2.0 stable
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-sanjuan committed Oct 21, 2019
0 parents commit 3a04cb5
Show file tree
Hide file tree
Showing 220 changed files with 26,527 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/docs export-ignore
/tests export-ignore
/.* export-ignore
/phpunit.xml.dist export-ignore
/docker-compose.yml export-ignore
/infection.* export-ignore
/Jenkinsfile export-ignore
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @LinioIT/seller-center
26 changes: 26 additions & 0 deletions .github/mergeable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
mergeable:
- when: pull_request.*
validate:
- do: label
must_exclude:
regex: do-not-merge/blocked
- do: title
must_exclude:
regex: /\[?wip\]?:?/i
- do: label
must_exclude:
regex: do-not-merge/work-in-progress
pass:
- do: checks
status: success
payload:
title: The PR is ready to be merged.
summary: The pull request is ready to be merged.
fail:
- do: checks
status: failure
payload:
title: The PR is not ready to be merged.
summary: The pull request is not ready to be merged.

13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
vendor/
.phpunit/
infection.log
.php_cs
.php_cs.cache
phpunit.xml
.idea/
.phpstan.neon
reports/
.php_cs
.idea/
.idea/workspace.xml
.docker
42 changes: 42 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'increment_style' => ['style' => 'post'],
'is_null' => ['use_yoda_style' => false],
'list_syntax' => ['syntax' => 'short'],
'method_argument_space' => ['ensure_fully_multiline' => true],
'method_chaining_indentation' => true,
'modernize_types_casting' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'phpdoc_align' => false,
'phpdoc_order' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'return_assignment' => true,
'single_line_comment_style' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
'void_return' => true,
'single_blank_line_at_eof' => true
])
->setFinder($finder)
->setUsingCache(true)
->setRiskyAllowed(true);
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: php

php:
- 7.3

before_script:
- composer install --no-interaction

script:
- vendor/bin/php-cs-fixer fix --dry-run -v
- vendor/bin/phpstan analyse
- vendor/bin/phpunit --verbose
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Changelog
===================


Unreleased
----------------------



Changelog v0.2.0 (2019-09-02)
----------------------

### Added

* Request and response logs in the managers
* Shipment manager into the sdk to get the shipment providers from seller center
* jsonSerialize into models
* `Product::fromSku` to use when only the images will be updated
* Product remove feature into the product manager
* `getFailureReasons` into the Orders manager
* Supports multiple status for a single order
* `Images::addManyFromString` to add multiple images using their url

### Fixed
* Feed manager. Now its checks the right object
* `extraAttributes` in orders. Now `extraAttributes` its processed as a `string`
* Uninitialized collection for orders
* The category behavior when it contains commas

### Changed

* Manager's return array. Now its return a clean array by use array_values
* The product constructor. `new Product` was replaced by `Product::fromBasicData`
* The `addImage` parameters. Now a simple array it's supported
* `Brand::fromProduct` method. Now its called `Brand::fromName`
* `Brand::fromBrand` method. Now its called `Brand::build`
* `Orders::fromOrders` method. Not its called `Orders::fromData`
* `Orders::fromOrderItems` method. Not its called `Orders::fromItems`
* `Orders::getStatus` method. Not its called `Orders::getStatuses`
* `Orders::getStatuses`. Instead to return an string, now return an array with all the statuses


Changelog [v0.1.0](https://github.com/LinioIT/seller-center-sdk/releases/tag/v0.1.0) (2019-04-24)
----------------------

Initial Release

45 changes: 45 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
application = "seller-center-sdk"

pipeline {
agent any

stages {
stage("Build") {
steps {
parallel(
"Configure": {
sh "mkdir -p reports"
},

"PHP": {
sh "composer install"
}
)
}
}

stage("Test") {
steps {
parallel(
"php-cs-fixer": {
sh "php vendor/bin/php-cs-fixer fix --dry-run -vv --format=junit > reports/php-cs-fixer.xml"
},

"phpunit": {
sh "php vendor/bin/phpunit --log-junit reports/phpunit.xml"
},

"phpstan": {
sh "php vendor/bin/phpstan analyse"
}
)
}
}
}

post {
always {
junit "reports/**/*.xml"
}
}
}
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2015, Bazaya México, S de RL de C.V.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Linio Input nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Seller Center PHP SDK
=====================
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)


Installation
------------

The recommended way to install the SDK is [through composer](http://getcomposer.org)

Edit your composer.json to add the repository URL:

{
"repositories": [
{
"type": "vcs",
"url": "[email protected]:LinioIT/seller-center-sdk.git"
}
]
}

Then require the package:

$ composer require linio/seller-center-SDK

Quick start
-----

### Configuration

To interact with the Seller Center platform you need to ask for a UserID and API KEY and know the URL and version of the service you'll consume.

Those values will be used through a `Configuration` object as follows.

```php
$configuration = new \Linio\SellerCenter\Application\Configuration('api-key-provided', 'api-username-provided', 'https://enviroment-seller-center-api.com', '1.0');
```

### Accessing the functionalities

All the interaction with the platform will be guided through the SDK class **SellerCenterSdk**. To create it you need to provide a specific configuration and an *HTTP Client*.

```php
$client = new \GuzzleHttp\Client();

$configuration = new \Linio\SellerCenter\Application\Configuration('api-key-provided', 'api-username-provided', 'https://enviroment-seller-center-api.com', '1.0');

$sdk = new \Linio\SellerCenter\SellerCenterSdk($configuration, $client);
```

One you have the SDK instance you can access to all the functionalities group in a series of managers.

```php
$result = $sdk->manager()->getSome();
```

If you want to retrieve all the available brands in Seller Center, you just need to use the Brand manager as follows:

```php
$brandList = $sdk->brands()->getBrands();
```

### Knowing the managers

Here is a list of the actual managers in the SDK:

- [BrandManager](docs/Managers/Brand.md)
- [CategoryManager](docs/Managers/Category.md)
- [DocumentManager](docs/Managers/Document.md)
- [FeedManager](docs/Managers/Feed.md)
- [OrderManager](docs/Managers/Order.md)
- [ProductManager](docs/Managers/Product.md)
- [QualityControlManager](docs/Managers/QcStatus.md)


### Logging

The SDK accept a Logging interface that will use to register every request and response through your application and
Seller Center in DEBUG mode.

```php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('myLogger');
$logger->pushHandler(new StreamHandler(__DIR__.'/sdk-log.log'));

$sellerCenterSdk = new SellerCenterSdk($configuration, $client, $logger);
```

Be very careful by using the SDK in debug mode, it will increase the size of log files very quickly. If you need to register every response, we recommend adding multiple log handlers.


```php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('myLogger');
$logger->pushHandler(new StreamHandler(__DIR__.'/sdk-log.log', Logger::INFO));
$logger->pushHandler(new StreamHandler(__DIR__.'/sdk-log-debug.log', Logger::DEBUG));

$sellerCenterSdk = new SellerCenterSdk($configuration, $client, $logger);
```

### Contributing

Feel free to send your contributions as a PR. Make sure to fulfill the followings items.

* [Commit standards](docs/Contribute/Standards.md)
* [PSR-2](https://www.php-fig.org/psr/psr-2/)
* [Tests](docs/Contribute/Tests.md)
Loading

0 comments on commit 3a04cb5

Please sign in to comment.