This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3b860a5
Showing
51 changed files
with
1,875 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/.php_cs export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/tests export-ignore | ||
/.editorconfig export-ignore |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Lines starting with '#' are comments. | ||
# Each line is a file pattern followed by one or more owners. | ||
|
||
# More details are here: https://help.github.com/articles/about-codeowners/ | ||
|
||
# The '*' pattern is global owners. | ||
|
||
# Order is important. The last matching pattern has the most precedence. | ||
# The folders are ordered as follows: | ||
|
||
# In each subsection folders are ordered first by depth, then alphabetically. | ||
# This should make it easy to add new rules without breaking existing ones. | ||
|
||
# Global rule: | ||
* @Razorsheep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/vendor | ||
composer.lock | ||
phpunit.xml | ||
.phpunit.result.cache | ||
.php_cs.cache | ||
.php-cs-fixer.cache | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
$finder = (new PhpCsFixer\Finder) | ||
->notPath('bootstrap') | ||
->notPath('storage') | ||
->notPath('vendor') | ||
->notPath('docker') | ||
->in(getcwd()) | ||
->name('*.php') | ||
->notName('*.blade.php') | ||
->notName('index.php') | ||
->notName('server.php') | ||
->ignoreDotFiles(true) | ||
->ignoreVCS(true); | ||
|
||
return Signifly\styles($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
filter: | ||
excluded_paths: [ tests/* ] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: false | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
|
||
build: | ||
nodes: | ||
analysis: | ||
tests: | ||
override: | ||
- php-scrutinizer-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
All notable changes to `laravel-struct` will be documented in this file | ||
|
||
## 0.0.1 - 2022-10-30 | ||
|
||
- Experimental release! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) Signifly <info@signifly.com> | ||
|
||
> 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<p align="center"> | ||
![Struct Logo](struct.svg?raw=true "Struct Logo") | ||
</p> | ||
|
||
# Make requests to the Struct API from your Laravel app | ||
|
||
The `signifly/laravel-struct` package allows you to easily make requests to the Struct API. | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require signifly/laravel-struct | ||
``` | ||
|
||
The package will automatically register itself. | ||
|
||
|
||
## Documentation | ||
|
||
You can find the full documentation [here](https://www.notion.so/signifly/Laravel-Struct). | ||
Struct API Documentation [here](https://docs.struct.com/documentation/v3/integration/web-api/). | ||
|
||
|
||
## Testing | ||
```bash | ||
composer test | ||
``` | ||
|
||
## Security | ||
|
||
If you discover any security issues, please email dev@signifly.com instead of using the issue tracker. | ||
|
||
## Credits | ||
|
||
- [Ro Kleine Sonne](https://github.com/Razorsheep) | ||
- [All contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "signifly/laravel-struct", | ||
"description": "A simple package to handle communication with Struct API", | ||
"homepage": "https://github.com/signifly/laravel-struct", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Ro Kleine Sonne", | ||
"email": "ro@signifly.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.4|^8.0", | ||
"guzzlehttp/guzzle": "^7.2", | ||
"illuminate/contracts": "^8.0|^9.0", | ||
"illuminate/http": "^8.0|^9.0", | ||
"illuminate/routing": "^8.0|^9.0", | ||
"illuminate/support": "^8.0|^9.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.0", | ||
"orchestra/testbench": "^6.0|^7.0", | ||
"phpunit/phpunit": "^9.0", | ||
"signifly/php-config": "^1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Signifly\\Struct\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Signifly\\Struct\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/phpunit", | ||
"fix": "vendor/bin/php-cs-fixer fix" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Signifly\\Struct\\StructServiceProvider" | ||
], | ||
"aliases": { | ||
"Struct": "Signifly\\Struct\\Support\\Facades\\Struct" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'credentials' => [ | ||
|
||
/* | ||
* The API key from private app credentials. | ||
*/ | ||
'api_key' => env('STRUCT_API_KEY', ''), | ||
|
||
/* | ||
* The password from private app credentials. | ||
*/ | ||
'base_uri' => env('STRUCT_PASSWORD', ''), | ||
], | ||
|
||
'webhooks' => [ | ||
|
||
/* | ||
* The webhook secret provider to use. | ||
*/ | ||
'secret_provider' => \Signifly\Struct\Webhooks\ConfigSecretProvider::class, | ||
|
||
/* | ||
* The shopify webhook secret. | ||
*/ | ||
'secret' => env('STRUCT_WEBHOOK_SECRET'), | ||
|
||
], | ||
|
||
'exceptions' => [ | ||
|
||
/* | ||
* Whether to include the validation errors in the exception message. | ||
*/ | ||
'include_validation_errors' => false, | ||
|
||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Signifly Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
<php> | ||
<env name="STRUCT_API_KEY" value="struct.api.key.goes.here" /> | ||
<env name="STRUCT_PASSWORD" value="struct.password.goes.here" /> | ||
<env name="STRUCT_DOMAIN" value="struct-domain.goes.here" /> | ||
<env name="STRUCT_API_VERSION" value="2019-07" /> | ||
<env name="STRUCT_WEBHOOK_SECRET" value="secret" /> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Signifly\Struct\Exceptions; | ||
|
||
use Illuminate\Http\Client\Response; | ||
|
||
interface ErrorHandlerInterface | ||
{ | ||
public function handle(Response $response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Signifly\Struct\Exceptions; | ||
|
||
use Illuminate\Http\Client\Response; | ||
|
||
class Handler implements ErrorHandlerInterface | ||
{ | ||
public function handle(Response $response) | ||
{ | ||
if ($response->successful()) { | ||
return; | ||
} | ||
|
||
if ($response->status() === 429) { | ||
throw new TooManyRequestsException($response); | ||
} | ||
|
||
if ($response->status() === 422) { | ||
throw new ValidationException($response->json('errors', [])); | ||
} | ||
|
||
if ($response->status() === 404) { | ||
throw new NotFoundException(); | ||
} | ||
|
||
$response->throw(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Signifly\Struct\Exceptions; | ||
|
||
class InvalidFormatException extends \Exception | ||
{ | ||
public static function for(string $format): self | ||
{ | ||
return new static(sprintf('Invalid format `%s` provided.', $format)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Signifly\Struct\Exceptions; | ||
|
||
class InvalidMethodException extends \Exception | ||
{ | ||
public function __construct($message = 'Method not allowed. Check out the documentation.') | ||
{ | ||
parent::__construct($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Signifly\Struct\Exceptions; | ||
|
||
use Exception; | ||
|
||
class NotFoundException extends Exception | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('The resource you are looking for could not be found.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Signifly\Struct\Exceptions; | ||
|
||
use Illuminate\Http\Client\Response; | ||
|
||
class TooManyRequestsException extends \Exception | ||
{ | ||
public Response $response; | ||
|
||
public function __construct(Response $response, $message = null) | ||
{ | ||
$this->response = $response; | ||
|
||
parent::__construct($message ?? 'Too many requests.'); | ||
} | ||
} |
Oops, something went wrong.