Store ApI

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I was wondering if there is an example of a widget that uses the Store API. I have made my way into this process and didn't know exactly how to proceed in getting the store api working. The documentation tells me what i need to to do but i live by examples and i wanted to see how it works before i can start adding that into my code. Thanks
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
William,

I'll flag this post and make sure to get back to you with an answer!
Photo of Alan Clayton

Alan Clayton, Official Rep

  • 8,788 Points 5k badge 2x thumb
William, can you take a look at the thread here, https://community.risevision.com/rise_vision_inc/topics/api-store-authentication-gadget-help Specifically, the third response form Alex and let us know if that helps?
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
So let me guess on this because I'm still might not be clear on this just yet. I need to copy the dist folder from https://github.com/Rise-Vision/widget-common/ and put it in my project which contains the files i need for the store. 

Then add the two js files into my html widget.
dist/config.js
dist/store-auth.js

Then I will have to initialize the object in the widget:
var _auth = new RiseVision.Common.Store.Auth();
and call the checkForDisplay function:
_auth.checkForDisplay(displayId, productCode, function(authorized) {
  _someCallback()
});
What is _someCallback() ? 

Then make sure  these are in the correct spot. 

gadgets.rpc.register("rsparam_set_" + id, RiseVision.Financial.Table.setParams);
gadgets.rpc.call("", "rsparam_get", null, id, ["additionalParams", "displayId", "companyId"]);
Photo of Alex D.

Alex D., Employee

  • 1,038 Points 1k badge 2x thumb
Hi William,

Yes, those are the only 2 files you need from the dist folder, you can copy and add them to your project.

As for the _someCallback() function, that can be any function you want to use as your callback. This callback is called every time the widget is Authenticated via the API, which should happen about once every 23 hours.

Let me know if this clears things up.

Thanks.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Ok i think i have everything working. I do have it where its seen by me in the store. My question is on the authentication part. It says in the documentation that there is supposed to be an overlay on top of the item if its not authorized. Is that something i have to setup or is that done on your end. Also i haven't seen the overlay on my testing so i didn't know if that will come when the widget is ready to go live. Thanks 
Photo of Alan Clayton

Alan Clayton, Official Rep

  • 8,788 Points 5k badge 2x thumb
The widget-common Library should take care of the overlay. Is that what you are you using to handle the authorization? http://help.risevision.com/#/developer/store-api/store-auth/auth-using-widget-common
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Yes i am but in my test i dont see an overlay. I know I'm getting authorized and unauthorized but i didn't know if the overlay would happen until the widget becomes public or not. I figured i would see it during my test but right now i haven't seen it. Thanks
Photo of Alex D.

Alex D., Employee

  • 1,038 Points 1k badge 2x thumb
Hi William,
I believe I've missed a step in the above documetation. In order for the overlay to show correctly, you have to add the following CSS file to the Widget or copy the CSS into the HTML: https://github.com/Rise-Vision/widget-common/blob/master/dist/css/store-auth.css
Let me know if that fixes your issue.
Thanks!
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
I believe that took care of the issue. I will be testing it out over the week but i think its ready.