resolve method

Future<FFXDynamicLink?> resolve(
  1. String code
)

The link code names on this app's host; null when the host doesn't know it, it was turned off, or it was made on another host. Reports nothing; open does. Throws FFXDynamicLinksNotConfiguredError when off, and FFXApiError when the host can't be reached after its retries (up to four attempts, at most 3 s of waiting between them).

Implementation

Future<FFXDynamicLink?> resolve(String code) async {
  final base = _requireBase();
  if (!isShortCode(code)) return null;
  final response = await _withRetry(
    () => _core.client.get(
      _endpoint(base, '/v1/links/$code'),
      headers: const {'accept': 'application/json'},
    ),
    attempts: 4,
    maxWaiting: const Duration(seconds: 3),
    what: 'resolve link $code',
  );
  if (response.statusCode == 404) return null;
  if (response.statusCode != 200) throw _problemOf(response);
  final link = _decode(response, PublicDynamicLinkResponse.fromJson).link;
  if (!link.isActive || link.shortCode != code) return null;
  return FFXDynamicLink(
    shortCode: link.shortCode,
    routePath: link.routePath,
    routeParameters: link.routeParameters,
    title: _blankToNull(link.socialTitle),
    description: _blankToNull(link.socialDescription),
    imageUrl: _blankToNull(link.socialImageUrl),
    campaign: FFXLinkCampaign.fromJson(link.campaign.toJson()),
    forceRedirect: link.forceRedirect,
  );
}