common.consent

io.token.proto.common.consent /common/src/main/proto/consent.proto


syntax = "proto3";
package io.token.proto.common.consent;
option java_outer_classname = "ConsentProtos";
option csharp_namespace = "Tokenio.Proto.Common.ConsentProtos";

import "account.proto";
import "extensions/field.proto";
import "money.proto";
import "token.proto";
import "transferinstructions.proto";

message Consent {
  string id = 1;                                // Same as the corresponding token id
  Beneficiary beneficiary = 2;
  string member_id = 3;

  oneof type {
    InformationAccess information_access = 5;
    Payment payment = 6;
    StandingOrder standing_order = 9;
    BulkPayment bulk_payment = 10;
  }

  string initiator_id = 7;                      // ID of the member requesting consent (e.g. merchant)
  string initiator_ref_id = 8;                  // Reference ID set by the member requesting consent
  string description = 11;                      // Optional description
  int64 created_at_ms = 12;
  int64 expires_at_ms = 13;                     // Optional for transfer consents.

  message InformationAccess {
    repeated ResourceAccess resource_access = 1;

    message ResourceAccess {
      io.token.proto.common.account.BankAccount account = 1;
      repeated ResourceType resources = 2;

      enum ResourceType {
        INVALID_RESOURCE_TYPE = 0;
        ACCOUNT = 1;
        BALANCE = 2;
        TRANSACTIONS = 3;
        TRANSFER_DESTINATIONS = 4;
        FUNDS_CONFIRMATIONS = 5;
        STANDING_ORDERS = 6;
      }
    }
  }

  message Payment {
    io.token.proto.common.account.BankAccount account = 1;
    io.token.proto.common.money.Money lifetime_amount = 2;
    io.token.proto.common.money.Money amount = 3;
    repeated io.token.proto.common.transferinstructions.TransferEndpoint destinations = 4 [deprecated=true];
    repeated io.token.proto.common.transferinstructions.TransferDestination transfer_destinations = 5;
    string remittance_reference = 6 [(io.token.proto.extensions.field.hash) = true];
  }

  message StandingOrder {
    io.token.proto.common.account.BankAccount account = 1;
    io.token.proto.common.money.Money amount = 2; // amount per charge
    string frequency = 3; // ISO 20022: DAIL, WEEK, TOWK, MNTH, TOMN, QUTR, SEMI, YEAR
    repeated io.token.proto.common.transferinstructions.TransferDestination transfer_destinations = 4;
    string remittance_reference = 5 [(io.token.proto.extensions.field.hash) = true];
  }

  message BulkPayment {
    repeated Payment payments = 1;
    io.token.proto.common.account.BankAccount account = 2;

    message Payment {
      string amount = 1;
      string currency = 2;
      string ref_id = 3;
      string description = 4;
      transferinstructions.TransferDestination destination = 5;
    }
  }

  message Beneficiary {
    io.token.proto.common.token.TokenMember member = 1;
    io.token.proto.common.token.ActingAs acting_as = 2;
  }
}

message ConsentRequest {
  string tpp_name = 1;
  string tpp_callback_url = 2;
  string tpp_ref_id = 3;
  string description = 4;
  oneof body {
    io.token.proto.common.token.TokenRequestPayload.AccessBody.ResourceTypeList resource_type_list = 5;
    io.token.proto.common.token.TokenRequestPayload.AccessBody.AccountResourceList account_resource_list = 6;
    io.token.proto.common.token.TokenRequestPayload.TransferBody transfer_body = 7;
    io.token.proto.common.token.StandingOrderBody standing_order_body = 8;
    io.token.proto.common.token.BulkTransferBody bulk_transfer_body = 9;
  }
}

message CreateConsent {
  string user_id = 1;
  string request_id = 2;
  oneof type {
    ResourceTypeAccess resource_type_access = 3;
    AccountResourceAccess account_resource_access = 4;
    Transfer transfer = 5;
    StandingOrder standing_order = 6;
    BulkTransfer bulk_transfer = 7;
  }

  message ResourceTypeAccess {
    repeated string account_identifiers = 1; // bank account identifiers (opaque to Token)
  }

  message AccountResourceAccess {}

  message Transfer {
    string account_identifier = 1;  // bank account identifier (opaque to Token)
    int64 expires_at_ms = 2;
    int64 effective_at_ms = 3;
    int64 endorse_until_ms = 4;
  }

  message StandingOrder {
    string account_identifier = 1;  // bank account identifier (opaque to Token)
    int64 expires_at_ms = 2;
    int64 effective_at_ms = 3;
    int64 endorse_until_ms = 4;
  }

  message BulkTransfer {
    string account_identifier = 1;  // bank account identifier (opaque to Token)
    int64 expires_at_ms = 2;
    int64 effective_at_ms = 3;
    int64 endorse_until_ms = 4;
  }
}

enum StatusFilter {
  INVALID = 0;
  ALL = 1;
  ACTIVE = 2;
  CANCELLED = 3;
  EXPIRED = 4;
}