Is there any way to query balanced and obtain a list of customers via code?
Consider my site has many users, only some of them require a balanced customer id.
I could search my own DB and look for customers who have a balanced id assigned.
For the purpose of error checking I would like to query balanced and get their list of customers.
I know I can do this manually through the marketplace UI, this is not practical so i need to do it programatically.
Here's an example: https://github.com/balanced/balanced-php/blob/master/tests/Balanced/SuiteTest.php#L259
$marketplaces = Marketplace::query()->all();
Balanced's PHP client uses https://github.com/bninja/restful underneath the hood, so every resource has a static query method. Look # https://github.com/bninja/restful/blob/master/src/RESTful/Query.php#L120 to see that this exposes a all() member method as well.
So, for any Balanced resource, in PHP, you can query it by saying ${RESOURCE_NAME}::query(). In your case, if you want to get ALL the customers, then you can do:
Balanced\Customer::query()->all();
Hope this helps.
I'm not sure about PHP, but with ruby you can access it via:
Balanced::Customer.all
If the PHP wrapper provides a Customer Object, I'd guess you'd be able to access it that way.
According to the PHP documentation the object is accessible via:
Balanced\Customer()
Related
I am trying to use the OpenAlex API: https://docs.openalex.org/api
This API provides access to a catalog of scholarly papers, authors, institutions, etc...
It is easy enough to make a query for an institution's information such. Here is an example from the API docs:
https://api.openalex.org/I19820366
I am trying to figure out how to get a specific institution's ID.
In the docs, there is a statement that this ID number is Microsoft Academic Graph's institutional ID: https://www.microsoft.com/en-us/research/project/microsoft-academic-graph/
But I have been unable to figure out anything in Microsoft Academic Graph either.
How can I find the institutional ID for a specific institution?
I am a beginner, and I also just started to retrieve data from the OpenAlex API. For me, the easiest way was either to use the ROR id or the GRID id, which you can both look up for any institution either here: https://www.grid.ac/ or here: https://ror.org/
Then you use either ROR or GRID-ID as an identifier (https://docs.openalex.org/about-the-data/institution#ids) and that identifier as a filter, as specified in the API documentation.
Be aware, that except for the Institution-ID, that you want to find, all the other institutional IDs, like ROR or GRID, have to be put in your request as a full URL. Take the example of the Johns Hopkins University. It's not enough to put their ROR like this: "00za53h95", you have to put in the API request like that: "https://ror.org/00za53h95" (without the quotes) or else it won't work. In my example, a request could look like this:
https://api.openalex.org/institutions/https://ror.org/00za53h95
This will deliver a nice json file with all the info you need, including the institution's ID in the database. Save the information as a file by using a cURL GET request or just do it via your browser and get the result as a webpage, both works. If you do the latter, you should follow the suggestion of the OpenAlex team and install a browser plugin like JSONVue, that will make the experience of reading the result on your screen so much better.
Hope that helps.
You can use the OpenAlex API to search for the ID like this:
https://api.openalex.org/institutions?filter=display_name.search:University%20of%20Virginia
In addition to Heather's comment, I'd like to add that we can now go to https://explore.openalex.org/ and search for any entity. Start typing "Johns Hopkins University" and you'll get to this page: https://explore.openalex.org/institutions/I145311948 which has all the identifiers (including the openalex id I145311948) and additional information about this institution.
I am building the section of my e commerce in Flask where customers can choose one of many shipping services alternatives. Building the options for the SelectField is expensive since I have to query and call different APIs from shipping providers to get quotes. After the POST request is sent and I have a selection from my customer, I would like to avoid having to rebuild all the objects, including the company, service, and price. What would be the best approach in this case? I understand g nor session would serve me in this case, and I would really like to avoid having to write options to the database. Thanks.
I am working on a script (which is in Python) for doing some management on our Magento environment.
Now I am wondering if I can create categories with assigned ID.
I think this might be impossible due to key constraints. But is there a way?
Just putting category_id in the parameter list in catalog_category.create, it does not work, it just skips the parameter.
The main reason of wanting this is because I need to know the category ID in order to create the subcategories.
I do know the Magento API returns the ID of the created category. But, I have no way of knowing what subcategories are supposed to go to that created category. (Or I can rewrite a load of code, which I am not too fond of...).
So I was thinking this was the easiest way to go with right now.
Any suggestions, comments, answers? Anything is appreciated!
No, you can't. Magento's entity IDs are for Magento so you cannot specify what you'd like them to be.
When you create an entity with the API it will return the new ID, as you've said.
For your use case it might be easiest to add a new attribute to your categories in Magento, call it "my_category_id" or something and allow your API to set that instead.
I'm working on REST Api suing Python Flask, as I have more and more routes, its hard to manage all the resource urls.
Right now, I'm confused which one is better practices of URL parameters. Examples below:
Get a list of courses with limits:
/courses/<int:lim> OR /courses/list?lim=10
Get a specific course:
/courses/<code>/<section> OR /courses/show?code=cs100§ion=1
Get a list of students in specific course:
/courses/<code>/<section>/students OR /students/show?code=cs100§ion=1
Should I pass query parameters using / or by doing ?
The only reason I'm using / is that there's no conflict in query.
If I have these two URL for two different queries, how can I fix it so I can query base on the parameters:
/students/show?code=cs100§ion=1 (Get all students in that course)
/students/show?id=123456789 (Get the specific student)
The URL should identify a resource or collection of resources. Any options you want to give the client, such as pagination, limits, filtering, sorting, etc. I think is best to include in the query string or in HTTP headers.
So regarding your specific questions:
Get a list of courses with limits: /courses/<int:lim> OR /courses/list?lim=10
Neither one. Use /courses?lim=10. No need to have a /list component, that is an action, not a resource.
Get a specific course: /courses/<code>/<section> OR /courses/show?code=cs100§ion=1
The first. Once again, /courses/show indicates an action, you want URLs to be links to resources, in this case your course.
Get a list of students in specific course: /courses/<code>/<section>/students OR /students/show?code=cs100§ion=1
The first, same reason as the previous one.
I have given REST API talks at the last two PyCon conferences, feel free to check them out if you want to learn more API design best practices:
PyCon 2014: Writing RESTful Web Services with Flask
PyCon 2015: Is Your REST API RESTful?
I'm developing a rest API for our business system. We have the following resources so far:
/sales/orders
/sales/orders/{orderno}
/sales/order-items
There will be lots of resources when the API is finished, so we need to structure it in a good way to make it easy to understand. My question is: should /sales/order-items instead be /sales/orders/order-items? There is maybe no correct answer here, but what would you prefer?
One more question: The sales/order-items resource will list either all open items or all shipped items. It will not be possible to get all order-items regardless of status (open/shipped). The resource URI could the be like this sales/order-items?orderstatus={OPEN/SHIPPED} (the orderstatus query parameter would be mandatory then) or it could be two resources like this sales/order-items/open and sales/order-items/shipped. What is the preferred?
A resource is 'any information that can be named'. Your URIs should be entity based. 'order-items' is not an entity, but a data type.
/sales/order/order-1456321 is the Entity you most likely want. Which would contain the data of all order items.
If you wish to restrict access, you can return a client error if no query string is supplied. and having
/sales/order/order-12345?status=open
etc. Hope this helps.
EDIT:
/sales/order-items or /sales/orders/order-items?
This is domain specific, and really should be answered by a domain expert. Your URI Hierarchy provides scope (and so detail) to your resource. So as an educated guess, It does not make sense to have "order-items" within the scope of "/sales/orders/" because "order-items" is not an "order".
/sales/ordered-items
seems the most sensible answer.
On a personal note, and not to question your domain too much, Having a strong understanding of the flow of the business and information that's stored may result in something along the lines of these suggestions;
/sales/orders?status=open - Are all orders shipped at once?
/sales/orders/order-1234/packages?status=open - Are orders split into packages?