| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Query - Basic Description of Filters on Shopify | ||
| 9 | |||
| 10 | =cut | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | Queries describe Shopify filters that can be put on get requests. This allows them to be translated into local database queries for testing purposes. | ||
| 15 | |||
| 16 | The following queries exist: | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | package WWW::Shopify::Query; | ||
| 21 | sub new { return bless { name => undef }, $_[0]; } | ||
| 22 | sub name { $_[0]->{name} = $_[1] if defined $_[1]; return $_[0]->{name}; } | ||
| 23 | sub field_name { $_[0]->{field_name} = $_[1] if defined $_[1]; return $_[0]->{field_name}; } | ||
| 24 | |||
| 25 | =head2 WWW::Shopify::Query::LowerBound | ||
| 26 | |||
| 27 | Specifies a lower bound on the specified field. An example of this is WWW::Shopify::Model::Product's created_at_min query, which links to the created_at field. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | package WWW::Shopify::Query::LowerBound; | ||
| 32 | use parent 'WWW::Shopify::Query'; | ||
| 33 | sub new { return bless { 'field_name' => $_[1] }, $_[0]; } | ||
| 34 | |||
| 35 | =head2 WWW::Shopify::Query::UpperBound | ||
| 36 | |||
| 37 | As above, except an upper bound. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | package WWW::Shopify::Query::UpperBound; | ||
| 42 | use parent 'WWW::Shopify::Query'; | ||
| 43 | sub new { return bless { 'field_name' => $_[1] }, $_[0]; } | ||
| 44 | |||
| 45 | =head2 WWW::Shopify::Query::Enum | ||
| 46 | |||
| 47 | A query that states that a field can be equal to one of the specified enumerations. | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | package WWW::Shopify::Query::Enum; | ||
| 52 | use parent 'WWW::Shopify::Query'; | ||
| 53 | sub new { return bless { 'field_name' => $_[1], 'enums' => $_[2] }, $_[0]; } | ||
| 54 | sub enums { return @{$_[0]->{enums}}; } | ||
| 55 | |||
| 56 | =head2 WWW::Shopify::Query::Match | ||
| 57 | |||
| 58 | A query that states that the specified field must exactly equal the input, though there is no restriction on what this input might be. | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | package WWW::Shopify::Query::Match; | ||
| 63 | use parent 'WWW::Shopify::Query'; | ||
| 64 | sub new { return bless { 'field_name' => $_[1] }, $_[0]; } | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | =head2 WWW::Shopify::Query::MultiMatch | ||
| 69 | |||
| 70 | A query that states that the specified field must equal any element in the input, though there is no restriction on what this input might be. | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | package WWW::Shopify::Query::MultiMatch; | ||
| 75 | use parent 'WWW::Shopify::Query'; | ||
| 76 | sub new { return bless { 'field_name' => $_[1] }, $_[0]; } | ||
| 77 | |||
| 78 | =head2 WWW::Shopify::Query::Custom | ||
| 79 | |||
| 80 | A query that takes a sub that details how to handle the query. | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | |||
| 85 | package WWW::Shopify::Query::Custom; | ||
| 86 | use parent 'WWW::Shopify::Query'; | ||
| 87 | sub new { return bless { 'field_name' => $_[1], 'sub' => $_[2] }, $_[0]; } | ||
| 88 | sub routine { return $_[0]->{'sub'}; } | ||
| 89 | |||
| 90 | 1; |