API-Octopart
view release on metacpan or search on metacpan
lib/API/Octopart.pm view on Meta::CPAN
my $moq = $p->{quantity};
my $price = $p->{price};
$ss{$s->{company}{name}}{price_tier}{$p->{quantity}} = $price;
# Find the minimum order quantity and the MOQ price:
if (!defined($ss{$s->{company}{name}}{moq}) ||
$ss{$s->{company}{name}}{moq} > $moq)
{
$ss{$s->{company}{name}}{moq} = $moq;
$ss{$s->{company}{name}}{moq_price} = $price;
}
}
}
}
$part{sellers} = \%ss;
push @results, \%part;
}
# Delete sellers that do not meet the constraints and
# add matching results to @ret:
my @ret;
foreach my $r (@results)
{
next if (defined($opts{mfg}) && $r->{mfg} !~ /$opts{mfg}/i);
foreach my $s (keys %{ $r->{sellers} })
{
if (!defined($r->{sellers}{$s}{price_tier})
|| (defined($opts{min_qty}) && $r->{sellers}{$s}{stock} < $opts{min_qty})
|| (defined($opts{max_price}) && $r->{sellers}{$s}{moq_price} > $opts{max_price})
|| (defined($opts{max_moq}) && $r->{sellers}{$s}{moq} > $opts{max_moq}
|| defined($opts{seller}) && $s !~ /$opts{seller}/i)
)
{
delete $r->{sellers}{$s};
}
}
push @ret, $r;
}
return \@ret;
}
=back
=head1 SEE ALSO
L<https://octopart.com/>, L<https://octopart.com/api>
=head1 ATTRIBUTION
Octopart is a registered trademark and brand of Octopart, Inc. All tradmarks,
product names, logos, and brands are property of their respective owners and no
grant or license is provided thereof.
The copyright below applies to this software module; the copyright holder is
unaffiliated with Octopart, Inc.
=head1 AUTHOR
Originally written at eWheeler, Inc. dba Linux Global by Eric Wheeler
to facilitate optimization of RF matching components, but only for
components that are available for purchase at electronic component
vendors (of course!) L<https://youtu.be/xbdBjR4szjE>
=head1 COPYRIGHT
Copyright (C) 2022 eWheeler, Inc. dba Linux Global
L<https://www.linuxglobal.com/>
This module is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This module is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this module. If not, see <http://www.gnu.org/licenses/>.
=cut
1;
( run in 1.263 second using v1.01-cache-2.11-cpan-bbcb1afb8fc )