Skip to content

Commit

Permalink
Merge pull request #2 from codebar-ag/feature-updates
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
StanBarrows authored Jan 28, 2025
2 parents 8ba2f99 + 5a08114 commit 9105dda
Show file tree
Hide file tree
Showing 37 changed files with 512 additions and 37 deletions.
55 changes: 55 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Bug Report
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: input
id: package-version
attributes:
label: Package Version
description: What version of our Package are you running? Please be as specific as possible
placeholder: "11.0"
value: "11.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.3.0"
value: "8.3.0"
validations:
required: true
- type: input
id: laravel-version
attributes:
label: Laravel Version
description: What version of Laravel are you running? Please be as specific as possible
placeholder: "11.0.0"
value: "11.0.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
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Question or Feature
description: Open a Question or Feature Request
title: "[Feature]: "
labels: ["feature"]
body:
- type: textarea
id: question-feature
attributes:
label: Question or Feature?
description: Enter a Question or Feature Request
validations:
required: true
3 changes: 3 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

If you discover any security related issues, please email [email protected] instead of using the issue tracker.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
32 changes: 32 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: dependabot-auto-merge
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:

- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
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"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
21 changes: 21 additions & 0 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Fix PHP code style issues

on: [push]

jobs:
php-code-styling:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
55 changes: 55 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: run-tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
max-parallel: 1
matrix:
os: [ ubuntu-latest ]
php: [ 8.3 ]
laravel: [ 11.* ]
stability: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: cp phpunit.xml.dist phpunit.xml

- name: Execute tests
run: vendor/bin/pest

- name: Store Log Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: Store report artifacts
path: ./vendor/orchestra/testbench-core/laravel/storage/logs
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
40 changes: 39 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Or:
You can publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-instagram-config"
php artisan vendor:publish --tag="instagram-config"
```

This is the contents of the published config file:
Expand Down Expand Up @@ -89,6 +89,44 @@ INSTAGRAM_CLIENT_ID=your-client-id
INSTAGRAM_CLIENT_SECRET=your-client-secret
```

## Overriding the default routes

If you want to override the default routes, you can do so by creating a `instagram.php` file in your routes directory and adding the following code:

```php
<?php

use CodebarAg\LaravelInstagram\Http\Controllers\InstagramController;
use Illuminate\Support\Facades\Route;

Route::prefix('instagram')->name('instagram.')->group(function () {
Route::get('/auth', [InstagramController::class, 'auth'])->name('auth');

Route::get('/callback', [InstagramController::class, 'callback'])->name('callback');
});
```

Then you should register the routes in your `bootstrap\app.php`:

```php
->withRouting(
web: __DIR__ . '/../routes/web.php',
// api: __DIR__ . '/../routes/api.php',
then: function () {
Route::middleware('web')->group(base_path('routes/instagram.php'));
},
)
```

or in your `RouteServiceProvider`:

```php
$this->routes(function () {
Route::middleware('web')->group(base_path('routes/web.php'));
Route::middleware('web')->group(base_path('routes/instagram.php'));
});
```

You can get your client id and client secret by registering your app on the [Instagram Developer Portal](https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login)

When configuring your app on the Instagram Developer Portal, you will need to set the redirect uri to: `http://your-app-url.com/instagram/callback`
Expand Down
4 changes: 2 additions & 2 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"require": {
"php": "^8.3",
"guzzlehttp/guzzle": "^7.8",
"illuminate/contracts": "^11.0",
"illuminate/contracts": "^10.0|^11.0",
"nesbot/carbon": "^2.72",
"saloonphp/cache-plugin": "^3.0",
"saloonphp/laravel-plugin": "^3.5",
"saloonphp/laravel-plugin": "^3.0",
"saloonphp/saloon": "^3.7",
"spatie/laravel-package-tools": "^1.16"
},
Expand Down
Empty file modified config/instagram.php
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions phpunit.xml.dist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="INSTAGRAM_CLIENT_ID" value=""/>
<env name="INSTAGRAM_CLIENT_SECRET" value=""/>
<env name="INSTAGRAM_CLIENT_ID" value="CLIENT_ID"/>
<env name="INSTAGRAM_CLIENT_SECRET" value="CLIENT_SECRET"/>
</php>
<source>
<include>
Expand Down
Empty file modified ray.php
100644 → 100755
Empty file.
4 changes: 0 additions & 4 deletions routes/instagram.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@
Route::get('/auth', [InstagramController::class, 'auth'])->name('auth');

Route::get('/callback', [InstagramController::class, 'callback'])->name('callback');

Route::get('/me', [InstagramController::class, 'me'])->name('me');

Route::get('/media', [InstagramController::class, 'media'])->name('media');
});
Empty file modified src/Actions/InstagramHandler.php
100644 → 100755
Empty file.
Empty file modified src/Authenticator/InstagramAuthenticator.php
100644 → 100755
Empty file.
Empty file modified src/Commands/LaravelInstagramCommand.php
100644 → 100755
Empty file.
Empty file modified src/Connectors/InstagramConnector.php
100644 → 100755
Empty file.
Empty file modified src/Data/InstagramImage.php
100644 → 100755
Empty file.
Empty file modified src/Data/InstagramUser.php
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions src/Http/Controllers/InstagramController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function callback(Request $request)

$json = $response->json();

ray($json);

Cache::store(config('instagram.cache_store'))->put('instagram.authenticated', $json, now()->addDays(60));

return response('Authenticated Instagram account: '.Arr::get($json, 'username'), 200);
Expand Down
Empty file modified src/LaravelInstagramServiceProvider.php
100644 → 100755
Empty file.
Empty file modified src/Requests/Authentication/GetAccessTokenRequest.php
100644 → 100755
Empty file.
Empty file modified src/Requests/Authentication/GetShortLivedAccessTokenRequest.php
100644 → 100755
Empty file.
Loading

0 comments on commit 9105dda

Please sign in to comment.