Upstream sync
This commit is contained in:
@@ -18,6 +18,10 @@ import (
|
|||||||
"gitlab.com/pactual1/backend/shared"
|
"gitlab.com/pactual1/backend/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ContractDistanceThresholdKm = float64(10)
|
||||||
|
)
|
||||||
|
|
||||||
func SaveDeviceInfo(c *gin.Context) {
|
func SaveDeviceInfo(c *gin.Context) {
|
||||||
var deviceInfo models.DeviceInfo
|
var deviceInfo models.DeviceInfo
|
||||||
rawData, _ := c.GetRawData()
|
rawData, _ := c.GetRawData()
|
||||||
@@ -48,7 +52,7 @@ func SaveDeviceInfo(c *gin.Context) {
|
|||||||
deviceInfoBytes, _ := json.Marshal(deviceInfo)
|
deviceInfoBytes, _ := json.Marshal(deviceInfo)
|
||||||
if deviceContract.BlockchainSecret == "" {
|
if deviceContract.BlockchainSecret == "" {
|
||||||
deviceContract.BlockchainSecret = shared.GenerateRandomString(BlockchainSecretLength)
|
deviceContract.BlockchainSecret = shared.GenerateRandomString(BlockchainSecretLength)
|
||||||
_, _, err := contract.UpdateContract(deviceContract)
|
deviceContract, _, err = contract.UpdateContract(deviceContract)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("SaveDeviceInfo Update Contract error: %v", err)
|
log.Printf("SaveDeviceInfo Update Contract error: %v", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not update contract secret"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not update contract secret"})
|
||||||
@@ -68,6 +72,16 @@ func SaveDeviceInfo(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not save device info in blockchain"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not save device info in blockchain"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if shared.DistanceKm(deviceInfo.Lat, deviceInfo.Lon, deviceContract.EndLat, deviceContract.EndLon) <= ContractDistanceThresholdKm {
|
||||||
|
deviceContract.Status = models.ContractStatusExecuted
|
||||||
|
_, _, err := contract.UpdateContract(deviceContract)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("SaveDeviceInfo Update Contract error: %v", err)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not update contract status"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"gitlab.com/pactual1/backend/database/device"
|
"gitlab.com/pactual1/backend/database/device"
|
||||||
"gitlab.com/pactual1/backend/models"
|
"gitlab.com/pactual1/backend/models"
|
||||||
"gitlab.com/pactual1/backend/services/blockchain"
|
"gitlab.com/pactual1/backend/services/blockchain"
|
||||||
|
"gitlab.com/pactual1/backend/services/messaging"
|
||||||
"gitlab.com/pactual1/backend/shared"
|
"gitlab.com/pactual1/backend/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -167,7 +168,9 @@ func UpdateContract(contract models.Contract) (models.Contract, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create contract in blockchain only when it is signed
|
// Create contract in blockchain only when it is signed
|
||||||
if oldContract.Status != contract.Status && contract.Status == models.ContractStatusSigned {
|
if oldContract.Status != contract.Status {
|
||||||
|
|
||||||
|
if contract.Status == models.ContractStatusSigned {
|
||||||
err = blockchain.NewService(config.AppConfig.Blockchain).CreateContract(context.Background(), shared.CovertUintToByte32(contract.ID))
|
err = blockchain.NewService(config.AppConfig.Blockchain).CreateContract(context.Background(), shared.CovertUintToByte32(contract.ID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("UpdateContract Error: Could not create contract in blockchain: %v", err)
|
log.Printf("UpdateContract Error: Could not create contract in blockchain: %v", err)
|
||||||
@@ -184,6 +187,25 @@ func UpdateContract(contract models.Contract) (models.Contract, int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
messagingChannel := messaging.GetMessagingChannel()
|
||||||
|
|
||||||
|
notification := models.Notification{
|
||||||
|
Title: "Contract Alert",
|
||||||
|
NotificationType: "Contract",
|
||||||
|
Text: fmt.Sprintf("Contract %s status updated to %s", contract.Name, contract.Status),
|
||||||
|
CompanyID: int(contract.BuyerID),
|
||||||
|
}
|
||||||
|
messagingChannel <- notification
|
||||||
|
|
||||||
|
sellerNotification := models.Notification{
|
||||||
|
Title: "Contract Alert",
|
||||||
|
NotificationType: "Contract",
|
||||||
|
Text: fmt.Sprintf("Contract %s status updated to %s", contract.Name, contract.Status),
|
||||||
|
CompanyID: int(contract.SellerID),
|
||||||
|
}
|
||||||
|
messagingChannel <- sellerNotification
|
||||||
|
}
|
||||||
|
|
||||||
return contract, status, err
|
return contract, status, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -138,7 +137,6 @@ func SaveDeviceInfoToDB(deviceInfo models.DeviceInfo, rawData []byte) (models.De
|
|||||||
return deviceInfo, device, fmt.Errorf("SaveDeviceInfo CREATE -DeviceInfo DB Error: %v", err)
|
return deviceInfo, device, fmt.Errorf("SaveDeviceInfo CREATE -DeviceInfo DB Error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
go func(deviceInfo models.DeviceInfo) {
|
go func(deviceInfo models.DeviceInfo) {
|
||||||
var contract models.Contract
|
var contract models.Contract
|
||||||
if err := shared.GetDb().Where("device_ids @> ARRAY[?]::integer[]", deviceInfo.DeviceID).First(&contract).Error; err != nil {
|
if err := shared.GetDb().Where("device_ids @> ARRAY[?]::integer[]", deviceInfo.DeviceID).First(&contract).Error; err != nil {
|
||||||
@@ -169,8 +167,6 @@ func SaveDeviceInfoToDB(deviceInfo models.DeviceInfo, rawData []byte) (models.De
|
|||||||
}
|
}
|
||||||
}(deviceInfo)
|
}(deviceInfo)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return deviceInfo, device, nil
|
return deviceInfo, device, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,8 +195,6 @@ func CountDeviceInfoByCompany(companyID uint) (int64, error) {
|
|||||||
return count, nil
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func CountDeviceBreachedAndNormalDevicesByCompany(companyID uint, startTime, endTime time.Time) (int64, int64, map[string]map[string]int64, error) {
|
func CountDeviceBreachedAndNormalDevicesByCompany(companyID uint, startTime, endTime time.Time) (int64, int64, map[string]map[string]int64, error) {
|
||||||
var contracts []models.Contract
|
var contracts []models.Contract
|
||||||
var allDeviceIDs []int64
|
var allDeviceIDs []int64
|
||||||
@@ -264,16 +258,10 @@ func CountDeviceBreachedAndNormalDevicesByCompany(companyID uint, startTime, end
|
|||||||
return inRangeCount, outOfRangeCount, monthlyCounts, nil
|
return inRangeCount, outOfRangeCount, monthlyCounts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type ContractLocationMatch struct {
|
type ContractLocationMatch struct {
|
||||||
ContractID uint
|
ContractID uint
|
||||||
DeviceInfoID uint
|
DeviceInfoID uint
|
||||||
}
|
}
|
||||||
const oneKmInDegrees = 0.009 // Approximately 1 km in degrees for lat/lon
|
|
||||||
|
|
||||||
func isWithinOneKm(lat1, lon1, lat2, lon2 float64) bool {
|
|
||||||
return math.Abs(lat1-lat2) <= oneKmInDegrees && math.Abs(lon1-lon2) <= oneKmInDegrees
|
|
||||||
}
|
|
||||||
|
|
||||||
func FetchMatchingContractsAndDeviceInfo(companyID uint64, startTime, endTime time.Time) ([]ContractLocationMatch, error) {
|
func FetchMatchingContractsAndDeviceInfo(companyID uint64, startTime, endTime time.Time) ([]ContractLocationMatch, error) {
|
||||||
var contracts []models.Contract
|
var contracts []models.Contract
|
||||||
@@ -310,8 +298,8 @@ func FetchMatchingContractsAndDeviceInfo(companyID uint64, startTime, endTime ti
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if isWithinOneKm(contract.StartLat, contract.StartLon, deviceInfo.Lat, deviceInfo.Lon) ||
|
if shared.DistanceKm(contract.StartLat, contract.StartLon, deviceInfo.Lat, deviceInfo.Lon) <= 1 ||
|
||||||
isWithinOneKm(contract.EndLat, contract.EndLon, deviceInfo.Lat, deviceInfo.Lon) {
|
shared.DistanceKm(contract.EndLat, contract.EndLon, deviceInfo.Lat, deviceInfo.Lon) <= 1 {
|
||||||
|
|
||||||
results = append(results, ContractLocationMatch{
|
results = append(results, ContractLocationMatch{
|
||||||
ContractID: contract.ID,
|
ContractID: contract.ID,
|
||||||
@@ -324,4 +312,3 @@ func FetchMatchingContractsAndDeviceInfo(companyID uint64, startTime, endTime ti
|
|||||||
|
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
700
postman/Backend.postman_collection.json
Normal file
700
postman/Backend.postman_collection.json
Normal file
@@ -0,0 +1,700 @@
|
|||||||
|
{
|
||||||
|
"info": {
|
||||||
|
"_postman_id": "cae9b5db-2e4f-46c8-9f86-51c530d51c36",
|
||||||
|
"name": "Backend",
|
||||||
|
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
|
||||||
|
"_exporter_id": "29923405",
|
||||||
|
"_collection_link": "https://pactual-toptal.postman.co/workspace/pactual-toptal-Workspace~afe12f79-75cd-428c-8cbd-e47c5f2cad3c/collection/29923405-cae9b5db-2e4f-46c8-9f86-51c530d51c36?action=share&source=collection_link&creator=29923405"
|
||||||
|
},
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Contract",
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Create Contracts",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\n \"sellerId\": 1,\n \"buyerId\": 2,\n \"description\": \"This is a sample contract.\",\n \"productId\": 3,\n \"minTemp\": -20.0,\n \"maxTemp\": 40.0,\n \"arrivalDate\": 1674019200,\n \"penaltyType\": \"AMOUNT\",\n \"penaltyValue\": 100,\n \"penaltyRec\": \"DAILY\"\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "{{URL}}/contracts/create"
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Create Contracts",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\n \"sellerId\": 1,\n \"buyerId\": 2,\n \"description\": \"This is a sample contract.\",\n \"productId\": 3,\n \"minTemp\": -20.0,\n \"maxTemp\": 40.0,\n \"arrivalDate\": 1674019200,\n \"penaltyType\": \"AMOUNT\",\n \"penaltyValue\": 100,\n \"penaltyRec\": \"DAILY\"\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "{{URL}}/contracts/create"
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Fri, 06 Oct 2023 08:40:15 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Length",
|
||||||
|
"value": "61"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"id\": 9,\n \"message\": \"Successfully received and saved contract\"\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "UpdateContract",
|
||||||
|
"request": {
|
||||||
|
"method": "PATCH",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\n \"deviceIds\": [1,2],\n \"status\": \"active\"\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "{{URL}}/contracts/2"
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Create Contracts",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\n \"sellerId\": 1,\n \"buyerId\": 2,\n \"description\": \"This is a sample contract.\",\n \"productId\": 3,\n \"minTemp\": -20.0,\n \"maxTemp\": 40.0,\n \"arrivalDate\": 1674019200,\n \"penaltyType\": \"AMOUNT\",\n \"penaltyValue\": 100,\n \"penaltyRec\": \"DAILY\"\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "{{URL}}/contracts/create"
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Fri, 06 Oct 2023 08:40:15 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Length",
|
||||||
|
"value": "61"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"id\": 9,\n \"message\": \"Successfully received and saved contract\"\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Contracts for Buyers",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/contracts"
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Get Contracts for Buyers",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/contracts"
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Fri, 06 Oct 2023 08:27:52 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Length",
|
||||||
|
"value": "1056"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"data\": [\n {\n \"status\": {\n \"key\": \"Unknown\",\n \"value\": \"unknown\"\n },\n \"buyer\": {\n \"id\": 2,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 7,\n \"numberOfDevices\": 0,\n \"dateCreated\": \"2023-10-06T08:36:23.752245+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Unknown\",\n \"value\": \"unknown\"\n },\n \"buyer\": {\n \"id\": 2,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 6,\n \"numberOfDevices\": 0,\n \"dateCreated\": \"2023-10-06T08:25:40.488392+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Active\",\n \"value\": \"active\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 1,\n \"numberOfDevices\": 3,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Pending signature\",\n \"value\": \"pending\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 2,\n \"numberOfDevices\": 1,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Active\",\n \"value\": \"active\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 3,\n \"numberOfDevices\": 4,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Active\",\n \"value\": \"active\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 4,\n \"numberOfDevices\": 4,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n }\n ],\n \"total\": 6\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Contracts By Id",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/contracts/1"
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Get Contracts for Buyers",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/contracts"
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Fri, 06 Oct 2023 08:27:52 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Length",
|
||||||
|
"value": "1056"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"data\": [\n {\n \"status\": {\n \"key\": \"Unknown\",\n \"value\": \"unknown\"\n },\n \"buyer\": {\n \"id\": 2,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 7,\n \"numberOfDevices\": 0,\n \"dateCreated\": \"2023-10-06T08:36:23.752245+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Unknown\",\n \"value\": \"unknown\"\n },\n \"buyer\": {\n \"id\": 2,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 6,\n \"numberOfDevices\": 0,\n \"dateCreated\": \"2023-10-06T08:25:40.488392+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Active\",\n \"value\": \"active\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 1,\n \"numberOfDevices\": 3,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Pending signature\",\n \"value\": \"pending\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 2,\n \"numberOfDevices\": 1,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Active\",\n \"value\": \"active\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 3,\n \"numberOfDevices\": 4,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n },\n {\n \"status\": {\n \"key\": \"Active\",\n \"value\": \"active\"\n },\n \"buyer\": {\n \"id\": 1,\n \"name\": \"Nova kompanija\"\n },\n \"contractID\": 4,\n \"numberOfDevices\": 4,\n \"dateCreated\": \"2023-09-13T08:36:41.742294+02:00\"\n }\n ],\n \"total\": 6\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "GetContractStatuses",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/contracts/statuses"
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "GetContractStatuses",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/contracts/statuses"
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Fri, 06 Oct 2023 08:28:42 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Length",
|
||||||
|
"value": "292"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"data\": [\n {\n \"key\": \"active\",\n \"value\": \"Active\"\n },\n {\n \"key\": \"pending\",\n \"value\": \"Pending signature\"\n },\n {\n \"key\": \"draft\",\n \"value\": \"Draft\"\n },\n {\n \"key\": \"signed\",\n \"value\": \"Signed\"\n },\n {\n \"key\": \"ready_for_activation\",\n \"value\": \"Ready for Activation\"\n },\n {\n \"key\": \"executed\",\n \"value\": \"Executed\"\n },\n {\n \"key\": \"revoked\",\n \"value\": \"Revoked\"\n }\n ]\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Text Template",
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "List text templates",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{URL}}/text_templates?offset=0&limit=20",
|
||||||
|
"host": [
|
||||||
|
"{{URL}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"text_templates"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "offset",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Response",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/text_templates?offset=0&limit=20",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"text_templates"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "offset",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Tue, 26 Sep 2023 10:27:00 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Length",
|
||||||
|
"value": "152"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"text_templates\": [\n {\n \"ID\": 1,\n \"CreatedAt\": \"2023-09-25T16:58:33.345979Z\",\n \"UpdatedAt\": \"2023-09-25T16:58:33.345979Z\",\n \"DeletedAt\": null,\n \"Value\": \"a\"\n }\n ],\n \"total\": 1\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Product Template",
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "List product template",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{URL}}/product_templates?offset=0&limit=20",
|
||||||
|
"host": [
|
||||||
|
"{{URL}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"product_templates"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "offset",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Response",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/product_templates?offset=0&limit=20",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"product_templates"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "offset",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Mon, 25 Sep 2023 16:55:54 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Transfer-Encoding",
|
||||||
|
"value": "chunked"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"product_templates\": [\n {\n \"ID\": 17,\n \"CreatedAt\": \"2023-09-25T16:45:01.586172Z\",\n \"UpdatedAt\": \"2023-09-25T16:45:01.586172Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 16,\n \"CreatedAt\": \"2023-09-25T16:44:45.66992Z\",\n \"UpdatedAt\": \"2023-09-25T16:44:45.66992Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 15,\n \"CreatedAt\": \"2023-09-25T16:44:38.975468Z\",\n \"UpdatedAt\": \"2023-09-25T16:44:38.975468Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 14,\n \"CreatedAt\": \"2023-09-25T16:43:55.978523Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:55.978523Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 13,\n \"CreatedAt\": \"2023-09-25T16:43:49.435178Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:49.435178Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 12,\n \"CreatedAt\": \"2023-09-25T16:43:15.815458Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:15.815458Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 11,\n \"CreatedAt\": \"2023-09-25T16:43:03.75841Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:03.75841Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 10,\n \"CreatedAt\": \"2023-09-25T16:40:26.031528Z\",\n \"UpdatedAt\": \"2023-09-25T16:40:26.031528Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 9,\n \"CreatedAt\": \"2023-09-25T16:39:54.451953Z\",\n \"UpdatedAt\": \"2023-09-25T16:39:54.451953Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 8,\n \"CreatedAt\": \"2023-09-25T16:38:34.110926Z\",\n \"UpdatedAt\": \"2023-09-25T16:38:34.110926Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 7,\n \"CreatedAt\": \"2023-09-25T16:37:05.161071Z\",\n \"UpdatedAt\": \"2023-09-25T16:37:05.161071Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 6,\n \"CreatedAt\": \"2023-09-25T16:36:19.275174Z\",\n \"UpdatedAt\": \"2023-09-25T16:36:19.275174Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 5,\n \"CreatedAt\": \"2023-09-25T16:34:20.104245Z\",\n \"UpdatedAt\": \"2023-09-25T16:34:20.104245Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 4,\n \"CreatedAt\": \"2023-09-25T16:32:59.988835Z\",\n \"UpdatedAt\": \"2023-09-25T16:32:59.988835Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 3,\n \"CreatedAt\": \"2023-09-25T16:32:55.449467Z\",\n \"UpdatedAt\": \"2023-09-25T16:32:55.449467Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 2,\n \"CreatedAt\": \"2023-09-25T16:30:27.334546Z\",\n \"UpdatedAt\": \"2023-09-25T16:30:27.334546Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 1,\n \"CreatedAt\": \"2023-09-25T16:28:28.085355Z\",\n \"UpdatedAt\": \"2023-09-25T16:28:28.085355Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n }\n ],\n \"total\": 17\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Product Template by ID",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "{{URL}}/product_templates/1"
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Response",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/product_templates?offset=0&limit=20",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"product_templates"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "offset",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Mon, 25 Sep 2023 16:55:54 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Transfer-Encoding",
|
||||||
|
"value": "chunked"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"product_templates\": [\n {\n \"ID\": 17,\n \"CreatedAt\": \"2023-09-25T16:45:01.586172Z\",\n \"UpdatedAt\": \"2023-09-25T16:45:01.586172Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 16,\n \"CreatedAt\": \"2023-09-25T16:44:45.66992Z\",\n \"UpdatedAt\": \"2023-09-25T16:44:45.66992Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 15,\n \"CreatedAt\": \"2023-09-25T16:44:38.975468Z\",\n \"UpdatedAt\": \"2023-09-25T16:44:38.975468Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 14,\n \"CreatedAt\": \"2023-09-25T16:43:55.978523Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:55.978523Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 13,\n \"CreatedAt\": \"2023-09-25T16:43:49.435178Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:49.435178Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 12,\n \"CreatedAt\": \"2023-09-25T16:43:15.815458Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:15.815458Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 11,\n \"CreatedAt\": \"2023-09-25T16:43:03.75841Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:03.75841Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 10,\n \"CreatedAt\": \"2023-09-25T16:40:26.031528Z\",\n \"UpdatedAt\": \"2023-09-25T16:40:26.031528Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 9,\n \"CreatedAt\": \"2023-09-25T16:39:54.451953Z\",\n \"UpdatedAt\": \"2023-09-25T16:39:54.451953Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 8,\n \"CreatedAt\": \"2023-09-25T16:38:34.110926Z\",\n \"UpdatedAt\": \"2023-09-25T16:38:34.110926Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 7,\n \"CreatedAt\": \"2023-09-25T16:37:05.161071Z\",\n \"UpdatedAt\": \"2023-09-25T16:37:05.161071Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 6,\n \"CreatedAt\": \"2023-09-25T16:36:19.275174Z\",\n \"UpdatedAt\": \"2023-09-25T16:36:19.275174Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 5,\n \"CreatedAt\": \"2023-09-25T16:34:20.104245Z\",\n \"UpdatedAt\": \"2023-09-25T16:34:20.104245Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 4,\n \"CreatedAt\": \"2023-09-25T16:32:59.988835Z\",\n \"UpdatedAt\": \"2023-09-25T16:32:59.988835Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 3,\n \"CreatedAt\": \"2023-09-25T16:32:55.449467Z\",\n \"UpdatedAt\": \"2023-09-25T16:32:55.449467Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 2,\n \"CreatedAt\": \"2023-09-25T16:30:27.334546Z\",\n \"UpdatedAt\": \"2023-09-25T16:30:27.334546Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 1,\n \"CreatedAt\": \"2023-09-25T16:28:28.085355Z\",\n \"UpdatedAt\": \"2023-09-25T16:28:28.085355Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n }\n ],\n \"total\": 17\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Locations",
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "List locations",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{URL}}/locations?q=abc",
|
||||||
|
"host": [
|
||||||
|
"{{URL}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"locations"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "q",
|
||||||
|
"value": "abc"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"name": "Response",
|
||||||
|
"originalRequest": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost:8080/product_templates?offset=0&limit=20",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"port": "8080",
|
||||||
|
"path": [
|
||||||
|
"product_templates"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "offset",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"value": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": "OK",
|
||||||
|
"code": 200,
|
||||||
|
"_postman_previewlanguage": "json",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Credentials",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Headers",
|
||||||
|
"value": "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Methods",
|
||||||
|
"value": "POST, OPTIONS, GET, PUT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Access-Control-Allow-Origin",
|
||||||
|
"value": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Date",
|
||||||
|
"value": "Mon, 25 Sep 2023 16:55:54 GMT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Transfer-Encoding",
|
||||||
|
"value": "chunked"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cookie": [],
|
||||||
|
"body": "{\n \"product_templates\": [\n {\n \"ID\": 17,\n \"CreatedAt\": \"2023-09-25T16:45:01.586172Z\",\n \"UpdatedAt\": \"2023-09-25T16:45:01.586172Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 16,\n \"CreatedAt\": \"2023-09-25T16:44:45.66992Z\",\n \"UpdatedAt\": \"2023-09-25T16:44:45.66992Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 15,\n \"CreatedAt\": \"2023-09-25T16:44:38.975468Z\",\n \"UpdatedAt\": \"2023-09-25T16:44:38.975468Z\",\n \"DeletedAt\": null,\n \"Name\": \"Name\"\n },\n {\n \"ID\": 14,\n \"CreatedAt\": \"2023-09-25T16:43:55.978523Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:55.978523Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 13,\n \"CreatedAt\": \"2023-09-25T16:43:49.435178Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:49.435178Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 12,\n \"CreatedAt\": \"2023-09-25T16:43:15.815458Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:15.815458Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 11,\n \"CreatedAt\": \"2023-09-25T16:43:03.75841Z\",\n \"UpdatedAt\": \"2023-09-25T16:43:03.75841Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 10,\n \"CreatedAt\": \"2023-09-25T16:40:26.031528Z\",\n \"UpdatedAt\": \"2023-09-25T16:40:26.031528Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 9,\n \"CreatedAt\": \"2023-09-25T16:39:54.451953Z\",\n \"UpdatedAt\": \"2023-09-25T16:39:54.451953Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 8,\n \"CreatedAt\": \"2023-09-25T16:38:34.110926Z\",\n \"UpdatedAt\": \"2023-09-25T16:38:34.110926Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 7,\n \"CreatedAt\": \"2023-09-25T16:37:05.161071Z\",\n \"UpdatedAt\": \"2023-09-25T16:37:05.161071Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 6,\n \"CreatedAt\": \"2023-09-25T16:36:19.275174Z\",\n \"UpdatedAt\": \"2023-09-25T16:36:19.275174Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 5,\n \"CreatedAt\": \"2023-09-25T16:34:20.104245Z\",\n \"UpdatedAt\": \"2023-09-25T16:34:20.104245Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 4,\n \"CreatedAt\": \"2023-09-25T16:32:59.988835Z\",\n \"UpdatedAt\": \"2023-09-25T16:32:59.988835Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 3,\n \"CreatedAt\": \"2023-09-25T16:32:55.449467Z\",\n \"UpdatedAt\": \"2023-09-25T16:32:55.449467Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 2,\n \"CreatedAt\": \"2023-09-25T16:30:27.334546Z\",\n \"UpdatedAt\": \"2023-09-25T16:30:27.334546Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n },\n {\n \"ID\": 1,\n \"CreatedAt\": \"2023-09-25T16:28:28.085355Z\",\n \"UpdatedAt\": \"2023-09-25T16:28:28.085355Z\",\n \"DeletedAt\": null,\n \"Name\": \"a\"\n }\n ],\n \"total\": 17\n}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "prerequest",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"variable": [
|
||||||
|
{
|
||||||
|
"key": "URL",
|
||||||
|
"value": "http://localhost:8080"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -4,7 +4,28 @@
|
|||||||
|
|
||||||
package shared
|
package shared
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RoleAdmin string = "admin"
|
RoleAdmin string = "admin"
|
||||||
RoleProUser string = "pro-user"
|
RoleProUser string = "pro-user"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func DistanceKm(lat1 float64, lng1 float64, lat2 float64, lng2 float64) float64 {
|
||||||
|
radlat1 := float64(math.Pi * lat1 / 180)
|
||||||
|
radlat2 := float64(math.Pi * lat2 / 180)
|
||||||
|
|
||||||
|
theta := float64(lng1 - lng2)
|
||||||
|
radtheta := float64(math.Pi * theta / 180)
|
||||||
|
|
||||||
|
dist := math.Sin(radlat1)*math.Sin(radlat2) + math.Cos(radlat1)*math.Cos(radlat2)*math.Cos(radtheta)
|
||||||
|
if dist > 1 {
|
||||||
|
dist = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
dist = math.Acos(dist)
|
||||||
|
dist = dist * 180 / math.Pi
|
||||||
|
dist = dist * 60 * 1.1515
|
||||||
|
|
||||||
|
return dist * 1.609344
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user