SambaPOS API Integration with NewBook PMS/Booking System

We can help don’t hesitate to ask when you get stumped.

1 Like

Appreciated, will be speaking to you Monday then LOL

As first time even looking at scripts in Samba just trying to at least understand the workflow in Samba which is the side I understand more about :smile:
Is where scripts actually get implemented.

There is execute script but presume this is to run an automation type script.

As what I think should be a simpler example;
If you wanted to say update an entity field, say because I wanted to setup custom entity grid to show guest name next to room number.
My first impression would be an update entity data action with field value of {CALL:xxxx} where xxxx is the script name for the script which would look up the guest name for the room??
Obviously variable actions add an additional complexity but just as a basic example if I wanted to updated room 1 with room 1’s guest name.

Hopefully I’m not too far wrong with this?

Your correct CALL:X will return whatever value your function returns granted it’s valid and formatted for what your doing correctly.

There is a built in way to test your functions without leaving the script editor it’s located bottom right.

1 Like

Nice one, step 1 of 99 ticked LOL
Actually that is a revilement as after the general tutorial video I watched was thinking I would be getting big list of the values dumped but now the JSON basics part makes more sense in being able to pull a specific value without getting everything in a lump.
And am imagining I could have an entity data field of the room ID used on the site so this can be used as a ‘variable’ hopefully using in one way or another the ‘{tags}’ in the function/lookup.

The Execute Script Action does something similar to {CALL:X}, but it does not return values per-say. If you need a value returned, use {CALL:X}.

Here are 2 examples that show how powerful the scripting engine is…

Use Execute Script Action to invoke JScript, which runs SQL script…


Use Execute Script Action to invoke JScript, which runs a query to pull the value out of a Program Setting stored in [ProgramSettingValues] (the value of which happens to be a SQL query), then use JScript to execute that SQL Script, which has the effect of updating a row in the DB [EntityStateLogs] table … for editing Timeclock Punch Data…

3 Likes

If anyone can spare a little time I could really do with a bit of help getting off the ground.
Am sure once I have a starting point I can get to grips with it but am just struggling to get started.
I now have testing account but am not sure how to use these details :confused:
I might have bitten off more than I can chew…

Not sure how to start the script.
Documentations says;

To access our REST API you must authenticate via HTTP username and password,
these will be provided to you along with this document.

I have the username and password but an unsure how to begin.

I converted this to V5 Question since others may benefit from this discussion or may want to provide insight.

2 Likes

Typically its an HTML string you type into browser can you provide more documentation on how their REST setup is working?

NewBook_REST_POS_Integration_Guide.pdf (75.8 KB)

We are missing some key information. We might need to see more documentation on the actual software like when you login to the software there should be some options you need to configure there. Is there a link to any documentation for the actual software?

All I have at the minute is this documentation and a testing username, password and API key.

We might need to see documentation for the actual software. Typically you need to setup some things for REST on that side.

Can you give an example of what type of things?
Just want to avoid showing how little experience I have when contacting them LOL

1 Like

I would just ask to see documentation for the software. You could say it would help in your decision to use it.

PS: Tons of documentation and examples on REST if you google it. One that comes up a lot is Wordpress a very popular online blog that has REST API available for users. You might get ideas by reading how it works there.

I am trying to attempt myself at the minute for what its worth.

Starting with documentation;

POST URL: https://testau.newbookpms.com/rest/auth_test
HTTP Username: As provided
HTTP Password: As provided
JSON Request:
{
"api_key": "your_api_key_here"
}
JSON Response:
{
"success": "You have successfully authenticated to NewBook Test Property"
}

Am just struggling on using POST URL.
From what Ive read online and in documentation (an I may very well have misunderstood) to test my script with auth test i need to ‘post’

{
"api_key": "your_api_key_here"
}

to

https://user:password@testau.newbookpms.com/rest/auth_test

obviously replacing user, password and your_api_key_here
which will give me a response of;

{
"success": "You have successfully authenticated to NewBook Test Property"
}

So to test ‘success’ I would then have

document.write(success);

So starting from the latter I have uploaded test .html to my website;

<!DOCTYPE html>
<html>
<head>
<script type="application/javascript">
???????????
document.write(success);
</script>
</head>
<body>
</body>
</html>

Which is working should give me You have successfully authenticated to NewBook Test Property on the page.

Obviously need to get the ‘POST’ bit.

As the documentation specifies HTTP Username/Password I am starting with https://user:password@testau.newbookpms.com/rest/auth_test for url

I am so so confused, so many different examples and cant even get my head round where the post url should be going into it :frowning:
ajax
cURL
jQuery
My head hurts LOL

Just slow down and read as much as you can. Try to look for discussion forums and typically you might find people showing examples of use.

I am reading all sorts but dont even know if its the right thing for what I need. LOL
Everything I get too either seems to be super basic single page JSON examples or overly complex examples :persevere:

Have done some test coding following the single page basic examples and understand the base JSON part.

Look here for a curl tool to help with playing with REST

http://curl.haxx.se/download.html

Also you might get some decent info here:

https://developer.marklogic.com/try/rest/index

That url is about a specific API but it explains it simple. You might get idea from it. The software your using assumes you know how to use it and doesnt explain it well for a beginner.