Swagger API and FWH

Swagger API and FWH

Postby Marc Venken » Tue Sep 22, 2020 10:39 pm

I'm using a shopcart system (shoptrader) for my online store. I'm not able to change all data by the import functions provided and changing some functions by Shoptrader will cost extra. Not a very big problem but we have FWH !!!
and so maybe I can do stuff with FWH and Swagger API that seems to be provided by Shoptrader.

Before I spend time in looking what Swagger can do for me, I have some starters questions :

I have a API code to connect, but I don't know whitch databases I can connect to...

I was abble to connect AND retrieve some data from the linkbar in Google. This was the result from the product database:

[{"uprid":"730","productId":730,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],"status":1,"quantity":"0","ean":"","sku":"","model":"KLEUR_P","hsCode":null,"name":"","price":"0.0000","taxClassId":"4","taxRate":"0.0000","isPhysical":"1","isDigital":"0","isQuotation":"0","url":"artikelen-zonder-categorie\/5f68953c837de","urlAbs":"https:\/\/www.maveco-webshop.be\/artikelen-zonder-categorie\/5f68953c837de","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dropship":"0","dateAdded":"2020-09-21 13:57:43","lastModified":"2020-09-21 13:57:43","descriptions":{"description":"","extra":"","intro":""},"images":["","","","","","","","","","","",""],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888888","name":"Artikelen zonder categorie","categoryIds":"888888","cPath":"888888"},"quantities":{"quantity":"0","physicalQuantity":"0","minimumQuantity":"0","externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"0.0000","normalPrice":"0.0000","price":"0.0000","specialPrice":"0.0000","purchasePrice":"0.0000"},"manufacturer":{"id":0,"name":"","image":""},"dimensions":{"type":"0","width":"0.00","height":"0.00","area":"0.00","weight":"0.00"},"reviews":{"count":0,"avg":0},"addons":{"multicatalog":{"enabled":0},"layover":{"enabled":1}}}]

I was not able at this time to change any values in the database (the API code is write and read anabled, but I think I can get this to work next days...

My questions :

Is there some FWH code that is working in retrieving this kind information ?

There are 2 lines of code in the online Swagger software tool :

cUrl :

curl -X PATCH "http://swagger.shoptrader.com/api/v2/customers/1?token=c5ce13c97e79b8d54ca40e75ea43c41282cb25e469c4babb8ad4400850a54624" -H "accept: application/json" -H "token: c5ce13c97e79b8d54ca40e75ea43c41282cb25e469c4babb8ad4400850a54624" -H "Content-Type: application/json" -d "{\"firstName\":\"Marco\"}"

and

Request Url :

http://swagger.shoptrader.com/api/v2/cu ... 0850a54624

What can I do with the cUrl code ?
The Request Url will give info when copied into a link bar in Chrome.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Swagger API and FWH

Postby Otto » Wed Sep 23, 2020 10:31 am

Marc, ... Not a very big problem but we have FWH !!!

and we have mod harbour
Best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Swagger API and FWH

Postby Marc Venken » Fri Nov 20, 2020 8:17 pm

I'm trying again to connect and use API

This code from the forum is actualy returning data ! (Adress, GPS coordinates...)

Code: Select all  Expand view

function api()

   local cGoogleURL := "https://nominatim.openstreetmap.org/search?format=json&q="
   local cAddress   := "Hofstraat 5,Opglabbeek"
   local aReturn, i, cTxt := ""

  // aReturn := hb_jsonDecode( WebPageContents( cGoogleURL + cAddress) )   // *** Change this ***
   aReturn := WebPageContents( cGoogleURL + cAddress)
   hb_jsondecode( aReturn, @aReturn )

   if !empty(aReturn)
      for i:=1 to len(aReturn)
         cTxt += aReturn[i,"display_name"] + e"\r\n"
         cTxt += aReturn[i,"lat"]+" "+aReturn[i,"lon"] + e"\r\n" + e"\r\n"
      next
   else
      cTxt:="not found"
   endif
   MsgInfo(cTxt)
return nil
 



This code also gives data, but I thing the text of the webshop (very large text) :roll:

Code: Select all  Expand view

function api1()

   //local cGoogleURL := "http://maps.googleapis.com/maps/api/geocode/json?address="
   //local cGoogleURL := "swagger.shoptrader.com/api/v2/products/500?search=prid"
   //local cGoogleURL := "http://maveco-webshop.be/products/500?search=prid"

   local cGoogleURL := "http://maveco-webshop.be/products/"


   local cAddress   := "search="
   local cSensor    := "500"
   local cKey       := "&key=MYKEY"

//curl -X GET "http://swagger.shoptrader.com/api/v2/products/1491?search=prid" -H "accept: application/json"
// http://swagger.shoptrader.com/api/v2/pr ... earch=prid

   MsgInfo( WebPageContents( cGoogleURL + cAddress + cSensor + cKey ) )

return nil

 


And here is a link to a sample screen in php from my webshop provider...

https://www.shoptrader.nl/partners/shoptrader-api/

AT time, I want to change some product data by API and not always by shop-import functions

Can somebody guide me for a starter function ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 109 guests