name: 'Fetch API Data'
description: 'This action will handle authenticated API requests, allowing you to save the data from the request into your workspace.'
author: 'James Ives <iam@jamesiv.es>'
runs:
  using: 'node12'
  main: 'lib/main.js'
branding:
  icon: 'truck'
  color: 'purple'
inputs:
  endpoint:
    description: 'The URL of the endpoint you would like to retrieve data from.'
    required: true

  configuration:
    description: 'Any applicable configuration settings that should be set such as authentication tokens. You can reference secrets using the secrets syntax, or you can reference data returned from the `TOKEN_ENDPOINT` request using the triple bracket syntax.'
    required: false

  token-endpoint:
    description: 'If the `ENDPOINT` API requires you to make a request to get an access token prior to fetching data you can perform this task by specifying a token endpoint. Any data returned from the token end can be referenced in the `CONFIGURATION` variable using the triple bracket syntax.'
    required: false

  token-configuration:
    description: 'Any applicable configuration settings that should be set such as authentication tokens. You can reference secrets using the secrets syntax.'
    required: false

  retry:
    description: 'If you are working with an intermittent API you can toggle this option to true. Doing so will make the action try the request 3 times at random invervals before failing.'
    required: false

  save-location:
    description: 'By default the save location of the JSON file is `fetch-api-data-action/data.json`, if you would like to override the directory you can do so by specifying a new one with this variable.'
    required: false

  save-name:
    description: 'You can override the name of the exported `.json` file by specifying a new one here. You should _not_ include the file extension in your name.'
    required: false

  debug:
    description: 'If set to true the action will log the API responses it receives in the terminal.'
    required: false

  format:
    description: 'Allows you to modify the format of the saved file, for example you can use txt here to save the file as a txt file. This field defaults to json.'
    required: false

  encoding:
    description: 'Allows you to specify the encoding the saved file, can be of type BufferEncoding: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex".'
    required: false

outputs:
  fetch-api-data:
    description: 'The requested data from the API stored as a string.'
