getAccounts method

Future<Campaign> getAccounts(
  1. InstantlyApiClient client
)

Since Instantly has a weird design, use this function if you got the campaign's name or status first and then want to get the accounts.

Implementation

Future<Campaign> getAccounts(InstantlyApiClient client) async {
  // If the accounts are already set, return a copy of the campaign.
  if (accounts != null) return copyWith();

  // If the accounts are not set, get the campaign from the API.
  final campaign = await client.getCampaignAccounts(campaignId: id);
  return copyWith(accounts: campaign.accounts);
}