Salsify Coding Exercise - XML Product Upload via API
Summary
In this exercise, you will build and document a script that is capable of updating Salsify via its API, with data from an XML file on an FTP server. Please write this in Ruby. You may use any reference and any open-source software you can find to help you build this system, so long as you document your use. However, you should not actively collaborate with others.
You will be sent an invite to Salsify, which will connect to a sandbox Salsify account. You will also be sent the login/pass details for the FTP access.
Requirements
Your script will:
- Connect to the FTP server (ftp.salsify.com), authenticate (using given credentials), and download "products.xml"
- Convert the XML format of the product list into JSON format (for the template of that JSON, see below).
- Use the Salsify API to update the products with the JSON you create in the above step.
JSON Format
{
"SKU": "1234",
"Item Name": "XYZ Name",
"Brand": "Generic Wine Co.",
"Color": "red",
"MSRP": "9.99",
"Bottle Size": "750mL",
"Alcohol Volume": "0.14",
"Description": "Example description."
}
Connecting to the API
It is a traditional CRUD API:
* CREATE a product - POST https://app.salsify.com/api/v1/products
* UPDATE a product - PUT https://app.salsify.com/api/v1/products/<product_id>
* READ a product - GET https://app.salsify.com/api/v1/products/<product_id>
* DELETE a product - DELETE https://app.salsify.com/api/v1/products/<product_id>
The <product_id> in this case will be the SKU in the XML.
Authorizing to the API
You will want the HTTP Authorization header to include your auth token (Authorization: "Bearer <your auth token here>").
To get an auth token, login to Salsify using the account given to you for this coding exercise, click on the Profile tab
at the top, go to My Profile, then API Access. In there you can get your auth token.
What to Submit
You should submit via email a zip file or provide access to a public source code repository that contains your code and a README including documentation of your script and the below notes. (Please do not commit API/user/pass credentials to a public source code repository.)
README - A text file that answers the following questions:
- How does your script work? (if not addressed in comments in source)
- What documentation, websites, etc did you consult in doing this assignment?
- What third-party libraries or other tools does the script use? How did you choose each library you used?
- How long did you spend on this exercise? If you had unlimited additional time to spend on this, how would you spend it and how would you prioritize each item?
- If you were to critique your code, what would you have to say about it?