printdotio / printio-api

Issues + wiki for the api. See http://print.io/api
0 stars 0 forks source link

GET Producttemplates AND Product Preview API Call explanation required #31

Open djeet opened 9 years ago

djeet commented 9 years ago

1) Please explain the parameters and usage of call get_producttemplates ()

stdClass Object ( [Options] => Array ( [0] => stdClass Object ( [Spaces] => Array ( [0] => stdClass Object ( [Id] => 82A8D [Index] => 1 [Layers] => Array ( [0] => stdClass Object ( [Id] => 81E92 [Type] => Design [ZIndex] => 0 [X1] => 0 [X2] => 7500 [Y1] => 0 [Y2] => 9000 [BackgroundImageUrl] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60backv2.png )

                                        [1] => stdClass Object
                                            (
                                                [Id] => 1213F
                                                [Type] => Image
                                                [ZIndex] => 1
                                                [X1] => 0
                                                [X2] => 7500
                                                [Y1] => 0
                                                [Y2] => 9000
                                            )

                                        [2] => stdClass Object
                                            (
                                                [Id] => 7AF5B
                                                [Type] => Design
                                                [ZIndex] => 2
                                                [X1] => 0
                                                [X2] => 7500
                                                [Y1] => 0
                                                [Y2] => 9000
                                                [OverlayImageUrl] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60overlayv2.png
                                            )

                                    )

See this URL http://bakingcode.org/print_io/?function=5&submit=Submit

2) Also required explanation for :

http://bakingcode.org/print_io/?function=15&submit=Submit

Request Array ( [Sku] => WovenBlanket1_50x60 [Template] => [Images] => Array ( [LayerId] => 8BC30 [Image] => Array ( [Url] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60back.png [MaxFit] => false [X1] => 0 [X2] => 10000 [Y1] => 0 [Y2] => 12000 )

    )

[MaxHeight] => 4
[MaxWidth] => 3

) Response stdClass Object ( [ErrorReferenceCode] => ec838b70-424c-4f0d-9373-8296f8f58d25 [Errors] => Array ( [0] => stdClass Object ( [AttemptedValue] => [CustomState] => [ErrorMessage] => Must not be empty. [PropertyName] => Items )

    )

[HadError] => 1

)

3) Is there an API method to generate the preview if we pass on the images?

AustenB commented 9 years ago

@djeet this is an advanced method for advanced uses outside of our web widget.

What is the goal of your API implementation so we can best direct you?

djeet commented 9 years ago

1) I am working on custom cart using Printio's API. So i have set up Printio products at

https://grads.myyearstream.com/new_site/product-select/?requestID=9357&sid=319&yid=300&nm=John%20Smith

2) Now i want to generate a preview of user's selected image on each selected printio product .I need to generate preview similar to how you have in your web widget.This preview will help user visualize his image on Printio products.

AustenB commented 9 years ago

1) I understand. Does it make sense to use our pre-existing web-widget and cart from our Javascript SDK? It is highly customizable.

2) If you are going to generate previews continuously we should discuss the implementation. Which products do you plan to do this for?

Best,

Austen

On Wed, Jun 3, 2015 at 11:15 AM, Djeet notifications@github.com wrote:

1) I am working on custom cart using Printio's API. So i have set up Printio products at

https://grads.myyearstream.com/new_site/product-select/?requestID=9357&sid=319&yid=300&nm=John%20Smith

2) Now i want to generate a preview of user's selected image on each selected printio product .I need to generate preview similar to how you have in your web widget.This preview will help user visualize his image on Printio products.

— Reply to this email directly or view it on GitHub https://github.com/printdotio/printio-api/issues/31#issuecomment-108479156 .

Austen Bernstein Founder & CEO printio

djeet commented 9 years ago

1) Its not possible . I had discussion with your team long back and some of the integration we were looking for were just not possible via web-widget

2) You can see them over here: https://grads.myyearstream.com/new_site/product-select/?requestID=9357&sid=319&yid=300&nm=John%20Smith

Canvas Wraps Professional Prints Phone Cases Tablet Cases Mugs Metal Magnets ( disabled at the moment) Mousepads

djeet commented 9 years ago

One more note: I am hoping that after correct implementation , this error will be go http://www.awesomescreenshot.com/image/291850/3628ad36b23d95c947a6ea2ff11819e3

AustenB commented 9 years ago

1) What are the features you need -> some might be ready now that weren't before.

2) I would use templates to download the overlays and work on your side to create the preview. We will be creating a Guide for this in our new documentation so it is clear -> but basically use the Single template only. Make sure the image is matching the size of the image ratio and has the correct image placement & then place the overlay over it.

I will note that number 2 won't be very easy for you to implement but depending on your timeline - you might want to wait for our formal guide on it.

On Wed, Jun 3, 2015 at 11:28 AM, Djeet notifications@github.com wrote:

One more note: I am hoping that after correct implementation , this error will be go

http://www.awesomescreenshot.com/image/291850/3628ad36b23d95c947a6ea2ff11819e3

— Reply to this email directly or view it on GitHub https://github.com/printdotio/printio-api/issues/31#issuecomment-108484040 .

Austen Bernstein Founder & CEO printio

djeet commented 9 years ago

1) We have gone way too far in our development cycle to consider 1

2) 2.1 How soon can you get me the guide? 2.2 I just need the explanation of parameters.So visit this link: http://bakingcode.org/print_io/?function=5&submit=Submit 2.3 Can you explain how i can use parameters to generate preview at my end

Here is my understanding , help me figure it out: 1) I will have a background image.However i have confusion about units of X2 and Y2 .It has z-index 0 which i understand 2) Why 2nd array has no image whats its purpose? 3) Overlay image is the frame .I somehow need to place my image inside it? Correct? However i am not sure about dimension of my image or which parameters to use to implement correct "size of the image ratio"

[Spaces] => Array ( [0] => stdClass Object ( [Id] => 82A8D [Index] => 1 [Layers] => Array ( [0] => stdClass Object ( [Id] => 81E92 [Type] => Design [ZIndex] => 0 [X1] => 0 [X2] => 7500 [Y1] => 0 [Y2] => 9000 [BackgroundImageUrl] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60backv2.png )

                                        [1] => stdClass Object
                                            (
                                                [Id] => 1213F
                                                [Type] => Image
                                                [ZIndex] => 1
                                                [X1] => 0
                                                [X2] => 7500
                                                [Y1] => 0
                                                [Y2] => 9000
                                            )

                                        [2] => stdClass Object
                                            (
                                                [Id] => 7AF5B
                                                [Type] => Design
                                                [ZIndex] => 2
                                                [X1] => 0
                                                [X2] => 7500
                                                [Y1] => 0
                                                [Y2] => 9000
                                                [OverlayImageUrl] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60overlayv2.png
                                            )

                                    )

                            )

                    )

4) What is the purpose of

                [ImageUrl] => http://app-imgs.print.io/product-wovenblankets/wovenblanket_50x60_Single.png
AustenB commented 9 years ago

Ok.

Focus only on the image layer and the top most design layer that has an OverlayURL field.

The middle image layer is the size of X2-X1,Y2-Y1.

Then you have to have the total size of the image with the total size of the OverlayURL field and apply the image at the x1, y1 starting coordinates within that size.

To be honest it will be difficult for you to implement before I create a full guide for it. The guide wont be ready until the end of the month.

There is also a method: called product preview -> Micah can inform you more about how to use that one. That might be your best option to start.

On Wed, Jun 3, 2015 at 11:45 AM, Djeet notifications@github.com wrote:

1) We have gone way too far in our development cycle to consider 1

2) 2.1 How soon can you get me the guide? 2.2 I just need the explanation of parameters.So visit this link: http://bakingcode.org/print_io/?function=5&submit=Submit 2.3 Can you explain how i can use parameters to generate preview at my end

Here is my understanding , help me figure it out: 1) I will have a background image.However i have confusion about units of X2 and Y2 .It has z-index 0 which i understand 2) Why 2nd array has no image whats its purpose? 3) Overlay image is the frame .I somehow need to place my image inside it? Correct? However i am not sure about dimension of my image or which parameters to use to implement correct "size of the image ratio"

[Spaces] => Array ( [0] => stdClass Object ( [Id] => 82A8D [Index] => 1 [Layers] => Array ( [0] => stdClass Object ( [Id] => 81E92 [Type] => Design [ZIndex] => 0 [X1] => 0 [X2] => 7500 [Y1] => 0 [Y2] => 9000 [BackgroundImageUrl] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60backv2.png )

                                    [1] => stdClass Object
                                        (
                                            [Id] => 1213F
                                            [Type] => Image
                                            [ZIndex] => 1
                                            [X1] => 0
                                            [X2] => 7500
                                            [Y1] => 0
                                            [Y2] => 9000
                                        )

                                    [2] => stdClass Object
                                        (
                                            [Id] => 7AF5B
                                            [Type] => Design
                                            [ZIndex] => 2
                                            [X1] => 0
                                            [X2] => 7500
                                            [Y1] => 0
                                            [Y2] => 9000
                                            [OverlayImageUrl] => https://az412349.vo.msecnd.net/product-wovenblankets/wovenblanket_50x60overlayv2.png

                                        )

                                )

                        )

                )

— Reply to this email directly or view it on GitHub https://github.com/printdotio/printio-api/issues/31#issuecomment-108491900 .

Austen Bernstein Founder & CEO printio

austincprintio commented 9 years ago

@AustenB Is there anything I can do to help move this forward? They are a company that benefits greatly from being able to provide merchandise at graduation time which is right around now or coming up shortly. Should I schedule a call on Micah's calendar?

AustenB commented 9 years ago

Private message me On Jun 5, 2015 4:59 PM, "AustinC" notifications@github.com wrote:

@AustenB https://github.com/AustenB Is there anything I can do to help move this forward? They are a company that benefits greatly from being able to provide merchandise at graduation time which is right around now or coming up shortly. Should I schedule a call on Micah's calendar?

— Reply to this email directly or view it on GitHub https://github.com/printdotio/printio-api/issues/31#issuecomment-109437122 .

djeet commented 9 years ago

I am able to generate preview now .But somehow i am noticing a weird bug now. From last few "Product Preview" API calls , i get a success response.But when i check path of image , it does not exist.This happens for live and staging environment.

-If there was an issue in generation of images "HadError":false should have been set true.

{"Url":"http://cdn.print.io/img-manip/150710-16231147992102cc-0.png","HadError":false}
AustenB commented 9 years ago

Why is your Y1 = -34.

Try again with a positive number.

On Fri, Jul 10, 2015 at 12:29 PM, Djeet notifications@github.com wrote:

I am able to generate preview now .But somehow i am noticing a weird bug now. From last few "Product Preview" API calls , i get a success response.But when i check path of image , it does not exist.This happens for live and staging environment.

-If there was an issue in generation of images "HadError":false should have been set true.

{"Url":" http://cdn.print.io/img-manip/150710-16231147992102cc-0.png","HadError":false } — Reply to this email directly or view it on GitHub https://github.com/printdotio/printio-api/issues/31#issuecomment-120452234 .

Austen Bernstein Founder & CEO printio

micahasmith commented 9 years ago

can you post in your exact JSON post so that we can replay/diagnose? there are scenarios where negative numbers are fine, btw

djeet commented 9 years ago

Here is the JSON:

{"Sku":"PhoneCase-iphone5C-Matte","Template":"Single","Images":[{"LayerId":"E63E7","Image":{"Url":"http:\/\/grads.myyearstream.com\/new_site\/wp-content\/uploads\/userPreview\/Gregy Finch1436769909.jpg","MaxFit":0,"X1":-31.849411764706,"X2":708.15058823529,"Y1":-31.849411764706,"Y2":1079.1505882353}}],"MaxHeight":1111,"MaxWidth":1692}

micahasmith commented 9 years ago

I just submitted that and got:

image

{
  "Url": "http://cdn.print.io/img-manip/150713-125326540d0dbd93-4.png",
  "HadError": false
}
djeet commented 9 years ago

Hi Micah,

I am trying to troubleshoot scenario as to how this condition would occur. When i send a request , image gets generated , there is no error and URL is returned but no image is found at that URL.

http://cdn.print.io/img-manip/150710-16231147992102cc-0.png

Its an abrupt behavior and i continue to inspect it at my end. Ideally API response should throw an error in case image is not generated OR there was an problem in me sending wrong parameters.

Thanks Jeet

micahasmith commented 9 years ago

The image is not immediately available-- it gets generated asynchronously. We've measured that generation times are normally a little less than 3 seconds, though variable

micahasmith commented 9 years ago

If this is for user previews and you have the ability to make the image smaller-- do so-- it'll decrease generation time.

djeet commented 9 years ago

Yes i figured out the delay in generation of image part.

However nothing explains why this URL would still throw such response. http://cdn.print.io/img-manip/150710-16231147992102cc-0.png

Ideally If you can investigate what happened it with this image, it would help further. We don't want user to wait for long time ( for which i will lower image size) OR have a scenario where the image path generated is 404.

Do you recommend doing any kind of conditional check at my end to overcome this scenario?

micahasmith commented 9 years ago

Was it for the same request? Are you able to recreate? I've had my QA testing the req and we haven't recreated yet. The endpoint for this is idempotent--

djeet commented 9 years ago

Hi Micah ,

This is a bit urgent and i have noticed this problem for first time.

Issue Description: For Canvas Wraps 16 x 20 product template call, API sends me product template which has resolution 6900 x 5700

i.e. for product which is in "Portrait Mode" (Height> Width) the frame returned is in "Landscape Mode"(Width > Height) .I could have simply inverted the frame but when i generate preview , the API expects users image X,Y in Landscape mode.


                                            [2] => stdClass Object
                                                (
                                                    [Id] => A3762
                                                    [Type] => Design
                                                    [ZIndex] => 2
                                                    [X1] => 0
                                                    [X2] => 6900
                                                    [Y1] => 0
                                                    [Y2] => 5700
                                                    [OverlayImageUrl] => https://az412349.vo.msecnd.net/product-canvaswraps/CanvasWrap16x20-OverlayWhitev4.png
                                                    [IncludeInPrint] => 

Questions: 1) Why would API call return inverse orientation? 2) Are there some parameters in API Call where i can specify orientation? 3) What is teh best way to handle this scenario?

AustenB commented 9 years ago

Micah is away until Monday. I will do my best to help you in the meantime.

1) Products are not by default in portrait orientation they are by default in landscape orientation as it is ordered in higher volume this way. If the top of the photo is on the left side it is also available to be hung in portrait. So the top should be on the top for landscape or the top of the image on the left hand side for portrait.

2) No there are no parameters to specify orientation - only rotation if necessary. However I think this is answered in 1.

3) See number 1.

On Fri, Jul 17, 2015 at 12:52 PM, Djeet notifications@github.com wrote:

Hi Micah ,

This is a bit urgent and i have noticed this problem for first time.

Issue Description: For Canvas Wraps 16 x 20 product template call, API sends me product template which has resolution 6900 x 5700

i.e. for product which is in "Portrait Mode" (Height> Width) the frame returned is in "Landscape Mode"(Width > Height) .I could have simply inverted the frame but when i generate preview , the API expects users image X,Y in Landscape mode.

                                        [2] => stdClass Object
                                            (
                                                [Id] => A3762
                                                [Type] => Design
                                                [ZIndex] => 2
                                                [X1] => 0
                                                [X2] => 6900
                                                [Y1] => 0
                                                [Y2] => 5700
                                                [OverlayImageUrl] => https://az412349.vo.msecnd.net/product-canvaswraps/CanvasWrap16x20-OverlayWhitev4.png
                                                [IncludeInPrint] =>


Questions:
1) Why would API call return inverse orientation?
2) Are there some parameters in API Call where i can specify orientation?
3) What is teh best way to handle this scenario?

—
Reply to this email directly or view it on GitHub
https://github.com/printdotio/printio-api/issues/31#issuecomment-122341014
.

Austen Bernstein Founder & CEO printio