"""
Represents non-fractional signed whole numeric values. Since the value may exceed the size of a 32-bit integer, it's encoded as a string.
"""
scalar BigInt

"""
An ISO 8601-encoded date
"""
scalar ISO8601Date

"""
An ISO 8601-encoded datetime
"""
scalar ISO8601DateTime

enum MetricName {
  """
  New Customers attributed to direct conversions from the campaign, such as last click attribution
  """
  FIRST_ORDER_CONVERSIONS

  """
  Leads attributed to direct conversions from the campaign, such as last click attribution
  """
  FIRST_ORDER_LEADS

  """
  Revenue attributed to direct conversions from the campaign, such as last click attribution
  """
  FIRST_ORDER_REVENUE

  """
  Subscriptions attributed to direct conversions from the campaign, such as last click attribution
  """
  FIRST_ORDER_SUBSCRIPTIONS

  """
  New Customers attributed to halo effects from the campaign
  """
  SECOND_ORDER_CONVERSIONS

  """
  Leads attributed to halo effects from the campaign
  """
  SECOND_ORDER_LEADS

  """
  Revenue attributed to halo effects from the campaign
  """
  SECOND_ORDER_REVENUE

  """
  Subscriptions attributed to halo effects from the campaign
  """
  SECOND_ORDER_SUBSCRIPTIONS
}

enum MetricUnit {
  """
  The metrics are measured in new customers
  """
  CUSTOMERS

  """
  The metrics are measured by revenue in USD
  """
  REVENUE

  """
  The metrics are measured in subscriptions
  """
  SUBSCRIPTIONS
}

type Model {
  """
  The name of the model
  """
  name: String!

  """
  The unit in which this model's metrics are measured in
  """
  unit: MetricUnit!
}

type ModeledMetricQuery {
  """
  The array containing the modeled metric rows
  """
  data: [ModeledMetricRow!]!

  """
  Pagination info for the query
  """
  pageInfo: PageInfo!
}

type ModeledMetricRow {
  """
  The type of the metric
  """
  metricName: MetricName!

  """
  The value of the metric
  """
  metricValue: Float!

  """
  The date the metric was created or last updated
  """
  processDate: ISO8601DateTime!

  """
  The date the metric corresponds to. This is a date string in the format of YYYY-MM-DD
  """
  reportedDate: String!

  """
  The ID for the campaign
  """
  sourceCampaignId: String!

  """
  The name of the campaign
  """
  sourceCampaignName: String

  """
  The tactic the campaign is labeled with in the Data Center, if any
  """
  sourceCampaignTactic: String

  """
  The data source channel of the campaign
  """
  sourceChannelName: String!

  """
  The name of the model that produced this metric
  """
  target: String!

  """
  The channel that the modeling attributes credit for this metric. Only applies to second order metrics.
  """
  targetChannelName: String
}

type PageInfo {
  """
  The cursor for the next page, if there is one
  """
  endCursor: String

  """
  Whether a next page exists or not
  """
  hasNextPage: Boolean
}

type Query {
  """
  Returns the source names of all channels you have in use.
  """
  channelNames: [String!]!

  """
  Get modeled metrics for a given date range. We recommend pulling data updates once per day. Results will be paginated, so implementations should handle making multiple calls using the `after` argument.
  """
  modeledMetrics(
    """
    The cursor to indicate where the pagination should begin. Value comes from the `pageInfo>endCursor` field in the previous response.
    """
    after: BigInt

    """
    Filter by campaign ids. These correspond to the ids of your campaigns in their respective source channels.
    """
    campaignIds: [String!]

    """
    End date for the reporting records. Defaults to today.
    """
    endDate: ISO8601Date

    """
    Filters out any records that have not been created or updated since this date. We recommend using this field in all implementations to avoid pulling large, unchanged data sets.
    """
    processDate: ISO8601Date

    """
    Sales channels to filter modeled output by. When omitted, returns both ECOMMERCE and RETAIL.
    """
    salesChannel: [SalesChannelEnum!]

    """
    Start date for the reporting records. Defaults to 30 days ago.
    """
    startDate: ISO8601Date
  ): ModeledMetricQuery!

  """
  Returns all of the available models.
  """
  models: [Model!]!

  """
  Get reported spend metrics for campaigns by date. Returns spend data per campaign/day. Results will be paginated, so implementations should handle making multiple calls using the `after` argument.
  """
  reportedMetrics(
    """
    The cursor to indicate where the pagination should begin. Value comes from the `pageInfo>endCursor` field in the previous response.
    """
    after: BigInt

    """
    Filter by campaign ids. These correspond to the ids of your campaigns in their respective source channels.
    """
    campaignIds: [String!]

    """
    End date for the reporting records. Defaults to today.
    """
    endDate: ISO8601Date

    """
    Filters out any records that have not been created or updated since this date. We recommend using this field in all implementations to avoid pulling large, unchanged data sets.
    """
    processDate: ISO8601Date

    """
    Start date for the reporting records. Defaults to 30 days ago.
    """
    startDate: ISO8601Date
  ): ReportedMetricQuery!
}

type ReportedMetricQuery {
  """
  The array containing the reported metric rows
  """
  data: [ReportedMetricRow!]!

  """
  Pagination info for the query
  """
  pageInfo: PageInfo!
}

type ReportedMetricRow {
  """
  The ID for the campaign
  """
  campaignId: String!

  """
  The name of the campaign
  """
  campaignName: String

  """
  The data source channel of the campaign
  """
  channelName: String!

  """
  The date the metric was created or last updated
  """
  processDate: ISO8601Date!

  """
  The date the metric corresponds to
  """
  reportedDate: ISO8601Date!

  """
  The spend amount for the campaign on this date
  """
  spend: Float!
}

"""
Sales channel for filtering modeled metrics output
"""
enum SalesChannelEnum {
  ECOMMERCE

  RETAIL
}
