Merge branch 'master' of bbu/go-yelp-fusion into master

This commit is contained in:
2018-04-10 23:45:10 +02:00
committed by Gogs
4 changed files with 56 additions and 15 deletions

View File

@@ -3,16 +3,14 @@ package yelp
import (
"errors"
"fmt"
"github.com/guregu/null"
)
// CoordinateOptions are used with complex searches for locations.
// The geographic coordinate format is defined as:
// ll=latitude,longitude,accuracy,altitude,altitude_accuracy
type CoordinateOptions struct {
Latitude null.Float // Latitude of geo-point to search near (required)
Longitude null.Float // Longitude of geo-point to search near (required)
Latitude Float // Latitude of geo-point to search near (required)
Longitude Float // Longitude of geo-point to search near (required)
// Accuracy null.Float // Accuracy of latitude, longitude (optional)
// Altitude null.Float // Altitude (optional)
// AltitudeAccuracy null.Float // Accuracy of altitude (optional)

View File

@@ -2,16 +2,14 @@ package yelp
import (
"fmt"
"github.com/guregu/null"
)
// GeneralOptions includes a set of standard query options for using the search API.
// They are used along with a location based option to complete a search.
type GeneralOptions struct {
Term string // Search term (e.g. "food", "restaurants"). If term isnt included we search everything.
Limit null.Int // Number of business results to return
Offset null.Int // Offset the list of returned business results by this amount
Limit Int // Number of business results to return
Offset Int // Offset the list of returned business results by this amount
SortBy string // Sort mode: 0=Best matched (default), 1=Distance, 2=Highest Rated. If the mode is 1 or 2 a search may retrieve an additional 20 businesses past the initial limit of the first 20 results. This is done by specifying an offset and limit of 20. Sort by distance is only supported for a location or geographic search. The rating sort is not strictly sorted by the rating value, but by an adjusted rating value that takes into account the number of ratings, similar to a bayesian average. This is so a business with 1 rating of 5 stars doesnt immediately jump to the top.
CategoryFilter string // Category to filter search results with. See the list of supported categories. The category filter can be a list of comma delimited categories. For example, 'bars,french' will filter by Bars and French. The category identifier should be used (for example 'discgolf', not 'Disc Golf').
// RadiusFilter null.Float // Search radius in meters. If the value is too large, a AREA_TOO_LARGE error may be returned. The max value is 40000 meters (25 miles).

45
yelp/null.go Normal file
View File

@@ -0,0 +1,45 @@
package yelp
import "github.com/guregu/null"
//Float delegate for guregu/null
type Float struct {
null.Float
}
//NewFloat Construction
func NewFloat(f float64, valid bool) Float { return Float{null.NewFloat(f, valid)} }
//FloatFrom Construction
func FloatFrom(f float64) Float { return Float{null.FloatFrom(f)} }
//FloatFromPtr Construction
func FloatFromPtr(f *float64) Float { return Float{null.FloatFromPtr(f)} }
//Int delegate for guregu/null
type Int struct {
null.Int
}
//NewInt Construction
func NewInt(f int64, valid bool) Int { return Int{null.NewInt(f, valid)} }
//IntFrom Construction
func IntFrom(f int64) Int { return Int{null.IntFrom(f)} }
//IntFromPtr Construction
func IntFromPtr(f *int64) Int { return Int{null.IntFromPtr(f)} }
//Bool delegate for guregu/null
type Bool struct {
null.Bool
}
//NewBool Construction
func NewBool(f bool, valid bool) Bool { return Bool{null.NewBool(f, valid)} }
//BoolFrom Construction
func BoolFrom(f bool) Bool { return Bool{null.BoolFrom(f)} }
//BoolFromPtr Construction
func BoolFromPtr(f *bool) Bool { return Bool{null.BoolFromPtr(f)} }

View File

@@ -119,11 +119,11 @@ func (client *Client) makeRequest(area string, id string, params map[string]stri
if params["offset"] != "" {
q.Add("offset", params["offset"])
}
if params["sortby"] != "" {
q.Add("sort_by", params["sortby"])
if params["sort_by"] != "" {
q.Add("sort_by", params["sort_by"])
}
if params["categoryfilter"] != "" {
q.Add("category_filter", params["categoryfilter"])
if params["category_filter"] != "" {
q.Add("categories", params["category_filter"])
}
if params["locale"] != "" {
q.Add("locale", params["locale"])