mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Get shopping informations from octopart
This commit is contained in:
parent
d969f49ecc
commit
827dd01e28
1 changed files with 32 additions and 2 deletions
|
@ -27,6 +27,8 @@ use App\Entity\Parts\ManufacturingStatus;
|
||||||
use App\Services\InfoProviderSystem\DTOs\FileDTO;
|
use App\Services\InfoProviderSystem\DTOs\FileDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||||
|
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
||||||
|
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||||
use App\Services\OAuth\OAuthTokenManager;
|
use App\Services\OAuth\OAuthTokenManager;
|
||||||
use Symfony\Component\HttpClient\HttpOptions;
|
use Symfony\Component\HttpClient\HttpOptions;
|
||||||
use Symfony\Component\HttpClient\NativeHttpClient;
|
use Symfony\Component\HttpClient\NativeHttpClient;
|
||||||
|
@ -65,17 +67,22 @@ class OctopartProvider implements InfoProviderInterface
|
||||||
currency
|
currency
|
||||||
quantity
|
quantity
|
||||||
}
|
}
|
||||||
sellers(authorizedOnly: false) {
|
sellers(authorizedOnly: true) {
|
||||||
company {
|
company {
|
||||||
name
|
name
|
||||||
homepageUrl
|
|
||||||
}
|
}
|
||||||
isAuthorized
|
isAuthorized
|
||||||
offers {
|
offers {
|
||||||
clickUrl
|
clickUrl
|
||||||
inventoryLevel
|
inventoryLevel
|
||||||
moq
|
moq
|
||||||
|
sku
|
||||||
packaging
|
packaging
|
||||||
|
prices {
|
||||||
|
price
|
||||||
|
currency
|
||||||
|
quantity
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
specs {
|
specs {
|
||||||
|
@ -209,6 +216,28 @@ class OctopartProvider implements InfoProviderInterface
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Parse the offers
|
||||||
|
$orderinfos = [];
|
||||||
|
foreach ($part['sellers'] as $seller) {
|
||||||
|
foreach ($seller['offers'] as $offer) {
|
||||||
|
$prices = [];
|
||||||
|
foreach ($offer['prices'] as $price) {
|
||||||
|
$prices[] = new PriceDTO(
|
||||||
|
minimum_discount_amount: $price['quantity'],
|
||||||
|
price: (string) $price['price'],
|
||||||
|
currency_iso_code: $price['currency'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$orderinfos[] = new PurchaseInfoDTO(
|
||||||
|
distributor_name: $seller['company']['name'],
|
||||||
|
order_number: $offer['sku'],
|
||||||
|
prices: $prices,
|
||||||
|
product_url: $offer['clickUrl'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Generate a footprint name from the package and pin count
|
//Generate a footprint name from the package and pin count
|
||||||
$footprint = null;
|
$footprint = null;
|
||||||
if ($package !== null) {
|
if ($package !== null) {
|
||||||
|
@ -232,6 +261,7 @@ class OctopartProvider implements InfoProviderInterface
|
||||||
footprint: $footprint,
|
footprint: $footprint,
|
||||||
datasheets: [new FileDTO($part['bestDatasheet']['url'], $part['bestDatasheet']['name'])],
|
datasheets: [new FileDTO($part['bestDatasheet']['url'], $part['bestDatasheet']['name'])],
|
||||||
parameters: $parameters,
|
parameters: $parameters,
|
||||||
|
vendor_infos: $orderinfos,
|
||||||
mass: $mass,
|
mass: $mass,
|
||||||
manufacturer_product_url: $part['manufacturerUrl'],
|
manufacturer_product_url: $part['manufacturerUrl'],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue