EffectResponse.fromJson constructor

EffectResponse.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory EffectResponse.fromJson(Map<String, dynamic> json) {
  int type = convertInt(json["type_i"]);
  switch (type) {
    // Account effects
    case 0:
      return AccountCreatedEffectResponse.fromJson(json);
    case 1:
      return AccountRemovedEffectResponse.fromJson(json);
    case 2:
      return AccountCreditedEffectResponse.fromJson(json);
    case 3:
      return AccountDebitedEffectResponse.fromJson(json);
    case 4:
      return AccountThresholdsUpdatedEffectResponse.fromJson(json);
    case 5:
      return AccountHomeDomainUpdatedEffectResponse.fromJson(json);
    case 6:
      return AccountFlagsUpdatedEffectResponse.fromJson(json);
    case 7:
      return AccountInflationDestinationUpdatedEffectResponse.fromJson(json);
    // Signer effects
    case 10:
      return SignerCreatedEffectResponse.fromJson(json);
    case 11:
      return SignerRemovedEffectResponse.fromJson(json);
    case 12:
      return SignerUpdatedEffectResponse.fromJson(json);
    // Trustline effects
    case 20:
      return TrustlineCreatedEffectResponse.fromJson(json);
    case 21:
      return TrustlineRemovedEffectResponse.fromJson(json);
    case 22:
      return TrustlineUpdatedEffectResponse.fromJson(json);
    case 23:
      return TrustlineAuthorizedEffectResponse.fromJson(json);
    case 24:
      return TrustlineDeauthorizedEffectResponse.fromJson(json);
    case 25:
      return TrustlineAuthorizedToMaintainLiabilitiesEffectResponse.fromJson(
          json);
    // Trading effects
    case 30:
      return OfferCreatedEffectResponse.fromJson(json);
    case 31:
      return OfferRemovedEffectResponse.fromJson(json);
    case 32:
      return OfferUpdatedEffectResponse.fromJson(json);
    case 33:
      return TradeEffectResponse.fromJson(json);
    // Data effects
    case 40:
      return DataCreatedEffectResponse.fromJson(json);
    case 41:
      return DataRemovedEffectResponse.fromJson(json);
    case 42:
      return DataUpdatedEffectResponse.fromJson(json);
    // Bump Sequence effects
    case 43:
      return SequenceBumpedEffectResponse.fromJson(json);
    default:
      throw new Exception("Invalid operation type");
  }
}