-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b72f1d
commit b67ede2
Showing
10 changed files
with
432 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package mrs_service_go_sdk | ||
|
||
type ApiError struct { | ||
Status int `json:"status"` | ||
Error string `json:"error"` | ||
Message interface{} `json:"message"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package mrs_service_go_sdk | ||
|
||
type TaskSummary struct { | ||
Status string `json:"status"` | ||
Result struct { | ||
PriceAudit struct { | ||
Total int `json:"total"` | ||
} `json:"priceAudit"` | ||
StockCount struct { | ||
Total int `json:"total"` | ||
} `json:"stockCount"` | ||
StockOut struct { | ||
Total int `json:"total"` | ||
} `json:"stockOut"` | ||
Replenish struct { | ||
Total int `json:"total"` | ||
} `json:"replenish"` | ||
QueueBust struct { | ||
Total int `json:"total"` | ||
} `json:"queueBust"` | ||
Checklist struct { | ||
Total int `json:"total"` | ||
} `json:"checklist"` | ||
Shrinkage struct { | ||
Total int `json:"total"` | ||
} `json:"shrinkage"` | ||
Planogram struct { | ||
Total int `json:"total"` | ||
} `json:"planogram"` | ||
Markdown struct { | ||
Total int `json:"total"` | ||
} `json:"markdown"` | ||
QualClas struct { | ||
Total int `json:"total"` | ||
} `json:"qualClas"` | ||
RecepDir struct { | ||
Total int `json:"total"` | ||
} `json:"recepDir"` | ||
RecepCen struct { | ||
Total int `json:"total"` | ||
} `json:"recepCen"` | ||
RecepTsf struct { | ||
Total int `json:"total"` | ||
} `json:"recepTsf"` | ||
PriceChang struct { | ||
Total int `json:"total"` | ||
} `json:"priceChang"` | ||
RecepCS struct { | ||
Total int `json:"total"` | ||
} `json:"recepCS"` | ||
ReplenPrep struct { | ||
Total int `json:"total"` | ||
} `json:"replenPrep"` | ||
ReplenConf struct { | ||
Total int `json:"total"` | ||
} `json:"replenConf"` | ||
StockOutFA struct { | ||
Total int `json:"total"` | ||
} `json:"stockOutFA"` | ||
} `json:"result"` | ||
} | ||
|
||
type TasksRequest struct { | ||
Status string `json:"status"` | ||
Result []Task `json:"result"` | ||
} | ||
|
||
|
||
type Task struct { | ||
Status string `json:"status"` | ||
OwnerID string `json:"ownerId"` | ||
LastUpdateUser string `json:"lastUpdateUser"` | ||
TaskType string `json:"taskType"` | ||
Counter int `json:"counter"` | ||
SetupID string `json:"setupId"` | ||
TaskName string `json:"taskName"` | ||
Description string `json:"description"` | ||
ProfileID string `json:"profileId"` | ||
DeviceID string `json:"deviceId"` | ||
StoreID string `json:"storeId"` | ||
Priority int `json:"priority"` | ||
Shared bool `json:"shared"` | ||
DocumentID string `json:"documentId"` | ||
ScheduledDate int64 `json:"scheduledDate"` | ||
ApplicationID string `json:"applicationId"` | ||
Type string `json:"_type"` | ||
UID string `json:"_uId"` | ||
UpdateDate int `json:"_updateDate"` | ||
CreateDate int `json:"_createDate"` | ||
UpdateUser string `json:"_updateUser"` | ||
CreateUser string `json:"_createUser"` | ||
Items []TaskItem `json:"items"` | ||
} | ||
|
||
|
||
|
||
type TaskItem struct { | ||
ItemID string `json:"itemId"` | ||
Status string `json:"status"` | ||
TaskID string `json:"taskId"` | ||
Type string `json:"type,omitempty"` | ||
ApplicationID string `json:"applicationId"` | ||
_Type string `json:"_type"` | ||
UID string `json:"_uId"` | ||
UpdateDate int `json:"_updateDate"` | ||
CreateDate int `json:"_createDate"` | ||
UpdateUser string `json:"_updateUser,omitempty"` | ||
CreateUser string `json:"_createUser,omitempty"` | ||
ItemEan string `json:"itemEan,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package mrs_service_go_sdk | ||
|
||
|
||
import ( | ||
"net/http" | ||
"fmt" | ||
) | ||
|
||
const TASKS_MODULE_NAME = "tasks" | ||
|
||
func (c *Client) Summary() (*TaskSummary, error) { | ||
p := TaskSummary{} | ||
|
||
url := fmt.Sprintf("%s/%s", c.BaseApi, createPath(c.Organization, c.Application,"summary")) | ||
|
||
req, err := http.NewRequest("GET", url , nil) | ||
req.Header.Set("mrs-application-id", c.AppId) | ||
|
||
if err != nil { | ||
return &p, err | ||
} | ||
|
||
err = c.Send(req, &p) | ||
if err != nil { | ||
return &p, err | ||
} | ||
|
||
|
||
return &p, nil | ||
} | ||
|
||
|
||
func (c *Client) GetTasks(items bool) (*TasksRequest, error) { | ||
p := TasksRequest{} | ||
|
||
url := fmt.Sprintf("%s/%s", c.BaseApi, createPath(c.Organization, c.Application, fmt.Sprintf("?items=%t", items))) | ||
|
||
req, err := http.NewRequest("GET", url , nil) | ||
req.Header.Set("mrs-application-id", c.AppId) | ||
|
||
if err != nil { | ||
return &p, err | ||
} | ||
|
||
err = c.Send(req, &p) | ||
if err != nil { | ||
return &p, err | ||
} | ||
|
||
|
||
return &p, nil | ||
} | ||
|
||
func createPath(org, app, extra string) string{ | ||
return fmt.Sprintf("%s/orgs/%s/apps/%s/%s/%s", TASKS_MODULE_NAME, org, app, TASKS_MODULE_NAME, extra) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mrs_service_go_sdk | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
|
||
func TestTaskSummary(t *testing.T) { | ||
|
||
cl, err := NewClient("http://52.50.91.27:8067","tlantic", "instore", "489a598e-259c-4e25-974e-5de00b29f707") | ||
if err != nil { | ||
t.Errorf( err.Error()) | ||
} | ||
|
||
summary, err := cl.Summary() | ||
|
||
if err != nil{ | ||
t.Errorf( err.Error()) | ||
} | ||
|
||
t.Log(summary.Result.PriceChang.Total) | ||
|
||
|
||
} | ||
|
||
|
||
func TestGetTasks(t *testing.T) { | ||
|
||
cl, err := NewClient("http://52.50.91.27:8067","tlantic", "instore", "489a598e-259c-4e25-974e-5de00b29f707") | ||
if err != nil { | ||
t.Errorf( err.Error()) | ||
} | ||
|
||
tasks, err := cl.GetTasks(true) | ||
|
||
if err != nil{ | ||
t.Errorf( err.Error()) | ||
} | ||
|
||
t.Log(tasks.Result) | ||
|
||
if(len(tasks.Result)>0){ | ||
task := tasks.Result[0] | ||
t.Log(task.TaskName) | ||
t.Log(task.Items) | ||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters