Gloriafood integration

Continuing the discussion from SambaPOS 5.1.60 Release:

Is sambapos now compatible with gloriafood 100%?

if so how will i be able to integrate it without using the delivery setup as i dont do delivery?

I believe emre showed a basic gloriafood as an example.

1 Like

As you can see from the demonstration yes it is 100% compatible but seeing how we have only a single solution submitted by Emre himself I would consider it experimental still. You can use what he started and create your own integration. He gave you the basic idea.[quote=ā€œsid252uk, post:1, topic:11611ā€]
if so how will i be able to integrate it without using the delivery setup as i dont do delivery?
[/quote]

Just dive in and start building your own setup how you need it to run. You will need to study up on how Emre was able to get it to work specifically the jscript side.

1 Like

Hi guys
While testing the script, i followes emre instructions, but evrey time i placing an order with gloriafood, the app crash with this error:

mutation m{addEntity(entity:{
entityType:ā€œCustomersā€,name:ā€œ999 9999 99ā€,customData:[
{name:ā€œFirst Nameā€,value:ā€œmyfirstnamelā€},
{name:ā€œLast Nameā€,value:ā€œmylastnameā€},
{name:ā€œAddressā€,value:ā€œnullā€},
{name:ā€œEMail",value:"myemail@gmail.comā€}
])
{name}
}
mutation m{updateEntityState(entityTypeName:ā€œCustomersā€,entityName:ā€œ999 9999 99ā€,state:ā€œUnconfirmedā€,stateName:ā€œCStatusā€){name}}
C:\Users\user\Desktop\rest\script.js:457
getCustomer(data.addEntity.name, callback);
^

TypeError: Cannot read property ā€˜nameā€™ of null

Someone have an idea?

TNX

Looks like address is null

Thats not the full error is it?

Thanks for the quik replay
But i tried also with an adress, still i got the same error

{isEntityExists(type:ā€œCustomersā€,name:ā€œ999 9999 99ā€)}

mutation m{addEntity(entity:{
    entityType:"Customers",name:"999 9999 99",customData:[
        {name:"First Name",value:"yuval"},
        {name:"Last Name",value:"yuval"},
        {name:"Address",value:"my streed, my city"},
        {name:"EMail",value:"myemail@gmail.com"}
    ])
    {name}
}

mutation m{updateEntityState(entityTypeName:ā€œCustomersā€,entityName:ā€œ999 9999 99ā€,state:ā€œUnconfirmedā€,stateName:ā€œCStatusā€){name}}
C:\Users\user\Desktop\rest\SCRIPT.JS:457
getCustomer(data.addEntity.name, callback);
^

TypeError: Cannot read property ā€˜nameā€™ of null
at C:\Users\user\Desktop\rest\SCRIPT.JS:457:39
at IncomingMessage. (C:\Users\user\Desktop\rest\SCRIPT.JS:30:13)
at emitOne (events.js:77:13)
at IncomingMessage.emit (events.js:169:7)
at IncomingMessage.Readable.read (_stream_readable.js:368:10)
at flow (stream_readable.js:759:26)
at resume
(_stream_readable.js:739:3)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)

I got the same error trying to modify the scriptā€¦ I receive an order an automatically the script abortsā€¦

still trying to find outā€¦ LOL

G.

getCustomer(data.addEntity.name, callback);
^
TypeError: Cannot read property 'name' of null

getCustomer is returning nullā€¦ data.addEntity is null, so it cannot read the .name property.

After adding an Entity, you probably need to refresh the Cache first, before trying to ā€œgetā€ the Entity you just added.

ant idea how to do it?

There is a GQL mutation to refresh the SambaPOS cache.

I donā€™t think Entities are cached. That might be something else.

That doesnā€™t look properly formatted to me?
Should there not be a } between the closing ] and )?.. entity:{ doesnt seem to be closedā€¦

I am a little out of the loop on the GraphQL but also whats the {name}???
Is this potentially whats coming back null???

1 Like

The format is correct.

The name your referring to is its return.

Yes, there is a formatting issue there.

I donā€™t know how it worked for me maybe a copy paste issue I donā€™t knowā€¦

Can you try replacing this function?

function getAddCustomerScript(customer) {
    return `
    mutation m{addEntity(entity:{
        entityType:"${customerEntityType}",name:"${customer.phone}",customData:[
            {name:"First Name",value:"${customer.firstName}"},
            {name:"Last Name",value:"${customer.lastName}"},
            {name:"Address",value:"${customer.address}"},
            {name:"EMail",value:"${customer.email}"}
        ]})
        {name}
    }`;
}
3 Likes

I dont want to use the delivery setup (we dont do delivery) which Emre uses for the integration of this API. Would the script work without the delivery setup or does it have to be modified? (im not very good with scripts yet)

I guessed thats what it might be but my thought was that maybe that missing bracket made it a value rather than a return and since it has no value maybe what was causing the error with null value due to the missing }

nope, still the same:

mutation m{addEntity(entity:{
    entityType:"Customers",name:"999 9999 99",customData:[
        {name:"First Name",value:"yuval"},
        {name:"Last Name",value:"yuval"},
        {name:"Address",value:"HARAV HALPERIN, HERZLIYA"},
        {name:"EMail",value:"mm@gmaillamy.com"}
    ]})
    {name}
}

mutation m{updateEntityState(entityTypeName:ā€œCustomersā€,entityName:ā€œ999 9999 99ā€,state:ā€œUnconfirmedā€,stateName:ā€œCStatusā€){name}}
C:\Users\user\Desktop\rest\SCRIPT.JS:457
getCustomer(data.addEntity.name, callback);
^

TypeError: Cannot read property ā€˜nameā€™ of null
at C:\Users\user\Desktop\rest\SCRIPT.JS:457:39

The syntax is right and it returns name correctly:

It works just fine in GraphiQL as well so I dont think it was a syntax error. I mean its obviously wrong but somehow it still works so I dont think it caused his issue.