search.go
author Mikael Berthe <mikael@lilotux.net>
Sat, 22 Apr 2017 14:49:19 +0200
changeset 145 d7ccfe67fa9e
parent 138 23d3a518d0ad
child 149 5f922977d7c7
permissions -rw-r--r--
Bump version to 1.0 since the whole current API is covered

/*
Copyright 2017 Mikael Berthe

Licensed under the MIT license.  Please see the LICENSE file is this directory.
*/

package madon

import (
	"github.com/sendgrid/rest"
)

// Search search for contents (accounts or statuses) and returns a Results
func (mc *Client) Search(query string, resolve bool) (*Results, error) {
	if query == "" {
		return nil, ErrInvalidParameter
	}

	params := make(apiCallParams)
	params["q"] = query
	if resolve {
		params["resolve"] = "true"
	}

	var results Results
	if err := mc.apiCall("search", rest.Get, params, &results); err != nil {
		return nil, err
	}
	return &results, nil
}