| BZ-Client documentation | Contained in the BZ-Client distribution. |
BZ::Client::Product - Client side representation of a product in Bugzilla
This class provides methods for accessing and managing products in Bugzilla. Instances of this class are returned by BZ::Client::Product::get.
my $client = BZ::Client->new("url" => $url,
"user" => $user,
"password" => $password);
my $ids = BZ::Client::Product->get_accessible_products($client);
my $products = BZ::Client::Product->get($client, $ids);
This section lists the class methods, which are available in this module.
my @products = BZ::Client::Product->get_selectable_products($client);
Returns a list of the ids of the products the user can search on.
my @products = BZ::Client::Product->get_selectable_products($client);
Returns a list of the ids of the products the user can enter bugs against.
my @products = BZ::Client::Product->get_selectable_products($client);
Returns a list of the ids of the products the user can search or enter bugs against.
my @products = BZ::Client::Product->get($client, \@ids);
Returns a list of BZ::Client::Product instances with the product ID's mentioned in the list @ids.
my $product = BZ::Client->Product->new("id" => $id,
"name" => $name,
"description" => $description);
Creates a new instance with the given ID, name, and description.
This section lists the modules instance methods.
my $id = $product->id(); $product->id($id);
Gets or sets the products ID.
my $name = $product->name(); $product->name($name);
Gets or sets the products name.
my $description = $product->description(); $product->description($description);
Gets or sets the products description.
L<BZ::Client>, L<BZ::Client::API>
| BZ-Client documentation | Contained in the BZ-Client distribution. |
# # BZ::Client::Product - Client side representation of a product in Bugzilla # use strict; use warnings "all"; package BZ::Client::Product; use BZ::Client::API(); our $VERSION = 1.0; our @ISA = qw(BZ::Client::API); sub get_selectable_products($$) { my($class, $client) = @_; $client->log("debug", "BZ::Client::Product::get_selectable_products: Asking"); my $result = $class->get_list("Product.get_selectable_products", $client); $client->log("debug", "BZ::Client::Product::get_selectable_products: Got " . @$result); return $result; } sub get_enterable_products($$) { my($class, $client) = @_; $client->log("debug", "BZ::Client::Product::get_enterable_products: Asking"); my $result = $class->get_list("Product.get_enterable_products", $client); $client->log("debug", "BZ::Client::Product::get_enterable_products: Got " . @$result); return $result; } sub get_accessible_products($$) { my($class, $client) = @_; $client->log("debug", "BZ::Client::Product::get_accessible_products: Asking"); my $result = $class->get_list("Product.get_accessible_products", $client); $client->log("debug", "BZ::Client::Product::get_accessible_products: Got " . @$result); return $result; } sub get_list($$$) { my($class, $methodName, $client) = @_; my $result = $class->api_call($client, $methodName, {}); my $ids = $result->{"ids"}; if (!$ids || "ARRAY" ne ref($ids)) { $class->error($client, "Invalid reply by server, expected array of ids."); } return $ids; } sub get($$$) { my($class, $client, $ids) = @_; my $result = $class->api_call($client, "Product.get", { "ids" => $ids }); my $products = $result->{"products"}; if (!$products || "ARRAY" ne ref($products)) { $class->error($client, "Invalid reply by server, expected array of products."); } my @result; foreach my $product (@$products) { push(@result, $class->new(id => $product->{"id"}, name => $product->{"name"}, description => $product->{"description"}, internals => $product->{"internals"})); } return \@result; } sub new($@) { my $class = shift; my $self = { @_ }; bless($self, ref($class) || $class); return $self; } sub id($;$) { my $self = shift; if (@_) { $self->{"id"} = shift; } else { return $self->{"id"}; } } sub name($;$) { my $self = shift; if (@_) { $self->{"name"} = shift; } else { return $self->{"name"}; } } sub description($;$) { my $self = shift; if (@_) { $self->{"description"} = shift; } else { return $self->{"description"}; } } sub internals($;$) { my $self = shift; if (@_) { $self->{"internals"} = shift; } else { return $self->{"internals"}; } } 1;