Shopify/Model/SmartCollection.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 16 totaltotal 0.0% 0 / 89 CC 2 SCAR 8.5
CC
2
Cov
0%
should_contain
6.0
singular
2.0
fields
2.0
CRAP 2.3
1 #!/usr/bin/perl
2  
3 use strict;
4 use warnings;
5  
6 use WWW::Shopify;
7  
8 use WWW::Shopify::Model::SmartCollection::Rule;
9 use WWW::Shopify::Model::SmartCollection::Image;
10  
11 package WWW::Shopify::Model::SmartCollection;
12 use parent 'WWW::Shopify::Model::Item';
13  
14 sub singular { return "smart_collection"; }
15 my $fields; sub fields { return $fields; }
16 BEGIN { $fields = {
17 "body_html" => new WWW::Shopify::Field::Text::HTML(),
18 "handle" => new WWW::Shopify::Field::String::Handle(),
19 "disjunctive" => new WWW::Shopify::Field::Boolean(),
20 "sort_order" => new WWW::Shopify::Field::String::Enum(["manual", "automatic"]),
21 "template_suffix" => new WWW::Shopify::Field::String(),
22 "title" => new WWW::Shopify::Field::String::Words(1, 2),
23 "rules" => new WWW::Shopify::Field::Relation::Many("WWW::Shopify::Model::SmartCollection::Rule"),
24 "image" => new WWW::Shopify::Field::Relation::OwnOne("WWW::Shopify::Model::SmartCollection::Image"),
25 "id" => new WWW::Shopify::Field::Identifier(),
26 "created_at" => new WWW::Shopify::Field::Date(),
27 "metafields" => new WWW::Shopify::Field::Relation::Many("WWW::Shopify::Model::Metafield"),
28 "updated_at" => new WWW::Shopify::Field::Date(),
29 "published_at" => new WWW::Shopify::Field::Date(),
30 "published_scope" => new WWW::Shopify::Field::String()
31 }; }
32 my $queries; sub queries { return $queries; }
33 BEGIN { $queries = {
34 created_at_min => new WWW::Shopify::Query::LowerBound('created_at'),
35 created_at_max => new WWW::Shopify::Query::UpperBound('created_at'),
36 updated_at_min => new WWW::Shopify::Query::LowerBound('updated_at'),
37 updated_at_max => new WWW::Shopify::Query::UpperBound('updated_at'),
38 handle => new WWW::Shopify::Query::Match('handle')
39 }; }
40  
41  
42  
43 sub should_contain {
44 my ($self, $product) = @_;
45 my @rules = $self->rules->all;
46 if ($self->disjunctive) {
47 return int(grep { $_->matches($product) } @rules) > 0;
48 } else {
49 return int(grep { !$_->matches($product) } @rules) == 0;
50 }
51 }
52  
53 sub creation_minimal { return qw(title); }
54 sub creation_filled { return qw(id created_at); }
55 sub update_filled { return qw(updated_at); }
56 sub update_fields { return qw(body_html handle sort_order template_suffix title rules image metafields); }
57 sub has_metafields { return 1; }
58 sub throws_webhooks { return 1; }
59 sub webhook_topic { return "collections"; }
60  
61 sub actions { return qw(order); }
62  
63 sub read_scope { return "read_products"; }
64 sub write_scope { return "write_products"; }
65  
66 eval(__PACKAGE__->generate_accessors); die $@ if $@;
67  
68 1