com.citygrid.content.offers.search
Class CGOffersSearch
java.lang.Object
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
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
CGOffersSearch
public CGOffersSearch(String publisher)
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.