Goldshark Gem


To Install

gem install goldshark_gem

Put in Rails Gemfile

gem 'goldshark_gem'

Usage

gs = GS::Tool.new(localization)
texts = GS::Text.new(localization)

localization is the parameter key you will need to define in the YAML file. The config file has to be named 'tool_config.yml' and placed in the config folder of the Rails app.

localization = 'en_us' or 'fridge_finder' or whatever you want it to be.

YAML file Sample (tool_config.yml)

en_us:
    tool_guid: '12343252'
    locale: 'en'
    api_root: 'http://gst.api.igodigital.com/v2_2' # this parameter is optional it defaults to v2_2
    source: 'web' # this parameter is optional. Has no default

fridge_finder_web:
    tool_guid: '3255423'
    locale: 'en'
    api_root: 'http://gst.api.igodigital.com/v2_2' # this parameter is optional it defaults to v2_2
    source: 'web' # this parameter is optional. Has no default

fridge_finder_no_source:
    tool_guid: '3255423'
    locale: 'en'

Without YAML config file

If the tool_config.yml file is missing or you are not developing in the Rails enveironment. An empty object can be created and the variables can be defined like so:

gs = GS::Tool.new
gs.tool_guid('132424324')
gs.session_id('92034802')
gs.locale('en')
gs.url('http://gst.api.igodigital.com/v2_2') 

gs.source('web')

texts = GS::Text.new
texts.tool_guid('132424324')
texts.locale('en')

More About Defining Tool Source outside the config file

If you haven't added the source to the config file and Guided Selling tool powers both web and mobile, or guided selling and guided search. Defining a souce may be required by the client. To define a souce just do:

gs.source('web') or
gs.source('mobile')

Retrieve the 'gs' object variables

gs.tool_guid or texts.tool_guid
=> '1233242'

gs.session_id
=> '322342'

gs.locale or texts.locale
=> 'en'

gs.url
=> 'http://gst.api.igodigital.com/v2_2'

All calls return hashes with symbolized keys and all product calls return a constant structure for the product object

Load and Search a text

After the text object is initialized. The find method returns the value as a string. (The text type is always defined unlike the text name so I picked that param to make the call).

texts.load_text

texts.find(text_type)

Example:

texts.find('buy_now')
=> 'Buy Now'

Introduced in v0.2.1 a more forgiving ability to look up tool text type. The tool text type is not case sensitive anymore and can also be looked up as ddowncased and underscored.

Example: if the tool_type = 'Buy Now' all the following are valid options

texts.find('Buy Now')
texts.find('buy now')
texts.find('buy_now')

Grab the tool object with session id if defined, without session id if not defined

gs.get_tool

The following accepts an ARRAY of tool step option ids and returns the results tool object.

gs.get_results(tool_step_option_ids)

Get Products by skus or product ids

The following call accepts one skus or a string of comma separated values of skus and returns a products array.

gs.get_products_by_skus(skus)

The following call accepts one retailer_product_id or a string of comma separated values of retailer_product_ids and returns a products array.

gs.get_products_by_product_ids(product_ids)

The following call accepts an attribute name and returns an array of the requested attribute for all products.

gs.get_attribute_by_name(attribute_name)

The following call will return all products linked to the retailer_product_id listed.

gs.get_product_links(retailer_product_id)

Interact with User Data

The following will return the user data of the gs.session_id. The user_id param is optional.

gs.get_user_data(user_id)

The following call accepts session_data (it can be anything you want to save). And it save it to the user data.

gs.save_user_data(session_data, user_id)

Reporting calls

The following call records recommendation based on the gs.session_id. You will need to pass the group id and the retailer product list (not optional).

gs.recs(group_id, retailer_product_list)

The following call will record the event passed on the gs.session_id.

gs.record_events(event_name)

The following call will record microconversion based on the gs.session_id and the retailer product id passed (param not optional).

gs.micro_convert(retailer_product_id)

PG CI interaction

Since we often need to pull CI buy now info for PG products. The GS::Ci module will allow you to pass a sku and an rgid value (usually provided by the vendor to retrieve an array of vendors, vendor logo images and buy now links to build the buy now button for a specific product.

ci = GS::Ci.new
buy_now_array = ci.buy_now(pg_product_id, rgid)

The previous call will return:

[
    {
        :id=>"Product Id", 
        :logo=>"Retailer Logo Image", 
        :name=>"Retailer Name", 
        :buy_now_link=>"Buy now Button", 
        :product_name=>"Product Name", 
        :price=>"Price", 
        :product_image=>"Product Image", 
        :available=>"Y or N"
    }
]

Contributing to goldshark_gem

Gabriele Roselli

Copyright

Copyright (c) 2012 iGoDigital. See LICENSE.txt for further details.