syntax = "proto3";

package payments.methods.v1;

option go_package = "github.com/tech/sendico/pkg/proto/payments/methods/v1;methodsv1";

import "api/proto/common/pagination/v2/cursor.proto";
import "api/proto/payments/endpoint/v1/endpoint.proto";

// CreatePaymentMethodRequest is the request to create a new payment method.
message CreatePaymentMethodRequest {
  string account_ref = 1;
  string organization_ref = 2;
  payments.endpoint.v1.PaymentMethod payment_method = 3;
}

// CreatePaymentMethodResponse is the response for CreatePaymentMethod.
message CreatePaymentMethodResponse {
  payments.endpoint.v1.PaymentMethodRecord payment_method_record = 1;
}

// GetPaymentMethodRequest is the request to retrieve a payment method.
message GetPaymentMethodRequest {
  string account_ref = 1;
  string payment_method_ref = 2;
}

// GetPaymentMethodResponse is the response for GetPaymentMethod.
message GetPaymentMethodResponse {
  payments.endpoint.v1.PaymentMethodRecord payment_method_record = 1;
}

// GetPaymentMethodPrivateRequest retrieves a payment method without permission checks.
message GetPaymentMethodPrivateRequest {
  string organization_ref = 1;
  oneof selector {
    string payment_method_ref = 2;
    string payee_ref = 3;
  }
  PrivateEndpoint endpoint = 4;
}

// PrivateEndpoint specifies which side of a payment method to retrieve.
enum PrivateEndpoint {
  // PRIVATE_ENDPOINT_UNSPECIFIED is the default zero value.
  PRIVATE_ENDPOINT_UNSPECIFIED = 0;
  // PRIVATE_ENDPOINT_SOURCE retrieves the source endpoint.
  PRIVATE_ENDPOINT_SOURCE = 1;
  // PRIVATE_ENDPOINT_DESTINATION retrieves the destination endpoint.
  PRIVATE_ENDPOINT_DESTINATION = 2;
}

// GetPaymentMethodPrivateResponse is the response for GetPaymentMethodPrivate.
message GetPaymentMethodPrivateResponse {
  payments.endpoint.v1.PaymentMethodRecord payment_method_record = 1;
}

// UpdatePaymentMethodRequest is the request to update an existing payment method.
message UpdatePaymentMethodRequest {
  string account_ref = 1;
  payments.endpoint.v1.PaymentMethodRecord payment_method_record = 2;
}

// UpdatePaymentMethodResponse is the response for UpdatePaymentMethod.
message UpdatePaymentMethodResponse {
  payments.endpoint.v1.PaymentMethodRecord payment_method_record = 1;
}

// DeletePaymentMethodRequest is the request to delete a payment method.
message DeletePaymentMethodRequest {
  string account_ref = 1;
  string payment_method_ref = 2;
  bool cascade = 3;
}

// DeletePaymentMethodResponse is the response for DeletePaymentMethod.
message DeletePaymentMethodResponse {}

// SetPaymentMethodArchivedRequest is the request to archive or unarchive a payment method.
message SetPaymentMethodArchivedRequest {
  string account_ref = 1;
  string organization_ref = 2;
  string payment_method_ref = 3;
  bool archived = 4;
  bool cascade = 5;
}

// SetPaymentMethodArchivedResponse is the response for SetPaymentMethodArchived.
message SetPaymentMethodArchivedResponse {}

// ListPaymentMethodsRequest is the request to list payment methods with optional filters.
message ListPaymentMethodsRequest {
  string account_ref = 1;
  string organization_ref = 2;
  string recipient_ref = 3;
  common.pagination.v2.ViewCursor cursor = 4;
}

// ListPaymentMethodsResponse is the response for ListPaymentMethods.
message ListPaymentMethodsResponse {
  repeated payments.endpoint.v1.PaymentMethodRecord payment_methods = 1;
}

// PaymentMethodsService provides operations for managing payment methods.
service PaymentMethodsService {
  // CreatePaymentMethod creates a new payment method.
  rpc CreatePaymentMethod(CreatePaymentMethodRequest) returns (CreatePaymentMethodResponse);
  // GetPaymentMethod retrieves a payment method by reference.
  rpc GetPaymentMethod(GetPaymentMethodRequest) returns (GetPaymentMethodResponse);
  // UpdatePaymentMethod updates an existing payment method.
  rpc UpdatePaymentMethod(UpdatePaymentMethodRequest) returns (UpdatePaymentMethodResponse);
  // DeletePaymentMethod deletes an existing payment method.
  rpc DeletePaymentMethod(DeletePaymentMethodRequest) returns (DeletePaymentMethodResponse);
  // SetPaymentMethodArchived sets the archived status of a payment method.
  rpc SetPaymentMethodArchived(SetPaymentMethodArchivedRequest) returns (SetPaymentMethodArchivedResponse);
  // ListPaymentMethods retrieves a list of payment methods.
  rpc ListPaymentMethods(ListPaymentMethodsRequest) returns (ListPaymentMethodsResponse);
  // GetPaymentMethodPrivate retrieves a payment method without permission checks.
  rpc GetPaymentMethodPrivate(GetPaymentMethodPrivateRequest) returns (GetPaymentMethodPrivateResponse);
}
