-
-
Save twhid/df77a5a70c4b0ae3c115 to your computer and use it in GitHub Desktop.
New Image Contract idea
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
// NOTE* The notations below assume that there is only 1 size per image, ie. new dynamically sized images are already working : | |
// POST a new image : | |
// soa/inventory-3/2/image | |
// payload : multi part form-data | |
// return value : | |
{ | |
id : '123', | |
original : '/path/to/original.jpeg', | |
master : '/path/to/master.jpeg', | |
} | |
// RPC functions like rotate : | |
// soa/inventory-3/2/image/123/process | |
{ | |
type : 'ROTATION', | |
degrees : 90 | |
} | |
// PUT to existing image : | |
// soa/inventory-3/2/image/123 | |
// payload : multi part form-data | |
// return value : | |
{ | |
id : '123', | |
original : '/path/to/new-original.jpeg', | |
master : '/path/to/new-master.jpeg', | |
} | |
// item contract will no longer have fully inflated photos, but an array of associations to images : | |
// GET or PUT item : | |
// soa/inventory-3/2/item/f_123 | |
{ | |
id : 'f_123', | |
images : [ | |
{ | |
id : 123, | |
position : 1 | |
}, { | |
id : 456, | |
position : 2 | |
} | |
] | |
} | |
// NOTE* The absennce of images on the item model could be solved by inflating the images : | |
{ | |
id : 'f_123', | |
images : [ | |
{ | |
id : 123, | |
position : 1, | |
image : { | |
id : 123, | |
original : '/path/to/original.jpeg', | |
master : '/path/to/master.jpeg' | |
} | |
}, { | |
id : 456, | |
position : 2 | |
image : { | |
id : 456, | |
original : '/path/to/original.jpeg', | |
master : '/path/to/master.jpeg' | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment