Git Product home page Git Product logo

tmp's Introduction

BE AWARE

This code is for demonstration purposes. It doesn't work. Read only.

Base API

Common

Content negotiation:
By default all data is sent and received as JSON. "Content-Type" header should be set to application/json

Pagination:
Requests that return multiple items will be paginated to 25 items by default. You can control it with start and limit parameters. If limit is more than 100, default value will be set.

Errors:

  • If item is not found, 200 OK and empty result: {} or [] will be sent.
  • Sending invalid JSON will result in a 400 Bad Request response.
  • Sending the wrong type of JSON values will result in a 400 Bad Request response.
  • Sending invalid fields will result in a 422 Unprocessable Entity response.

Every 4XX response contains JSON with an error object like

{
	"errors": [
		{
			"classification": "DeserializationError",
			"message": "invalid character '\\\\' looking for beginning of value"
		}
	]
}

/garments

Get garments list. Create new garment.

Endpoint: http://v2.local/api/garments

Methods:

  • GET, POST

Parameters:

  • ids Coma separated list of ids.
  • start Skip "n" records.
  • limit Limit selection. Default value is 50.

Result: Array of garment objects

e.g.:

GET /garments?ids=93e92e72-1bdb-436f-bdb9-52dba6c16176

[
	{ 
		/* Garment Object */ 
	},
]

/garments/:id

Endpoint: http://v2.local/api/garments/:id

Methods: Get, update and delete certain garment.

  • GET, PUT, DELETE
Garment Model
[
	{
		
		"id"        : "43a5dbed-4abb-452a-8f82-9a86e555930b",     // Garment Id as a uuid
		"gid"       : "43a5dbed-4abb-452a-8f82-123123123123",     // Group id
		"dummy_id"  : "0ae99696-0e13-4c54-8ad7-d1488dffbf65",
		"name"      : "Some name",
		"size_name" : "M",         // (String) Size, e.g. "XL", "42", etc...

		"sizes" : [
			{
				"id"        : "43a5dbed-4abb-452a-8f82-9a86e555930b",
				"size_name" : "S"
			},
			{
				"id"        : "33a6dbed-4abb-452a-8f82-1a16e666930a",
				"size_name" : "X"
			}  
		],

		"color" : "", // @todo		
		"slot"  : "some string",
		"layer" : 1.0,

		"url_prefix": "//v2.local/assets",

		"assets" : {
			"geometry" : {
				"id"   : "22a6dbed-1aab-452b-8f81-2a16e994120b"
			},
			"placeholder" : {
				"id"      : "542d25c0000000000000000d"
			}			
		},
		
		"materials" : [
			{
				// material object
			},
			
			{
				// material object
			}
		]
		
	},	
]

/user

Endpoint: http://v2.local/api/user

Methods:

  • GET, POST, PUT

Parameters:

Result: Object

User Model
{
	"dummy": {
		"id": "0ae99696-0e13-4c54-8ad7-d1488dffbf65",
		"default": true,
		"assets": {
			"geometry": {
				"id" : "e748f388-36f8-47a2-b012-61f1083b80e7"
			}
		},
		
		"body": {
			"height"    : 174.0,
			"chest"     : 95.0,
			"underbust" : 72.0,
			"waist"     : 61.5,
			"hips"      : 89.0
		},
	},
	
	"history" : [ 
		{
			"id"       : "e748f388-36f8-47a2-b012-61f1083b80e7", 
			"gid"      : "43a5dbed-4abb-452a-8f82-123123123123",
			"dummy_id" : "0ae99696-0e13-4c54-8ad7-d1488dffbf65",
			"name"     : "Some name",
			
				// ... full garment model ...
		},
	],

	// Personal settings for objects. Control with /user/objects API
	/* Unused
	"objects" : [
		{
			"id" : "e748f388-36f8-47a2-b012-61f1083b80e7",
			"assets" : {
				"placeholder" : {
					"id"  : "53b54559fcb05d3238000002",
				}
			}
		},
		{
			"id"     : "f848f388-41f1-43b3-b012-31f1023b11e1",
			"assets" : {
				"placeholder" : {
					"id"  : "53b54559fcb05d3238000002",
				}
			}
		}		
	]
	*/
}

To get morphed mannequin, just add all users body parameters to the dummy link, e.g.:

GET v2.local/assets/22a6dbed-1aab-452b-8f81-2a16e994120b?height=174.0&chest=95.0&underbust=72.0&waist=61.5&hips=89.0

Placeholders and History

@ todo description

/dummies

Create and Get methods for dummies

Endpoint: http://v2.local/api/dummies

Methods:

  • GET, POST

Parameters:

Result: Array of Objects or Object for POST

Dummy Model
{
	"id"         : "0ae99696-0e13-4c54-8ad7-d1488dffbf65",
	"name"       : "default dummy",
	"default"    : true,
	"url_prefix" : "//v2.local/assets",  

	"assets": {
		"geometry": {
			"id"  : "e748f388-36f8-47a2-b012-61f1083b80e7"
		}
	},
	
	"body": {
		"chest"     : 91.154,
		"underbust" : 77.13,
		"waist"     : 66.71,
		"hips"      : 88.88,
		"height"    : 170
	}
}

/dummies/:id

Update and Delete methods for dummy object

Endpoint: http://v2.local/api/dummies/:id

Methods:

  • GET, PUT, DELETE

Result: Dummy object

Example:

curl -XPOST -H "Content-Type:application/json" -d '
{
	"name"    : "default dummy", 
	"default" : true, 
	"assets"  : {
		"geometry" : {
			"id" : "e748f388-36f8-47a2-b012-61f1083b80e7"
		}
	}
}' http://v2.local/api/dummies

Result:

{
	"id"         : "0ae99696-0e13-4c54-8ad7-d1488dffbf65",
	"name"       : "default dummy",
	"default"    : true,
	"url_prefix" : "//v2.local/assets",  
	"assets": {
		"geometry": {
			"id"  : "e748f388-36f8-47a2-b012-61f1083b80e7"
		}
	},
	"body": {}
}

/materials

Create and Get materials

Endpoint: http://v2.local/api/materials

Methods:

  • GET, POST

Result: Array of objects

Expected POST data: Array of objects

Material Object

{
    "id"   : "4717c27a-9fb0-4d09-ad70-2ae01f85deeb",
    "name" : "Test Material",
    "ka"   : "0.0435 0.0435 0.0435",
    "kd"   : "0.1086 0.1086 0.1086",
    "ks"   : "0.0000 0.0000 0.0000",
    "illum": 6,
    "d"    : "-halo 0.6600",
    "ns"   : "10.0000",
    "ni"   : "1.19713",
    
    "map_ka" : {
    	"id"       : "54390be70000000000000001",
    	"orig_name": "test_300.jpg",
    	"options"  : "-s 1 1 1 -o 0 0 0 -mm 0 1"
    },
    
    "map_kd" : {
    	"id"         : "54390be70000000000000001",
    	"orig_name"  : "test_300.jpg",
    	"options"    : "-s 1 1 1 -o 0 0 0 -mm 0 1"
    }
}

1. Create Material

POST /materials [ {some material data}, {some material data} ]

As a result, you will get an array of generated ids. E.g.

[
  "48e1f441-1c50-4f17-9c39-360cf5ecc99c",
  "fab465a2-19f0-4067-8216-b456a7742b8f"
]

2. Use these ids array as a value for materials field of a garment object, e.g.:

PUT /garments/4717c27a-9fb0-4d09-ad70-2ae01f85deeb 
{
	"materials" : [
		"48e1f441-1c50-4f17-9c39-360cf5ecc99c",
		"fab465a2-19f0-4067-8216-b456a7742b8f"
	]
}

tmp's People

Contributors

3d0c avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.