Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
],
"require": {
"php": "~8.3.1|~8.4.1",
"always-open/laravel-request-logger": "^3.0",
"illuminate/contracts": "~10.0||~11.0||~12.0",
"spatie/laravel-data": "~4.16",
"spatie/laravel-package-tools": "^1.16"
Expand Down Expand Up @@ -74,4 +75,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
1 change: 1 addition & 0 deletions config/oxylabs-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
'username' => env('OXYLAB_API_USERNAME'),
'password' => env('OXYLAB_API_PASSWORD'),
'auth_method' => env('OXYLAB_API_AUTH_METHOD', 'basic'),
'request_logging_enabled' => env('OXYLABS_API_REQUEST_LOGGING_ENABLED', true),
];
33 changes: 33 additions & 0 deletions config/request-logger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

return [
/*
* This is the default suffix applied to a Model's table name.
*/
'table_suffix' => '_request_logs',

/*
* This is the default suffix applied to models' class names.
*
* Example: The facebook object name would have a request log model of FacebookRequestLog.
*/
'model_suffix' => 'RequestLog',

'model_path' => app_path('Models'),

'model_stub' => __DIR__.'/../stubs/model.stub',

'migration_path' => database_path('migrations'),

'migration_stub' => __DIR__.'/../stubs/migration.stub',

/*
* Enable the process stamps (sub) package to log which process/url/job invoked the call
*/
'enable_process_stamps' => true,

/*
* Precision value used in generating occurred_at for request log
*/
'log_timestamp_precision' => 3,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::create('oxylabs_api_request_logger', function (Blueprint $table) {
$table->id();
// Will store the relative path of the request (e.g. /addresses/validate)
$table->string('path', 191)
->index();
// What parameters were passed in (e.g. ?status=new)
$table->string('params', 512)
->nullable()
->fulltext();
// HTTP method (e.g. POST/PUT/DELETE)
$table->string('http_method', 10)
->index();
// Status code (e.g. 200, 204, 429)
$table->smallInteger('response_code', autoIncrement: false, unsigned: true)
->nullable()
->index();
// The entire JSON encoded payload of the request
$table->json('body')
->nullable();
// The headers that were part of the request
$table->json('request_headers')
->nullable();
// The entire JSON encoded responses
$table->json('response')
->nullable();
// The headers that were part of the response
$table->json('response_headers')
->nullable();
// Internal exceptions that occurred during the request
$table->string('exception')
->nullable();
// When the request was resolved to the millisecond
$table->timestamp('occurred_at', 3)->index();
$table->timestamps(precision: 3);
$table->processIds();
});
}

public function down(): void
{
Schema::dropIfExists('oxylabs_api_request_logger');
}
};
19 changes: 0 additions & 19 deletions database/migrations/create_oxylabs_api_table.php.stub

This file was deleted.

3 changes: 1 addition & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ parameters:
checkOctaneCompatibility: true
checkModelProperties: true
ignoreErrors:
- '#Trait AlwaysOpen\\OxylabsApi\\Traits\\APIStatus is used zero times and is not analysed.#'
- '#Call to function is_string\(\) with string will always evaluate to true.#'
- '#Trait AlwaysOpen\\OxylabsApi\\Traits\\APIStatus is used zero times and is not analysed.#'
33 changes: 20 additions & 13 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" bootstrap="vendor/autoload.php"
executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="false"
failOnWarning="false" cacheDirectory=".phpunit.cache" requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true">
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
shortenArraysForExportThreshold="10"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnPhpunitDeprecations="true"
failOnPhpunitDeprecation="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory suffix=".php">tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="reports/coverage/html" lowUpperBound="50" highLowerBound="90"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<source>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory suffix=".php">src</directory>
<directory>src</directory>
</include>
</source>
<php>
<server name="OXYLABS_API_REQUEST_LOGGING_ENABLED" value="false" force="true"/>
<env name="OXYLABS_API_REQUEST_LOGGING_ENABLED" value="false" force="true"/>
</php>
</phpunit>
40 changes: 21 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
shortenArraysForExportThreshold="10"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnPhpunitDeprecations="true"
failOnPhpunitDeprecation="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="VendorName Test Suite">
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory suffix=".php">./src</directory>
<directory>src</directory>
</include>
</source>
<php>
<server name="OXYLABS_API_REQUEST_LOGGING_ENABLED" value="false" force="true"/>
<env name="OXYLABS_API_REQUEST_LOGGING_ENABLED" value="false" force="true"/>
</php>
</phpunit>
4 changes: 2 additions & 2 deletions src/DTOs/Amazon/AmazonSellerResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AmazonSellerResponse extends Data
public function __construct(
/* @var AmazonSellerResult[] $results */
#[DataCollectionOf(AmazonSellerResult::class)]
public readonly array $results,
public readonly PushPullJob $job,
public readonly ?array $results,
public readonly ?PushPullJob $job,
) {}
}
4 changes: 2 additions & 2 deletions src/DTOs/Google/GoogleShoppingProductResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GoogleShoppingProductResponse extends Data
public function __construct(
/* @var GoogleShoppingProductResult[] $results */
#[DataCollectionOf(GoogleShoppingProductResult::class)]
public readonly DataCollection $results,
public readonly PushPullJob $job,
public readonly ?DataCollection $results,
public readonly ?PushPullJob $job,
) {}
}
4 changes: 2 additions & 2 deletions src/DTOs/UniversalResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UniversalResponse extends Data
public function __construct(
/* @var UniversalResult[] $results */
#[DataCollectionOf(UniversalResult::class)]
public readonly array $results,
public readonly PushPullJob $job,
public readonly ?array $results,
public readonly ?PushPullJob $job,
) {}
}
24 changes: 24 additions & 0 deletions src/Models/OxylabsApiRequestLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace AlwaysOpen\OxylabsApi\Models;

use AlwaysOpen\RequestLogger\Models\RequestLogBaseModel;

/**
* AlwaysOpen\OxylabsApi\Models\OxylabsApiRequestLogger
*
* @property string|null $path
* @property string|null $params
* @property string $http_method
* @property int|null $response_code
* @property array|string|null $body
* @property array|string|null $request_headers
* @property array|string|null $response
* @property array|string|null $response_headers
* @property string|null $exception
* @property \Carbon\Carbon|null $occurred_at
*/
class OxylabsApiRequestLogger extends RequestLogBaseModel
{
protected $table = 'oxylabs_api_request_logger';
}
Loading