com.citygrid.content.offers.search
Class CGOffersSearch

java.lang.Object
  extended by com.citygrid.content.offers.search.CGOffersSearch
All Implemented Interfaces:
Serializable, Cloneable

public class CGOffersSearch
extends Object
implements Serializable, Cloneable

The Offers SDK will help find any offers in your area as well as help minimize the listings returned for an offer based on where you are.

Let's pretend the user chose to find any offers for sushi in the 90025 zip code for restaurants.


 CGOffersSearch search = CityGrid.offersSearch();
    search.setWhat("sushi");
    search.setWhere("90025");

    CGOffersSearchResults results = search.search();

    for (CGOffersOffer offer : offers) {
        // do something with offer
    }

Next, let's pretend the user clicked on an offer for a specific location in your app. This assumes you found the offer item some way in your app, in this case, the last offer.


    // Pretend the user selected the last offer and wants to display the offer information for
    // just the last locationId (an offer may be for more than one location)
    // Usually this is a navigation to a detail view.
    CGOffersOffer offersOffer = results.getOffers()[results.getOffers().length - 1];
    int locationId = offersOffer.getLocations()[offersOffer.getLocations().length -1].getLocationId();

    // Get the detail for only the offer and the last location id (This will populate the offerId, locationId
    // and impressionId for you). You could alternatively use the offerId, locationId and impressionId yourself,
    // but this is easier
    CGOffersDetail detail = offersOffer.offersDetail();
    detail.setLocationId(locationId);

    CGOffersOffer detailsOffer = detail.detail().getOffer();
    // do something with the offer, say maybe showing it to the user.

See Also:
Serialized Form

Field Summary
private static String CGOffersSearchLatLonUri
           
private static String CGOffersSearchWhereUri
           
private  int connectTimeout
           
private  int excludeTag
           
private  Date expiresBefore
           
private  boolean hasBudget
           
private  boolean histograms
           
private  String impressionId
           
private  CGLatLon latlon
           
private  CGLatLon latlon2
           
private  int page
           
private  String placement
           
private  int popularity
           
private  String publisher
           
private  float radius
           
private  int readTimeout
           
private  int resultsPerPage
           
private  CGOffersSearchSort sort
           
private  String source
           
private  Date startDate
           
private  int tag
           
private  CGOffersSearchTagOperation tagOperation
           
private  CGOffersType type
           
private  String what
           
private  String where
           
 
Constructor Summary
CGOffersSearch(String publisher)
           
 
Method Summary
private  Map<String,Object> build()
           
 Object clone()
           
 boolean equals(Object o)
           
 int getConnectTimeout()
           
 int getExcludeTag()
           
 Date getExpiresBefore()
           
 String getImpressionId()
           
 CGLatLon getLatlon()
           
 CGLatLon getLatlon2()
           
 int getPage()
           
 String getPlacement()
           
 int getPopularity()
           
 String getPublisher()
           
 float getRadius()
           
 int getReadTimeout()
           
 int getResultsPerPage()
           
 CGOffersSearchSort getSort()
           
 String getSource()
           
 Date getStartDate()
           
 int getTag()
           
 CGOffersSearchTagOperation getTagOperation()
           
 CGOffersType getType()
           
 String getWhat()
           
 String getWhere()
           
 int hashCode()
           
 boolean isHasBudget()
           
 boolean isHistograms()
           
static CGOffersSearch offersSearch()
           
static CGOffersSearch offersSearchWithPlacement(String placement)
           
static CGOffersSearch offersSearchWithPublisher(String publisher)
           
static CGOffersSearch offersSearchWithPublisherAndPlacement(String publisher, String placement)
           
private  CGOffersOffer[] processOffers(org.codehaus.jackson.JsonNode parsedOffers)
           
(package private)  CGOffersSearchResults processResults(org.codehaus.jackson.JsonNode rootNode)
           
 CGOffersSearchResults search()
           
 void setConnectTimeout(int connectTimeout)
           
 void setExcludeTag(int excludeTag)
           
 void setExpiresBefore(Date expiresBefore)
           
 void setHasBudget(boolean hasBudget)
           
 void setHistograms(boolean histograms)
           
 void setImpressionId(String impressionId)
           
 void setLatlon(CGLatLon latlon)
           
 void setLatlon2(CGLatLon latlon2)
           
 void setPage(int page)
           
 void setPlacement(String placement)
           
 void setPopularity(int popularity)
           
 void setPublisher(String publisher)
           
 void setRadius(float radius)
           
 void setReadTimeout(int readTimeout)
           
 void setResultsPerPage(int resultsPerPage)
           
 void setSort(CGOffersSearchSort sort)
           
 void setSource(String source)
           
 void setStartDate(Date startDate)
           
 void setTag(int tag)
           
 void setTagOperation(CGOffersSearchTagOperation tagOperation)
           
 void setType(CGOffersType type)
           
 void setWhat(String what)
           
 void setWhere(String where)
           
 String toString()
           
private  List<CGError> validate()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CGOffersSearchWhereUri

private static final String CGOffersSearchWhereUri
See Also:
Constant Field Values

CGOffersSearchLatLonUri

private static final String CGOffersSearchLatLonUri
See Also:
Constant Field Values

publisher

private String publisher

type

private CGOffersType type

what

private String what

tag

private int tag

where

private String where

tagOperation

private CGOffersSearchTagOperation tagOperation

excludeTag

private int excludeTag

page

private int page

resultsPerPage

private int resultsPerPage

startDate

private Date startDate

expiresBefore

private Date expiresBefore

hasBudget

private boolean hasBudget

sort

private CGOffersSearchSort sort

source

private String source

popularity

private int popularity

histograms

private boolean histograms

placement

private String placement

impressionId

private String impressionId

latlon

private CGLatLon latlon

latlon2

private CGLatLon latlon2

radius

private float radius

connectTimeout

private int connectTimeout

readTimeout

private int readTimeout
Constructor Detail

CGOffersSearch

public CGOffersSearch(String publisher)
Method Detail

offersSearch

public static CGOffersSearch offersSearch()

offersSearchWithPublisher

public static CGOffersSearch offersSearchWithPublisher(String publisher)

offersSearchWithPlacement

public static CGOffersSearch offersSearchWithPlacement(String placement)

offersSearchWithPublisherAndPlacement

public static CGOffersSearch offersSearchWithPublisherAndPlacement(String publisher,
                                                                   String placement)

search

public CGOffersSearchResults search()
                             throws CGException
Throws:
CGException

validate

private List<CGError> validate()

build

private Map<String,Object> build()

processResults

CGOffersSearchResults processResults(org.codehaus.jackson.JsonNode rootNode)

processOffers

private CGOffersOffer[] processOffers(org.codehaus.jackson.JsonNode parsedOffers)

getPublisher

public String getPublisher()

setPublisher

public void setPublisher(String publisher)

getType

public CGOffersType getType()

setType

public void setType(CGOffersType type)

getWhat

public String getWhat()

setWhat

public void setWhat(String what)

getTag

public int getTag()

setTag

public void setTag(int tag)

getWhere

public String getWhere()

setWhere

public void setWhere(String where)

getTagOperation

public CGOffersSearchTagOperation getTagOperation()

setTagOperation

public void setTagOperation(CGOffersSearchTagOperation tagOperation)

getExcludeTag

public int getExcludeTag()

setExcludeTag

public void setExcludeTag(int excludeTag)

getPage

public int getPage()

setPage

public void setPage(int page)

getResultsPerPage

public int getResultsPerPage()

setResultsPerPage

public void setResultsPerPage(int resultsPerPage)

getStartDate

public Date getStartDate()

setStartDate

public void setStartDate(Date startDate)

getExpiresBefore

public Date getExpiresBefore()

setExpiresBefore

public void setExpiresBefore(Date expiresBefore)

isHasBudget

public boolean isHasBudget()

setHasBudget

public void setHasBudget(boolean hasBudget)

getSort

public CGOffersSearchSort getSort()

setSort

public void setSort(CGOffersSearchSort sort)

getSource

public String getSource()

setSource

public void setSource(String source)

getPopularity

public int getPopularity()

setPopularity

public void setPopularity(int popularity)

isHistograms

public boolean isHistograms()

setHistograms

public void setHistograms(boolean histograms)

getPlacement

public String getPlacement()

setPlacement

public void setPlacement(String placement)

getImpressionId

public String getImpressionId()

setImpressionId

public void setImpressionId(String impressionId)

getLatlon

public CGLatLon getLatlon()

setLatlon

public void setLatlon(CGLatLon latlon)

getLatlon2

public CGLatLon getLatlon2()

setLatlon2

public void setLatlon2(CGLatLon latlon2)

getRadius

public float getRadius()

setRadius

public void setRadius(float radius)

getConnectTimeout

public int getConnectTimeout()

setConnectTimeout

public void setConnectTimeout(int connectTimeout)

getReadTimeout

public int getReadTimeout()

setReadTimeout

public void setReadTimeout(int readTimeout)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2011. All Rights Reserved.