| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use WWW::Shopify; | ||
| 7 | |||
| 8 | package WWW::Shopify::Model::CustomCollection; | ||
| 9 | use parent "WWW::Shopify::Model::Item"; | ||
| 10 | |||
| 11 | my $fields; sub fields { return $fields; } | ||
| 12 | BEGIN { $fields = { | ||
| 13 | "body_html" => new WWW::Shopify::Field::String::HTML(), | ||
| 14 | "handle" => new WWW::Shopify::Field::String::Handle(), | ||
| 15 | "updated_at" => new WWW::Shopify::Field::Date(), | ||
| 16 | # This is what gets updated to get published (I know, I know). | ||
| 17 | "published" => new WWW::Shopify::Field::Boolean(), | ||
| 18 | "published_scope" => new WWW::Shopify::Field::String::Enum(["global"]), | ||
| 19 | "published_at" => new WWW::Shopify::Field::Date(), | ||
| 20 | "id" => new WWW::Shopify::Field::Identifier(), | ||
| 21 | "sort_order" => new WWW::Shopify::Field::String::Enum(["manual", "best-selling", "alpha-asc", "alpha-desc", "price-asc", "price-desc", "created", "created-desc"]), | ||
| 22 | "template_suffix" => new WWW::Shopify::Field::String(), | ||
| 23 | "metafields" => new WWW::Shopify::Field::Relation::Many("WWW::Shopify::Model::Metafield"), | ||
| 24 | "image" => new WWW::Shopify::Field::Relation::OwnOne('WWW::Shopify::Model::CustomCollection::Image'), | ||
| 25 | "title" => new WWW::Shopify::Field::String::Words(1, 2), | ||
| 26 | "collects" => new WWW::Shopify::Field::Relation::Many("WWW::Shopify::Model::CustomCollection::Collect", { direct => 1, key => "collection_id" }) | ||
| 27 | }; } | ||
| 28 | my $queries; sub queries { return $queries; } | ||
| 29 | BEGIN { $queries = { | ||
| 30 | created_at_min => new WWW::Shopify::Query::LowerBound('created_at'), | ||
| 31 | created_at_max => new WWW::Shopify::Query::UpperBound('created_at'), | ||
| 32 | updated_at_min => new WWW::Shopify::Query::LowerBound('updated_at'), | ||
| 33 | updated_at_max => new WWW::Shopify::Query::UpperBound('updated_at'), | ||
| 34 | handle => new WWW::Shopify::Query::Match('handle') | ||
| 35 | }; } | ||
| 36 | |||
| 37 | sub get_fields { return grep { $_ ne "collects" } $_[0]->SUPER::get_fields; } | ||
| 38 | |||
| 39 | sub creation_minimal { return qw(title); } | ||
| 40 | sub creation_filled { return qw(public_url created_at); } | ||
| 41 | sub update_filled { return qw(updated_at); } | ||
| 42 | sub update_fields { return qw(body_html handle sort_order template_suffix published title image collects metafields); } | ||
| 43 | sub webhook_topic { return "collections"; } | ||
| 44 | sub throws_webhooks { return 1; } | ||
| 45 | |||
| 46 | sub has_metafields { return 1; } | ||
| 47 | |||
| 48 | sub read_scope { return "read_products"; } | ||
| 49 | sub write_scope { return "write_products"; } | ||
| 50 | |||
| 51 | eval(__PACKAGE__->generate_accessors); die $@ if $@; | ||
| 52 | |||
| 53 | 1; |