Update inventory detail #31
			
				
			
		
		
		
	| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					package client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"github.com/Selly-Modules/natsio"
 | 
				
			||||||
 | 
						"github.com/Selly-Modules/natsio/model"
 | 
				
			||||||
 | 
						"github.com/Selly-Modules/natsio/subject"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetProductNoticesByInventory ...
 | 
				
			||||||
 | 
					func (w Warehouse) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, bsonToBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.GetProductNoticesByInventoryResponse `json:"data"`
 | 
				
			||||||
 | 
							Error string                                      `json:"error"`
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err = json.Unmarshal(msg.Data, &r); err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if r.Error != "" {
 | 
				
			||||||
 | 
							return nil, errors.New(r.Error)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return r.Data, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,6 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetProductNoticesByInventoryRequest ....
 | 
				
			||||||
 | 
					type GetProductNoticesByInventoryRequest struct {
 | 
				
			||||||
 | 
						InventoryIds []string `json:"inventoryIds"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetProductNoticesByInventoryResponse ....
 | 
				
			||||||
 | 
					type GetProductNoticesByInventoryResponse struct {
 | 
				
			||||||
 | 
						Notices []NewsAppResponse `json:"notices"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewsAppResponse ...
 | 
				
			||||||
 | 
					type NewsAppResponse struct {
 | 
				
			||||||
 | 
						ID           string        `json:"_id"`
 | 
				
			||||||
 | 
						Title        string        `json:"title,omitempty"`
 | 
				
			||||||
 | 
						Target       *TargetNewDoc `json:"target,omitempty"`
 | 
				
			||||||
 | 
						ActionType   *ActionType   `json:"action"`
 | 
				
			||||||
 | 
						ShortDesc    string        `json:"shortDesc,omitempty"`
 | 
				
			||||||
 | 
						Type         string        `json:"type"`
 | 
				
			||||||
 | 
						ShortTitle   string        `json:"shortTitle,omitempty"`
 | 
				
			||||||
 | 
						Color        string        `json:"color"`
 | 
				
			||||||
 | 
						Options      *NewsOptions  `json:"options,omitempty"`
 | 
				
			||||||
 | 
						DisplayStyle string        `json:"displayStyle"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewsOptions ...
 | 
				
			||||||
 | 
					type NewsOptions struct {
 | 
				
			||||||
 | 
						Category string `json:"category"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TargetNewDoc ...
 | 
				
			||||||
 | 
					type TargetNewDoc struct {
 | 
				
			||||||
 | 
						Type  string `json:"type,omitempty"`
 | 
				
			||||||
 | 
						Value string `json:"value,omitempty"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ActionType ...
 | 
				
			||||||
 | 
					type ActionType struct {
 | 
				
			||||||
 | 
						Type  string `json:"type"`
 | 
				
			||||||
 | 
						Value string `json:"value"`
 | 
				
			||||||
 | 
						Text  string `json:"text,omitempty"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -3,12 +3,14 @@ package subject
 | 
				
			||||||
var prefixes = struct {
 | 
					var prefixes = struct {
 | 
				
			||||||
	Communication string
 | 
						Communication string
 | 
				
			||||||
	Order         string
 | 
						Order         string
 | 
				
			||||||
 | 
						News          string
 | 
				
			||||||
	Warehouse     string
 | 
						Warehouse     string
 | 
				
			||||||
	Location      string
 | 
						Location      string
 | 
				
			||||||
	Supplier      string
 | 
						Supplier      string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	Communication: "communication",
 | 
						Communication: "communication",
 | 
				
			||||||
	Order:         "order",
 | 
						Order:         "order",
 | 
				
			||||||
 | 
						News:          "news",
 | 
				
			||||||
	Warehouse:     "warehouse",
 | 
						Warehouse:     "warehouse",
 | 
				
			||||||
	Location:      "location",
 | 
						Location:      "location",
 | 
				
			||||||
	Supplier:      "supplier",
 | 
						Supplier:      "supplier",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					package subject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func getNewsValue(val string) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s.%s", prefixes.Order, val)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var News = struct {
 | 
				
			||||||
 | 
						GetProductNoticesByInventory string
 | 
				
			||||||
 | 
					}{
 | 
				
			||||||
 | 
						GetProductNoticesByInventory: getNewsValue("get_product_notices_by_inventory"),
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue