"""
Send a message
Send a text message to channel destination
"""
name = "chat/send-message"
version = "1.0.0"

"""
Send Message
Sends message to one destination
"""
usecase SendMessage {
  input {
    """
    Destination
    Channel to send the message to
    """
    destination! string!
    
    """
    Text
    Contents of the message
    """
    text! string!
  }

  result {
    """
    Message ID
    Identifier of the message that was sent
    """
    messageId! string

    """
    Destination
    Identifier of the destination where the message was sent.
    """
    destination string

    """
    Rate Limit
    Rate limit details.
    """
    rateLimit RateLimit
  }

  error Error

  example Successful {
    input {
      destination = 'C1H9RESGL',
      text = 'Our app has 1,000,000 subscribers!',
    }

    result {
      destination = 'C1H9RESGL',
      messageId = "1503435956.000247",
    }
  }

  example Failed {
    input {
      destination = 'random',
      text = 'Message to nonexistent destination',
    }

    error {
      title = 'channel_not_found',
    }
  }
}

model Error {
  """
  Title
  A short, human-readable summary of the problem type.
  """
  title!

  """
  Detail
  A human-readable explanation specific to this occurrence of the problem.
  """
  detail

  """
  Rate Limit
  Rate limit details.
  """
  rateLimit RateLimit
}

model RateLimit {
  """
  Bucket
  Different parts of API may have different rate limits.
  Bucket identifies to which part of API the rate limits apply.
  """
  bucket string

  """
  Total Requests
  Total requests available in the time window.
  """
  totalRequests number

  """
  Remaining Requests
  Remaining requests available in the time window.
  """
  remainingRequests number

  """
  Remaining Requests available in percents
  Remaining requests available in the time window in percents.
  """
  remainingRequestsPercentage number

  """
  Reset Timestamp
  Timestamp when the rate limits will reset (in Unix Timestamp ms format).
  """
  resetTimestamp number

  """
  Reset After
  Number of seconds until reset of rate limit
  """
  resetAfter number

  """
  Retry After
  Number of seconds until user can retry the request
  """
  retryAfter number
}