Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertToCSV(body []byte) (string, error)
- func ConvertToXML(data interface{}) string
- func DecryptString(cipherText string) (string, error)
- func EncryptString(plain string) (string, error)
- func Get(apiURL string) ([]byte, error)
- func OutputFilePath(name, extension string) string
- func PostJSON(apiURL string, payload interface{}, headers map[string]string) ([]byte, error)
- func PrintAsTable(data interface{}, indent int)
- func ToTitle(s string) string
- func ValidateRequestLimits() error
Constants ¶
const ArraySeparator = "|"
ArraySeparator joins the elements of an array of scalars inside a single CSV cell.
Variables ¶
var MaxResponseMB int64 = 256
var RequestTimeout = 5 * time.Minute
Functions ¶
func ConvertToCSV ¶ added in v2.2.0
ConvertToCSV renders a JSON API response as CSV text.
A top-level JSON array becomes one row per element, which is what the bulk endpoints return; any other response becomes a single row. Nested objects are flattened into dotted column names ("location.city"). An array whose elements are all scalars is joined into one cell with ArraySeparator; an array holding objects keeps a column per element instead ("routes.0.prefix"), so its fields stay addressable. Columns are the union of the keys of every row, sorted, so the same response always produces the same file.
func ConvertToXML ¶
func ConvertToXML(data interface{}) string
func DecryptString ¶
func EncryptString ¶
func OutputFilePath ¶ added in v2.2.0
OutputFilePath works out the file an --output-file value should write to. The extension is appended only when the name does not already end in it, so "results" and "results.csv" both save to results.csv and neither doubles up.
An extension that does not match is left in place rather than swapped, so --output-file results.json with --output csv writes results.json.csv. That keeps the name the caller gave and never silently retargets a different file. The comparison ignores case, so results.CSV is accepted as it stands.
func PrintAsTable ¶
func PrintAsTable(data interface{}, indent int)
func ValidateRequestLimits ¶ added in v2.1.2
func ValidateRequestLimits() error
Types ¶
This section is empty.