Updating BigCommerce Pricing in Bulk with API - rest

I am trying to figure out the best way to update our prices via the API
Normal SKUs are fine, but the price of items with options seems a little less straightforward.
Using the GET v2/products?sku=XXXX there is only the base price of the item, not the price of the item with the option(s) selected
We also need the SKU of the item when the option(s) is(are) selected as my updated price list has SKU and Price
What is the best method of gathering this information, and then updating the prices?
Thanks for your help!

The V3 API provides a much better interface for this.
If all of your product's options are related to SKUs, you can GET all of the details of the product with its variants via
/v3/catalog/products?include=variants
This will show you option information along with all pricing - the calculated_price property will give you an idea of what the real price will be when you click on the option values for that SKU on the storefront - so it will take into account (for example) Product Rules and other things that might be going on in the background.
Editing SKUs (such as their price) can also be done via the endpoint.
Example:
PUT /v3/catalog/products/6606?include=variants (where 6606 is the Product ID)
{
"variants": [
{
"id": 25858,
"product_id": 6606,
"price": 10
},
{
"id": 25859,
"product_id": 6606,
"price": 11
},
{
"id": 25860,
"product_id": 6606,
"price": 13
}
]
}
This would update the prices of these 3 variants on the product (you'd get their IDs from the GET response).
If the product is "simple", meaning it has no child SKUs, you'll also see the product represented as a variant with sku_id=null. So you can actually use this endpoint to update the prices of simple products as well.

Related

How to Get / Update Customer GL Account info via Rest API

I'm trying to figure out how to Get and Update a Customer's GL Accounts info via Rest API.
As seen in this screenshot, a Customer's GL Accounts section has fields such as:
AR Account
AR Sub
Sales Account
Sales Sub
etc.
Via Rest API, where can I retrieve this Customer's above info, and how can I update them accordingly?
I'm able to perform CRUD for all the other Customer entity fields, but I'm quite lost regarding how per Customer GL Accounts can be retrieved and updated. Looking for any help to point me to the right direction.
Those fields are not the part of the Default endpoint, so you need some tricks to retrieve or update them.
You can either use custom endpoint or retrieve/update these fields using 'Custom' fields collection.
As for custom endpoint, here is the link that can help.
As for the custom fields, you can retrieve the values like that:
GET: {{sitename}}/entity/Default/20.200.001/Customer?$custom=DefLocation.CSalesAcctID, DefLocation.CARAccountID
Response:
{
"id": "90f25585-fbc0-eb11-9d4f-3ce1a14ed5bf",
"CustomerID": {
"value": "AAA"
},
"custom": {
"DefLocation": {
"CSalesAcctID": {
"type": "CustomStringField",
"value": "40000"
},
"CARAccountID": {
"type": "CustomStringField",
"value": "11000"
}
}
}
}
See here how to get the field names.
To update the fields you send them in the body the same way you get them in the response

Is there any easy method to getting the Column Title when using GET Row with the Smartsheet API?

Is there any easy method to getting the Column Title when using GET Row with the API? New to API. I'm utilizing Microsoft Power Automate for these calls to push updates to Teams and such (more custom than what comes natively from Smartsheet).
I'm utilizing this address from the documentation:
https://api.smartsheet.com/2.0/sheets/{SheetID}/rows/{rowID}, and then I add this string to the end of that URL to get discussions and columns: "?include=discussions,columns"
which will include a separate array named "Columns".
What I'm wanting to do is get the "Column title" within the initial GET Row action. It would show up within the "cells" array when doing a GET Row API call.
Here's an example of what is obtained in the "cells" array when GET Row is used:
"cells": [
{
"columnId": 4151830841190276,
"value": "New task.",
"displayValue": "New task."
}
]
And here's an example of what's obtained in that Columns array, which comes separate:
"columns": [
{
"id": 4151830841190276,
"version": 0,
"index": 3,
"title": "Item Name",
"type": "TEXT_NUMBER",
"primary": true,
"validation": false,
"width": 300
}
Which is fine, I can do lookups to bridge the gap between the ColumnID I obtain from "get row" and the Columns array that's also returned...but ideally I'd like to just get the ColumnID Title in the native "GET Row" action, preventing this workaround. Any ideas, or am I doing it the best way?
You can't get column information (title, type, options...) while specifically reading rows.
You have 2 options:
Make another call to get the column information
https://smartsheet-platform.github.io/api-docs/#get-column)
Read all
the sheet (both columns and rows at once)
https://smartsheet-platform.github.io/api-docs/#get-sheet
Both solution should be working, I would suggest the second solution since only one API call is needed, but need more work processing the data.

Best practice to return Type id descriptions for api consumers

I am developing an api for clients to consume.
Some of the objects e.g. telephone, where a person could have more than one telephone will have multiple type id's. I have a list of telephone types server side and the consumer will be required to either pass no value and it will default this or pass an id to represent the correct value. Now this in itself is not my issue however when you expand the type id's across many, many objects you arrive at my question.
If as a developer you're consuming the API data, would you prefer a single URI end point to retrieve all the type id's and descriptions, or multiple end points to call for each type id list (which would and has driven me nuts previously with other API's) or just document all the Id's (although this is a moving target always)
Basically clients will push their data into the system via the API, we will then process the data in some way and they will build reports from the data processed.
So what's preferred?
Single end point
GET: domain/root/allTypes
{
"TelephoneTypes":[
{"id": 123, "description":"Home"},
...
{"id": 789, "description":"Mobile"}
]
},
"EmailTypes":[
{"id": 234, "description":"personal"},
...
{"id": 567, "description":"work"}
]
}
Or
Multiple end points
GET: domain/root/telephone/types
{
"TelephoneTypes":[
{"id": 123, "description":"Home"},
...
{"id": 789, "description":"Mobile"}
]
}
GET: domain/root/email/types
{
"EmailTypes":[
{"id": 234, "description":"personal"},
...
{"id": 567, "description":"work"}
]
}
I'm sure context will effect the outcome and I've tried to give as simple a scope to the question. I'm really interested in the general preferred consumption approach as I've used several API's and added to many more but this is a greenfield project so I want to try and find the overall preferred method to passify the end users/developers and keep my sanity :)

Designing RESTful shopping cart

I am building a single page application for booking hotel conference rooms and am not sure how to set it up, or even if RESTful is the proper approach. There will be four steps to this SPA:
The user chooses a date (available dates come from server - some days could be fully booked).
The user chooses a conference room (conference rooms available at this hotel on the date chosen in step 1 are retrieved from the server).
The user enters their name, address, billing info.
User sees confirmation page.
This same SPA will be used by multiple hotels with the same database back-end, and for the front-end I was thinking Ember.
Is RESTful the right approach for this application?
I was thinking:
GET /dates?hotel_id=xxx (should I pass the hotel ID in the URL vs. in headers vs. in the body?)
GET /rooms?hotel_id=xxx&date=yyy (should I be passing the date and hotel_id in, or somehow remember it on the server?)
POST /order with body: {date, conference_room_id, name/address/billing info}, returns { confirmation_id }
Should the name/address/billing info be put into a separate POST?
Thank you for your advice.
In a REST(ful) framework there's no concept of session. Every request must send all the required information in order to identify a resource.
I'll post an example below, based on requirements you provided.
GET /hotels/{hotel_id}/dates
Path params:
hotel_id (required)
Query params:
startDate (optional, default: today)
endDate (optional, default (example): today + 3 months)
status (optional, "available"/"booked"/"all", default: "all")
Response body: [{"id":"20160503", "dateStr":"May 5th 2016", "status": "available"}]
GET /hotels/{hotel_id}/dates/{date_id}/rooms
Path params:
hotel_id (required)
date_id (required)
Query params:
status (optional, "booked"/"available"/"all", default:"all")
Response body: [{"id": "12", "status": "available", "reservationId": ""}, {"id: "13", "status": "booked", "reservationId" : "123"}]
Note: this kind of implementation allows to list different combinations of dates and rooms (e.g. booked rooms in available days).
POST /hotels/{hotel_id}/reservations
Path params:
hotel_id(required)
Request body: {"dateId":"20160503", "roomId":"12", "firstName":"John", "lastName":"Doe", "address": "xxx", "vatNumber" : "yyy", "companyName": "zzz"}
Note: if you store billing addresses as separate entities (e.g. if your server is required to "remember" them), then it can be useful to implement POST and GET services for billing addresses (/billing) and refer to them with proper identifiers.
Response body: {"reservationId" : "324"}
GET /hotels/{hotel_id}/reservations/{reservation_id}
Path params:
hotel_id(required)
reservation_id (required)
Response body: {"dateId":"20160503", "roomId":"12", "firstName":"John", "lastName":"Doe", "address": "xxx", "vatNumber" : "yyy", "companyName": "zzz"} (same as POST request body)
GET /dates?hotel_id=xxx (should I pass the hotel ID in the URL vs. in headers vs. in the body?)
GET /rooms?hotel_id=xxx&date=yyy (should I be passing the date and hotel_id in, or somehow remember it on the server?)
POST /order with body: {date, conference_room_id, name/address/billing info}, returns { confirmation_id }
Your solution can use Restful API approach. Because it enable any other component to directly call your APIs. It can be APP, or a website or plugin or just another java program connected to internet, they just need to trigger your API and they are done.
URL you mentioned for your application, please note that one should use resource-based URL approach while building RESTful api.
GET /date/hotels/ -> Gives you all available rooms in all hotels on that particular day
GET /dates/hotels/ -> Give you list of available rooms for a particular hotel (Use dates/hotel_id instead of dates/?hotel_id=xxx). Parameter should be used to filter your result. E.g. dates/hotels/hotel_id?PIN=142: This should gives you hotel whose pin matches 142
dates/hotels?MAX_RECORD=50: This should give you list of hotels but limit to 50
You can find more about creating resource-based Restful API https://www.youtube.com/playlist?list=PLqq-6Pq4lTTZh5U8RbdXq0WaYvZBz2rbn
I would put the "Selects" into GETs as designed.
e.g. dates GET /hotel/:id/date -> Get all available dates
rooms GET /hotel/:id/date/:date/rooms -> Get all available rooms
per design in a RESTful API GET is defined for requesting data.
For the POST I would not breakdown into a seperate POST but you can put some parameter like hotel_id or date into the URL.
Best
Fabian

Mongodb - Modelling a product catalog with user specific pricing

Looking at the mongoDB product catalog example (for data caching lookups), how would I best implement pricing and qty available that is specific to the user logged in.
I am picturing a layout something like this:
[{"_id":"skuA",
"details":{ "msrp": "$15", "short_desc": "my short description"}
, "PriceQty" : [{"custid": 1, "price":10 , "qty":25 },{"custid": 2, "price":9 , "qty":20 }]
}]
(but i would need to push in updated (or add if first log in) pricing when the user logs in (ex: remove where custid = 1 from all documents and push in ).
Or
Would it make sense to keep the item information in one place and create a separate collection holding the sku, price, customer, and qty? Not sure how I would use a reference ID on that to get an effectively SQL left join from the item collection to pricing collection with this second approach.
The Item collection would hold 100k+ (for quoting purposes) but the pricing and qty would hold 2k for what could be ordered on the spot. Unfortunately, I have my mind in the relational world still.