func (c *Currency) Catagories() ([]string, error) { var js JSONResponse url := apistore.BuildHttpURL(apistore.BaiduApistore, "/apistore/currencyservice/type", nil) if err := c.client.Get(url, &js); err != nil { return nil, err } var types []string if err := json.Unmarshal(js.RetData, &types); err != nil { return nil, err } return types, nil }
func (c *Currency) Exchange(data *ExchangeData) error { params := url.Values{} params.Set("fromCurrency", data.FromCurrency) params.Set("toCurrency", data.ToCurrency) params.Set("amount", fmt.Sprintf("%.4f", data.Amount)) url := apistore.BuildHttpURL(apistore.BaiduApistore, "/apistore/currencyservice/currency", params) var js JSONResponse if err := c.client.Get(url, &js); err != nil { return err } if err := json.Unmarshal(js.RetData, data); err != nil { return err } return nil }