Query URI service and return value to form field - forms

I would like to have a form field that when filled returns the information that the specific company name is available for registration or not. I have checked companies house website and they have their URI service, but it looks like that the query should be made by company number and not by name:
http://business.data.gov.uk/id/company/{companynumber}
Companies house
I'm newbie, so if with any answer you can provide me any code example that would be great, thanks in advance.

Related

How should I design MongoDB User Schema for Ecommerce website?

I have designed the User Schema, but I am a bit confused about the User Shipping Address. The user might have many shipping addresses that he wants to save in his profile.
So I am a bit confused whether I should create a separate Address schema and refer the User inside or save the Array of the Address object directly in the User Schema. But, one problem I have noticed; If I save the address in the Address Array under User's Schema, I will not have an object ID for the Address to be identified that which address I want to get. In this situation, I will have to face the problem to update the address.
If someone can tell me how should I go, It will be helpful for me.
You don't need an object ID to do that task.
The solution is that you can just manually assign an id to each address
by just putting both id and address in a json document and then pushing it in the array of addresses.
it will look something like this after in json format
address : [
{
id:1,
address:"address 1"
},
{
id:2,
address:"address 2"
}
]

Restrict Submission on Cognito Forms' Form Based on Previous Entries

I built a form in Cognito Forms for employees to reserve company vehicles. The following are important fields on the form:
Employee Name
Employee Email
Vehicle (selection)
Pick Up Date = date the user will get the car
Mileage = how many miles the user put on the car, entered after returning the car
We want to restrict the user from entering a new car reservation if they have a past entry that has not had Mileage entered. I was considering using a calculated field of some kind and then using the quantities feature to restrict duplicate entries but not sure what could be used in the form as comparison for duplicates. I know that currently Cognito Forms does not have a method for doing lookups of previous entries or else there wouldn't be a question. Has anyone else found a workaround before?

How to return only selected items from Pods Framework?

Just started using the PODS framework for Wordpress. Most of it I picked up pretty fast, the rest I'm struggling with. Below is an example of my confusion:
I created a custom post (Partner Bio) with auto-templates turned on.
I created a pods-template (Bio for Industry) that is sourcing post (Partner Bio).
I created another custom post (Industry) with multi-select post-type relationship field to post (Partner Bio).
The issue I'm having is that when I create an instance of post (Industry), then select specific items from that relationship (Partner Bio), (say there are 10, but I chose 3), I'm getting data returned for all of Partner Bio's instead of just the three I chose, so in other words the template pulling data from all Partner Bios regardless of what I choose in the post field drop down.
The template I'm using looks like this:
<div>{#post_thumbnail.thumbnail}<br/>
{#first_name} {#middle_initial} {#last_name}<br/>
{#title_of_partner}<br/>
{#position}<br/>
{#phone}<br/>
Email {#first_name}
</div>
This made me think that when you embed a pod usinge a shortcode, it's not being controlled by the fields selected when you edit your post. So then I tried grabbign the code from the template and then just dropping it in the post, that did not work either.
My goal is to display the block listed above one under another, based on which bios I choose. What am I doing wrong?
If my example above is confusing, here's a simpler sample illustrating the same issue, this maybe more clear:
Post A structure/fields:
Name,
Email,
Rel, // Post A's Relationship via post-type to Post B,
Auto templates: on,
Pods Template created: {#name}{#Emal}{#Image}
The issue, is when I create an instance of Post A and select items from the Rel, I'm getting values pulled in from all members of that relationship rather than just what I checked off.
If I turn off auto templates and drop in magic tags into the instance of Post A, I do get back only data for the relationship items I chose but I ge it back in this format:
Name and Name and Name
Emaile and Email and Email
Rather than:
Name
Email
Name
Email
...

REST API structure for multiple countries

I'm designing a REST API where you can search for data in different countries, but since you can search for the same thing, at the same time, in different countries (max 4), am I unsure of the best/correct way to do it.
This would work to start with to get data (I'm using cars as an example):
/api/uk,us,nl/car/123
That request could return different ids for the different countries (uk=1,us=2,nl=3), so what do I do when data is requested for those 3 countries?
For a nice structure I could get the data one at the time:
/api/uk/car/1
/api/us/car/2
/api/nl/car/3
But that is not very efficient since it hits the backend 3 times.
I could do this:
/api/car/?uk=1&us=2&nl=3
But that doesn't work very well if I want to add to that path:
/api/uk/car/1/owner
Because that would then turn into:
/api/car/owner/?uk=1&us=2&nl=3
Which doesn't look good.
Anyone got suggestions on how to structure this in a good way?
I answered a similar question before, so I will stick to that idea:
You have a set of elements -cars- and you want to filter it in some way. My advice is add any filter as a field. If the field is not present, then choose one country based on the locale of the client:
mydomain.com/api/v1/car?countries=uk,us,nl
This field should dissapear when you look for a specific car or its owner
mydomain.com/api/v1/car/1/owner
because the country is not needed (unless the car ID 1 is reused for each country)
Update:
I really did not expect the id of the car can be shared by several cars, an ID should be unique (like a primary key in a database). Then, it makes sense to keep the country parameter with the owner's search:
mydomain.com/api/v1/car/1/owner?countries=uk,us
This should return a list of people who own a car with the id 1... but for me this makes little sense as a functionality, in this search I'll only allow one country:
mydomain.com/api/v1/car/1/owner?country=uk

Facebook API - Custom Audience from contact data

does any one has experience with using Custom Audience API in order to create audience for contact data of people outside of U.S.?
Part of the API which i refer to is: https://developers.facebook.com/docs/marketing-api/reference/custom-audience/users/
As you can see, documentation lacks of explanation in what format should be data for COUNTRY field provided. Also I don't know how to format data for ST field if the country is outside of US. Should I use some region name or just leave it blank?
I uploaded 1000 users and nobody has been recognized so I suppose that I just did not format data properly.
Sample request: payload={"schema":["FN","LN","CT","ST","COUNTRY"],"is_raw":true,"data":[["adam","nowak","wroclaw","","poland"]]}&access_token=____&format=json
As you can see I left state field blank, and provided country in English translation and lower caps. It is possible that valid value is e.g. PL a not "poland". Also any information about what should be filled in state field would help me a lot.
Thanks in advance.