product request multi step #146
			
				
			
		
		
		
	| 
						 | 
					@ -34,6 +34,23 @@ func (c Product) ApplyRequest(p model.ProductApplyRequestPayload) error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c Product) CreateRequestSteps(p model.ProductCreateStepsPayload) error {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Product.CreateRequestStep, toBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Error string `json:"error"`
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err = json.Unmarshal(msg.Data, &r); err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if r.Error != "" {
 | 
				
			||||||
 | 
							return errors.New(r.Error)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error {
 | 
					func (c Product) ProcessApplyRequest(p model.ProductApplyRequestPayload) error {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.Product.ProcessApplyRequest, toBytes(p))
 | 
						msg, err := natsio.GetServer().Request(subject.Product.ProcessApplyRequest, toBytes(p))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,3 +3,7 @@ package model
 | 
				
			||||||
type ProductApplyRequestPayload struct {
 | 
					type ProductApplyRequestPayload struct {
 | 
				
			||||||
	RequestID string `json:"requestId"`
 | 
						RequestID string `json:"requestId"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ProductCreateStepsPayload struct {
 | 
				
			||||||
 | 
						RequestID string `json:"requestId"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,8 +9,10 @@ func getProductValue(val string) string {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Product = struct {
 | 
					var Product = struct {
 | 
				
			||||||
	ApplyRequest        string
 | 
						ApplyRequest        string
 | 
				
			||||||
 | 
						CreateRequestStep   string
 | 
				
			||||||
	ProcessApplyRequest string
 | 
						ProcessApplyRequest string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	ApplyRequest:        getProductValue("apply_request"),
 | 
						ApplyRequest:        getProductValue("apply_request"),
 | 
				
			||||||
 | 
						CreateRequestStep:   getProductValue("create_request_step"),
 | 
				
			||||||
	ProcessApplyRequest: getProductValue("process_apply_request"),
 | 
						ProcessApplyRequest: getProductValue("process_apply_request"),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue