syntax = "proto3";

import "google/protobuf/empty.proto";

option go_package = "github.com/UpmeshLTD/urus-aio/paid-order/server/grpc/pb";

package paidorderpb;

import "google/protobuf/timestamp.proto";

service PaidOrderService {
  rpc Ping (PingRequest) returns (PingResponse) {}

  rpc GetFulfillmentByID(GetFulfillmentRequest) returns (GetFulfillmentResponse) {}
  rpc UpdateFulfillmentDraftStatus(UpdateFulfillmentDraftStatusRequest) returns (google.protobuf.Empty) {}

  rpc GetPaidOrders(GetPaidOrdersRequest) returns (GetPaidOrderResponse) {}
  rpc UpdatePaidOrderIncorrectInformation(UpdatePaidOrderIncorrectInformationRequest) returns (google.protobuf.Empty) {}
  rpc UpdatePaidOrderShipmentId(UpdatePaidOrderShipmentIdRequest) returns (google.protobuf.Empty) {}

  rpc GetDeliveryAddressByCartID(GetDeliveryAddressByCartIDRequest) returns (GetDeliveryAddressByCartIDResponse) {}
  rpc GetDeliveryAddressByCartIDs(GetDeliveryAddressByCartIDsRequest) returns (GetDeliveryAddressByCartIDsResponse) {}

  rpc CancelArrangedShipPaidOrder(CancelArrangedShipPaidOrderRequest) returns (google.protobuf.Empty) {}
	rpc ReArrangeShipPaidOrders(ReArrangeShipPaidOrdersRequest) returns (ReArrangeShipPaidOrdersResponse) {}
}

message PingRequest {}

message PingResponse {
  int64 timestamps = 1;
  string environment  = 2;
  string hostname = 3;
}
message GetFulfillmentRequest {
	string fulfillment_id = 1;
	string workspace_id = 2;
}

message GetFulfillmentResponse {
	string id = 1;

	optional int64 courier_id = 2;
	optional int64 delivery_id = 3;

	optional int64 pickup_point_id = 4;
	google.protobuf.Timestamp pickup_time = 5;
	google.protobuf.Timestamp pickup_start_time = 6;
	google.protobuf.Timestamp pickup_end_time = 7;
	optional string pickup_instruction = 8;

	repeated OrderDetail order_details = 9;
}

message OrderDetail {
	string id = 1;
	string cart_id = 2;
	optional string shipping_group_id = 3;

	Address delivery_address = 4;
	Dimension dimension = 5;
	GeneralInformation general_information = 6;
	DeliveryDetails delivery_details = 7;
	repeated OrderItem order_items = 8;
}

message Dimension {
	optional double width = 1;
	optional double length = 2;
	optional double height = 3;
	optional double weight = 4;
}

message OrderItem {
	string id = 1;
	string item_id = 2;
	string item_post_id = 3;
	string item_name = 4;
	string item_code = 5;
	double item_price = 6;
	int64 item_quantity = 7;
	double item_sub_total = 8;
}

message Address {
	string address1 = 1;
	string address2 = 2;
	string postal_code = 3;
	string unit_number = 4;

	repeated Location sub_level_locations = 5;
}

message Location {
	string international_name = 1;
    string localized_name = 2;
	int64 parent_id = 3;
}

message GeneralInformation {
	string seller_id = 1;
	string page_name = 2;
	string customer_id = 3;
	string customer_name = 4;
	string customer_email = 5;
	string customer_phone_number = 6;
}

message DeliveryDetails {
	string delivery_option_id = 1;
	string delivery_option = 2;
	string delivery_address = 3;
	double delivery_surcharge = 4;
	string delivery_instruction = 5;
	string postal_code = 6;
	string recipient_name = 7;
	string recipient_phone_number = 8;
}

message UpdateFulfillmentDraftStatusRequest {
	string id = 1;
	bool draft = 2;
}

message UpdatePaidOrderIncorrectInformationRequest {
	string cart_id = 1;
	optional string shipping_group_id = 2;
	repeated string incorrect_information = 3;
}

message UpdatePaidOrderShipmentIdRequest {
	string cart_id = 1;
	optional string shipping_group_id = 2;
	string shipment_id = 3;
}

message GetDeliveryAddressByCartIDRequest {
	string CartID = 1;
}

message SubLevelLocation {
  string InternationalName = 1;
  string LocalizedName = 2;
}

message GetDeliveryAddressByCartIDResponseAddress {
  string ID = 1;
  string Address1 = 2;
  string Address2 = 3;
  string PostalCode = 4;
  int64 CountryID = 5;
  string UnitNumber = 6;
  repeated SubLevelLocation SubLevelLocations = 7;
}

message GetDeliveryAddressByCartIDResponse {
  string CartID = 1;
  string Owner = 2;
  string RecipientName = 3;
  string RecipientPhone = 4;
  GetDeliveryAddressByCartIDResponseAddress Address = 5;
}

message GetDeliveryAddressByCartIDsRequest {
	repeated string CartIDs = 1;
}

message GetDeliveryAddressByCartIDsResponse {
	repeated GetDeliveryAddressByCartIDResponse DeliveryAddresses = 1;
}

message GetPaidOrdersRequest {
  repeated string cart_ids = 1;
}

message PaidOrder {
  string cart_id = 1;
  optional string shipping_group_id = 2;
  google.protobuf.Timestamp created_at = 3;
}

message GetPaidOrderResponse {
  repeated PaidOrder paid_orders = 1;
}

message CancelArrangedShipPaidOrderRequest {
	string PaidOrderId = 1;
}

message ReArrangeShipPaidOrdersRequest {
	repeated string PaidOrderIDs = 1;
	string WorkspaceID = 2;
}

message ReArrangeShipPaidOrdersResponse {
	string FulfillmentID = 1;
}