RetrieveSubuserStatistics

public class RetrieveSubuserStatistics : RetrieveGlobalStatistics

The Statistic.Subuser class is used to make the Get Subuser Stats API call. At minimum you need to specify a start date.

do {
    let now = Date()
    let lastMonth = now.addingTimeInterval(-2592000) // 30 days
    let request = RetrieveSubuserStatistics(
        startDate: lastMonth,
        endDate: now,
        aggregatedBy: .week,
        subusers: "Foo", "Bar"
    )
    try Session.shared.send(modeledRequest: request) { result in
        switch result {
        case .success(_, let model):
            // The `model` property will be an array of `Statistic` structs.
            model.forEach { _ in
                // Do something with the stats here...
            }
        case .failure(let err):
            print(err)
        }
    }
} catch {
    print(error)
}
  • Initializes the request with a start date and subusers, as well as an end date and/or aggregation method.

    Declaration

    Swift

    public init(startDate: Date, endDate: Date? = nil, aggregatedBy: Statistic.Aggregation? = nil, subusers: [String])

    Parameters

    startDate

    The starting date of the statistics to retrieve.

    endDate

    The end date of the statistics to retrieve.

    aggregatedBy

    Indicates how the statistics should be grouped.

    subusers

    An array of subuser usernames to retrieve stats for (max 10).

  • Initializes the request with a start date and subusers, as well as an end date and/or aggregation method.

    Declaration

    Swift

    public convenience init(startDate: Date, endDate: Date? = nil, aggregatedBy: Statistic.Aggregation? = nil, subusers: String...)

    Parameters

    startDate

    The starting date of the statistics to retrieve.

    endDate

    The end date of the statistics to retrieve.

    aggregatedBy

    Indicates how the statistics should be grouped.

    subusers

    An array of subuser usernames to retrieve stats for (max 10).

  • Initializes the request with a start date and subusers, as well as an end date and/or aggregation method.

    Declaration

    Swift

    public convenience init(startDate: Date, endDate: Date? = nil, aggregatedBy: Statistic.Aggregation? = nil, subusers: [SendGrid.Subuser])

    Parameters

    startDate

    The starting date of the statistics to retrieve.

    endDate

    The end date of the statistics to retrieve.

    aggregatedBy

    Indicates how the statistics should be grouped.

    subusers

    An array of Subuser instances to retrieve stats for (max 10).

  • Initializes the request with a start date and subusers, as well as an end date and/or aggregation method.

    Declaration

    Swift

    public convenience init(startDate: Date, endDate: Date? = nil, aggregatedBy: Statistic.Aggregation? = nil, subusers: SendGrid.Subuser...)

    Parameters

    startDate

    The starting date of the statistics to retrieve.

    endDate

    The end date of the statistics to retrieve.

    aggregatedBy

    Indicates how the statistics should be grouped.

    subusers

    An array of Subuser instances to retrieve stats for (max 10).

  • Validates that there are no more than 10 subusers specified.

    Declaration

    Swift

    public override func validate() throws