NAME

Item - Main superclass for all the shopify objects.

DESCRIPTION

Items are the main super class for all Shopify objects. This class holds glue code that ties the schemas (WWW::Shopify::Model::Product, for example), which only hold definitions about how the Shopify API works, and WWW::Shopify, which is the acutal method for calling Shopify's interface.

These objects can be used in many ways; they boil down to one of three states.

DBIx::Class Object: The item has been mapped to a DBIx::Class schema and can be stored in a relational database.
WWW::Shopify::Model Object: The item is in an intemediate state, suitable for querying, perusing and manipulating.
JSON-Like Hash: The item is similar to the WWW::Shopify::Model, but lacks all-non canonical shopify references, and is ready to be encode_json'd before being sent off to Shopify.

METHODS

Most of these methods you shouldn't have to mess with, most of them are used to describe the objects appropriately so that testing mock frameworks and database can be created with ease.

new($%params)

Generates a new intermediate stage (WWW::Shopify::Model::...) object.

parent($package)

Does this package have a parent?

is_shop($package)

Convenience method telling us if we're a WWW::Shopify::Model::Shop.

singular($package)

Returns the text representing the singular form of this package. (WWW::Shopify::Model::Order->singular eq "order").

plural($package)

Returns the text representing the plural form of this package. (WWW::Shopify::Model::Address->plural eq "addresses").

countable($package), gettable($package), creatable($package), updatable($package), deletable($package), searchable($package)

Determines whether or not this package can perform these main actions. 1 for yes, undef for no.

actions($package)

Returns an array of special actions that this package can perform (for orders, they can open, close, and cancel).

create_method($package), update_method($package), delete_method($package)

Shopify occasionally arbitrarily changes their update/create methods from POST and PUT around. Sometimes it makes them the same. These say which method is used where, but generally the convention is:

CREATE => POST
UPDATE => PUT
DELETE => DELETE

But not always.

queries($package)

Returns a hash of WWW::Shopify::Query objects which describe you what kind of filters you can run on this package. (Limit, since_id, created_at_min, etc...)

unique_fields($package)

An array of fields which have to be unique in this package (WWW::Shopify::Model::Customer's email, for example)

get_fields($package)

Usually every field in a class, but not always; this returns an array of keys that tells you which fields will come back when you perform a normal get request.

creation_minimal($package)

Returns an array of fields that are required before you send an object off to be created on Shopify.

creation_filled($package)

Returns an array of fields that you should be getting back filled with data when the object is created on Shopify.

update_fields($package)

Returns an array of fields that you can update when an object is already created.

update_filled($package)

Returns an array of fields that will be changed/filled when an object is updated.

throws_webhooks($package), throws_create_webhooks($package), throws_update_webhooks($package), throws_delete_webhooks($package)

Tells you whether or not the object throws webhooks for a living.

get_all_through_parent($package), get_through_parent($package), create_through_parent($package), update_through_parent($package), delete_through_parent($package)

Occasionally, Shopify decides they wanna change up their normal API conventions, and decides to throw us a curve ball, and change up whether or not certain objects have to be accessed through their parent objects /product/3242134/variants/342342.json vs. /variants/342342.json

These tell you which objects have to go through their parent, and which don't. It tends to be rather arbitrary.

field($package, $name), fields($package)

Returns a WWW::Shopify::Field::... which describes the specified field, or returns a hash containing all fields.

associate($self)

Returns the WWW::Shopify object that created/updated/deleted this object last.

associate_parent($self)

Returns the parent associated with this object. If we're a variant, it'll return the parent product (if it had access to it at one point; it usually does)

metafields($self)

Returns the metafields associated with this item. If they haven't been gotten before, a request is made, and they're cahced inside the object.

If you change a metafield, and later want to access it through a copy of the object, and this copy already has looked at the metafields, you'll get a stale copy.

If this is the case, call the method below.

refesh_metafields($self)

Returns the metafields associated with item, but ALWAYS performs a get request.

add_metafield($self, $metafield)

Takes a WWW::Shopify::Model::Metafield object.

from_json($package, $json_hash)

Returns a WWW::Shopify::Model::... intermediate object from a hash that's been decoded from a JSON object (i.e. normal shopify object in the API docs, decoded using JSON qw(decode_json); ). Does a bunch of nice conversions, like putting DateTime objects in the proper places, and associate each individual obejct with a reference to its parent and to the WWW::Shopify object that created it.

to_json($self)

Returns a hash that's ready to be converted in to a JSON string using encode_json from the JSON package.

SEE ALSO

WWW::Shopify

AUTHOR

Adam Harrison

LICENSE

See LICENSE in the main directory.