The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Semantics3::Products - API Client for Semantics3 Products API

SYNOPSIS

    use Net::Semantics3::Products;
    use Data::Dumper;

    my $sem3 = Net::Semantics3::Products->new (
        api_key => 'YOUR_API_KEY',
        api_secret => 'YOUR_API_SECRET',
    );

    $sem3->add("products","cat_id",4992);
    $sem3->add("products","brand","Toshiba");
    $sem3->add("products","weight","gte",1000000);
    $sem3->add("products","weight","lt",1500000);

    my $products = $sem3->get_products();
    print STDERR Dumper($products);

DESCRIPTION

This module is a wrapper around the Semantics3 Products API. Methods are generally named after the HTTP method and the object name.

METHODS

API Object

new PARAMHASH

This creates a new Semantics3 API object. The following parameters are accepted:

api_key

This is required. You get this from your Semantics3 Dashboard.

api_secret

This is required. You get this from your Semantics3 Dashboard.

Offers

Methods for querying the 'offers' endpoint.

See https://semantics3.com/docs for full details.

offers_field( params1, params2, ... )

Query the offers endpoint by building up the query parameters.

    $sem3->offers_field( 'currency', 'USD' );
    $sem3->offers_field( 'currency', 'price', 'gte', 30 );

get_offers( )

Returns the output of the query on the 'offers' endpoint. Note: The output of this method would overwrite the output of any previous query stored in the results buffer.

    my $offersResultRef = $sem3->get_offers();
    print STDERR Dumper( $offersResultRef );

Categories

Methods for querying the 'categories' endpoint.

See https://semantics3.com/docs for full details.

categories_field( params1, params2, ... )

Query the categories endpoint by building up the query parameters.

    $sem3->categories_field( 'parent_cat_id', 1 );

get_categories( )

Returns the output of the query on the 'categories' endpoint. Note: The output of this method would overwrite the output of any previous query stored in the results buffer.

    my $categoriesResultRef = $sem3->get_categories();
    print STDERR Dumper( $categoriesResultRef );

Products

Methods for querying the 'products' endpoint.

See https://semantics3.com/docs for full details.

products_field( params1, params2, ... )

Query the products endpoint by building up the query parameters.

    $sem3->products_field( 'cat_id', 4992 );
    $sem3->products_field( 'brand', 'Toshiba' );
    $sem3->products_field( 'weight', 'gte', 1000000 );
    $sem3->products_field( 'weight', 'lt', 1500000 );

get_products( )

Returns the output of the query on the 'products' endpoint. Note: The output of this method would overwrite the output of any previous query stored in the results buffer.

    my $productsResultRef = $sem3->get_products();
    print STDERR Dumper( $productsResultRef );

all_products( )

Converts and returns the results of the query output of the 'products' endpoint as an array reference. get_products() or run_query("products") must have been called before and should have returned a valid result set.

    $sem3->get_products();
    my @productsArray = $sem3->all_products;
    foreach(@productsArray) {
        print STDERR Dumper($_);
    }

iterate_products( )

Returns the output of the query by auto incrementing the offset based on the limit defined. If limit is not defined, it defaults to default value of 10.

    #-- get_products() or run_query("products") must have been called before and query
    #-- should have returned a valid result set in order to use iterate_products() methdo
    $sem3->get_products();

    while(my $nextProductsRef = $sem3->iterate_products()) {
        print STDERR Dumper( $nextProductsRef );
    }

Common

Common methods for use to querying the various endpoints of the Semantics3 Products API.

See https://semantics3.com/docs for full details.

add( ENDPOINT, params1, params2, ... )

Query any endpoint by building up the query parameters.

    $sem3->add( 'products', 'cat_id', 4992 );
    $sem3->add( 'products', 'brand', 'Toshiba' );
    $sem3->add( 'products', 'weight', 'gte', 1000000 );
    $sem3->add( 'products', 'weight', 'lt', 1500000 );

remove( ENDPOINT, params1, params2, ... )

Removes any specific parameters in the constructured query parameter set for any endpoint.

    #-- Removes the 'gte' attribute and it's associated weight
    $sem3->remove( 'products', 'weight', 'gte' );
    #-- Removes the entire 'brand' field from the query
    $sem3->remove( 'products', 'brand' );

get_query( ENDPOINT )

Returns the hash reference of the constructed query for the specified endpoint.

    my $productsQuery = get_query( 'products' );

get_query_json( ENDPOINT )

Returns the JSON string of the constructed query for the specified endpoint.

    my $productsJSON = get_query_json( 'products' );

get_results( )

Returns the hash reference of the results from any previously executed query.

    my $resultsRef = get_results( );

get_results_json( )

Returns the JSON string of the results from any previously executed query.

    my $resultsJSONString = get_results_json( );

clear( )

Clears previously constructed parameters for each of the endpoints and also the results buffer.

    $sem3->clear();

run_query( ENDPOINT, data )

Execute query of any endpoint based on the previously constructed query parameters or alternatively execute query of any endpoint based on the hash reference or JSON string of the query you wish to supply. Returns a hash reference of the executed query.

    #-- Just query based on constructed query using methods add() or endpoint-specific methods like products_field(), etc..
    my $resultsRef = run_query( 'products' );
    #-- Pass in a hash reference
    my $resultsRef = run_query( 'products', { 'cat_id'=>4992, 'brand'=>'Toshiba' } );
    #-- Pass in a JSON string
    my $resultsRef = run_query( 'products', '{"cat_id":4992,"brand":"Toshiba","weight":{"gte":1000000,"lt":1500000}}' );

NAME

Net::Semantics3::Products - API Client for Semantics3 Products Data API

SEE ALSO

https://semantics3.com, https://semantics3.com/docs

AUTHOR

Sivamani Varun, varun@semantics3.com

COPYRIGHT AND LICENSE

Net-Semantics3 is Copyright (C) 2013 Semantics3 Inc.

This software is released under the MIT license cited below.

The "MIT" License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.