github.com/wit-ai/wit-go/v2@v2.0.2/export.go (about)

     1  // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
     2  
     3  package witai
     4  
     5  import (
     6  	"encoding/json"
     7  	"net/http"
     8  )
     9  
    10  type exportResponse struct {
    11  	URI string `json:"uri"`
    12  }
    13  
    14  // Export - Returns download URI. https://wit.ai/docs/http/20170307#get__export_link
    15  func (c *Client) Export() (string, error) {
    16  	resp, err := c.request(http.MethodGet, "/export", "application/json", nil)
    17  	if err != nil {
    18  		return "", err
    19  	}
    20  
    21  	defer resp.Close()
    22  
    23  	var r exportResponse
    24  	decoder := json.NewDecoder(resp)
    25  	err = decoder.Decode(&r)
    26  	return r.URI, err
    27  }