syntax = "proto3";

package io.restorecommerce.fulfillment_courier;

import "google/protobuf/any.proto";
import "io/restorecommerce/resource_base.proto";
import "io/restorecommerce/meta.proto";
import "io/restorecommerce/auth.proto";
import "io/restorecommerce/attribute.proto";
import "io/restorecommerce/status.proto";
import "io/restorecommerce/options.proto";

// Used by resolvers
import "io/restorecommerce/shop.proto";

/**
Microservice defination
*/

service FulfillmentCourierService {
  rpc Read (io.restorecommerce.resourcebase.ReadRequest) returns (FulfillmentCourierListResponse) {
    option (io.restorecommerce.options.is_query) = true;
  };
  rpc Create (FulfillmentCourierList) returns (FulfillmentCourierListResponse);
  rpc Update (FulfillmentCourierList) returns (FulfillmentCourierListResponse);
  rpc Upsert (FulfillmentCourierList) returns (FulfillmentCourierListResponse);
  rpc Delete (io.restorecommerce.resourcebase.DeleteRequest) returns (io.restorecommerce.resourcebase.DeleteResponse);
}

enum SupportedAPI {
  DHLRest = 0;
}

message FulfillmentCourier {
  option (restorecommerce.options.kafka_subscriber) = {
    plural: "fulfillmentCouriers"
    topic: "io.restorecommerce.fulfillment_courier.resource"
    created: "fulfillmentCourierCreated"
    updated: "fulfillmentCourierUpdated"
    deleted: "fulfillmentCourierDeleted"
  };

  optional string id = 1;
  optional io.restorecommerce.meta.Meta meta = 2;
  repeated string shop_ids = 3 [
    (io.restorecommerce.options.resolver) = {
      target_type: ".io.restorecommerce.shop.Shop",
      target_service: "master_data",
      target_sub_service: "shop",
      target_method: "Read",
      field_name: "shops",
    }
  ];
  optional string name = 4;
  optional string description = 5;
  optional string logo = 6;
  optional string website = 7;
  optional string credential_id = 8;
  optional google.protobuf.Any configuration = 9;
  optional string api = 10; // should be SupportedAPI (but unconstrained)
  repeated io.restorecommerce.attribute.Attribute attributes = 11; 
}

message FulfillmentCourierList {
  repeated FulfillmentCourier items = 1;
  optional uint32 total_count = 2;
  optional io.restorecommerce.auth.Subject subject = 3;
}

message FulfillmentCourierResponse {
  optional FulfillmentCourier payload = 1;
  optional io.restorecommerce.status.Status status = 2;
}

message FulfillmentCourierListResponse {
  repeated FulfillmentCourierResponse items = 1;
  optional uint32 total_count = 2;
  optional io.restorecommerce.status.OperationStatus operation_status = 3;
}

