From 47d981fb3698ff0b50ea8c1b36ae6e286c12b45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A1ngel?= Date: Fri, 12 Jul 2024 12:00:56 -0300 Subject: [PATCH] actualizado (#11) * :rocket: :rocket: * Fix styling --- .github/ISSUE_TEMPLATE/bug.yml | 100 +++++++++--------- .github/dependabot.yml | 9 +- .github/workflows/dependabot-auto-merge.yml | 7 +- .../workflows/fix-php-code-style-issues.yml | 3 +- .github/workflows/run-tests.yml | 20 +++- .github/workflows/update-changelog.yml | 7 +- README.md | 13 ++- composer.json | 10 +- phpunit.xml.dist | 58 ++++------ pint.json | 20 +++- src/Exceptions/GenericException.php | 6 +- src/MeliServices.php | 19 ++-- tests/ExampleTest.php | 2 + tests/Pest.php | 2 + 14 files changed, 145 insertions(+), 131 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index a9933e1..1d8a026 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -3,56 +3,56 @@ description: Report an Issue or Bug with the Package title: "[Bug]: " labels: ["bug"] body: - - type: markdown - attributes: - value: | - We're sorry to hear you have a problem. Can you help us solve it by providing the following details. - - type: textarea - id: what-happened - attributes: - label: What happened? - description: What did you expect to happen? - placeholder: I cannot currently do X thing because when I do, it breaks X thing. - validations: - required: true - - type: textarea - id: how-to-reproduce - attributes: - label: How to reproduce the bug - description: How did this occur, please add any config values used and provide a set of reliable steps if possible. - placeholder: When I do X I see Y. - validations: - required: true - - type: input - id: package-version - attributes: - label: Package Version - description: What version of our Package are you running? Please be as specific as possible - placeholder: 2.0.0 - validations: - required: true - - type: input - id: php-version - attributes: - label: PHP Version - description: What version of PHP are you running? Please be as specific as possible - placeholder: 8.2.0 - validations: - required: true - - type: dropdown - id: operating-systems - attributes: - label: Which operating systems does with happen with? - description: You may select more than one. - multiple: true - options: + - type: markdown + attributes: + value: | + We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you expect to happen? + placeholder: I cannot currently do X thing because when I do, it breaks X thing. + validations: + required: true + - type: textarea + id: how-to-reproduce + attributes: + label: How to reproduce the bug + description: How did this occur, please add any config values used and provide a set of reliable steps if possible. + placeholder: When I do X I see Y. + validations: + required: true + - type: input + id: package-version + attributes: + label: Package Version + description: What version of our Package are you running? Please be as specific as possible + placeholder: 2.0.0 + validations: + required: true + - type: input + id: php-version + attributes: + label: PHP Version + description: What version of PHP are you running? Please be as specific as possible + placeholder: 8.2.0 + validations: + required: true + - type: dropdown + id: operating-systems + attributes: + label: Which operating systems does with happen with? + description: You may select more than one. + multiple: true + options: - macOS - Windows - Linux - - type: textarea - id: notes - attributes: - label: Notes - description: Use this field to provide any other notes that you feel might be relevant to the issue. - validations: - required: false + - type: textarea + id: notes + attributes: + label: Notes + description: Use this field to provide any other notes that you feel might be relevant to the issue. + validations: + required: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 30c8a49..39b1580 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,4 +9,11 @@ updates: schedule: interval: "weekly" labels: - - "dependencies" \ No newline at end of file + - "dependencies" + + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index eb537d8..c3ad22d 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -8,22 +8,23 @@ permissions: jobs: dependabot: runs-on: ubuntu-latest + timeout-minutes: 5 if: ${{ github.actor == 'dependabot[bot]' }} steps: - + - name: Dependabot metadata id: metadata uses: dependabot/fetch-metadata@v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - + - name: Auto-merge Dependabot PRs for semver-minor updates if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} run: gh pr merge --auto --merge "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - + - name: Auto-merge Dependabot PRs for semver-patch updates if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} run: gh pr merge --auto --merge "$PR_URL" diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 2a95712..56d54d3 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -11,10 +11,11 @@ permissions: jobs: php-code-styling: runs-on: ubuntu-latest + timeout-minutes: 5 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 26a3b77..7dccf9a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,22 +1,29 @@ name: Tests - -on: [pull_request] +on: + pull_request: + paths: + - '**.php' + - '.github/workflows/run-tests.yml' + - 'phpunit.xml.dist' + - 'composer.json' + - 'composer.lock' jobs: test: runs-on: ${{ matrix.os }} + timeout-minutes: 5 strategy: fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - php: [8.2, 8.1] + php: [8.3, 8.2, 8.1] stability: [prefer-lowest, prefer-stable] name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -33,5 +40,8 @@ jobs: - name: Install dependencies run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction + - name: List Installed Dependencies + run: composer show -D + - name: Execute tests - run: vendor/bin/pest + run: vendor/bin/pest --ci diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index 76e2f4d..39de30d 100644 --- a/.github/workflows/update-changelog.yml +++ b/.github/workflows/update-changelog.yml @@ -10,12 +10,13 @@ permissions: jobs: update: runs-on: ubuntu-latest + timeout-minutes: 5 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - ref: master + ref: main - name: Update Changelog uses: stefanzweifel/changelog-updater-action@v1 @@ -26,6 +27,6 @@ jobs: - name: Commit updated CHANGELOG uses: stefanzweifel/git-auto-commit-action@v5 with: - branch: master + branch: main commit_message: Update CHANGELOG file_pattern: CHANGELOG.md diff --git a/README.md b/README.md index 0cfbd3e..9dbc2b9 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ [![Total Downloads](https://img.shields.io/packagist/dt/tepuilabs/mini-meli.svg?style=flat-square)](https://packagist.org/packages/tepuilabs/payment-processors) -genera acces token de mercado libre. +Genera access token de mercado libre. -la idea de esto es poder generar access token para poder tener acceso a los recursos de Mercadolibre. +la idea de esto es poder generar access token para poder tener acceso a los recursos de Mercado libre. ### como usar @@ -31,13 +31,13 @@ agrega en tu archivo de cofiguración lo siguiente: GRANT_TYPE=authorization_code CLIENT_ID= CLIENT_SECRET= -REDIREC_URL=http://localhost:9000 +REDIRECT_URL=http://localhost:9000 ``` > **Note** -> estos datos los debes configurar en mercado libre cuando crees una applicación, los unicos datos que necesitas son el client id / secret +> estos datos los debes configurar en mercado libre cuando crees una aplicación, los unicos datos que necesitas son el client id / secret -luego necesitas configurar algo como lo siguiente: +Luego necesitas configurar algo como lo siguiente: ```php '', + 'grant_type' => '', // default authorization_code 'client_id' => '', 'code' => $_GET['code'], // from url 'client_secret' => '', @@ -55,5 +55,4 @@ $params = [ ]; $response = (new MeliServices($params))->generateAccessToken(); - ``` diff --git a/composer.json b/composer.json index 2c9cda1..d38b191 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,13 @@ } ], "require": { - "php": "^8.1", - "guzzlehttp/guzzle": "^7.7" + "php": "^8.2", + "guzzlehttp/guzzle": "^7.8.1" }, "require-dev": { - "pestphp/pest": "^1.20", - "laravel/pint": "^1.2", - "spatie/ray": "^1.28" + "laravel/pint": "^1.14", + "pestphp/pest": "^2.34.4", + "spatie/ray": "^1.41.1" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index af1f6c6..08742a2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/pint.json b/pint.json index 7f92ce5..24f09b9 100644 --- a/pint.json +++ b/pint.json @@ -1,10 +1,20 @@ { "preset": "laravel", "rules": { - "phpdoc_line_span": { - "property": "single", - "const": "single", - "method": "single" - } + "blank_line_before_statement": true, + "method_argument_space": true, + "single_trait_insert_per_statement": true, + "types_spaces": { + "space": "single" + }, + "declare_strict_types": true, + "align_multiline_comment": true, + "array_indentation": true, + "array_syntax": true, + "concat_space": { + "spacing": "one" + }, + "explicit_string_variable": true, + "fully_qualified_strict_types": true } } diff --git a/src/Exceptions/GenericException.php b/src/Exceptions/GenericException.php index 48c403e..0b4bc47 100644 --- a/src/Exceptions/GenericException.php +++ b/src/Exceptions/GenericException.php @@ -1,9 +1,9 @@ $this->params['grant_type'], + return $this->httpRequest([ + 'grant_type' => $this->params['grant_type'] ?? 'authorization_code', 'client_id' => $this->params['client_id'], 'code' => $this->params['code'], 'client_secret' => $this->params['client_secret'], 'redirect_uri' => $this->params['redirect_uri'], - ]; - - return $this->httpRequest($params); + ]); } /** - * Undocumented function + * make a http request to mercado libre api * * @throws GenericException|GuzzleException */ diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index 5d36321..57349d9 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -1,5 +1,7 @@ toBeTrue(); }); diff --git a/tests/Pest.php b/tests/Pest.php index b3d9bbc..174d7fd 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1 +1,3 @@