The RCF Shop API can be used to query items from a warehouse based on name and availablility.
The API is currently live at rcf-shopify-s19.herokuapp.com
Contents
Product Queries
https://rcf-shopify-s19.herokuapp.com/query
can be used to find single items.
https://rcf-shopify-s19.herokuapp.com/all
will return the entire inventory.
Using the Query Path
Parameter name can be filled with a partial item name. For instance, name=Casa
, supplied as https://rcf-shopify-s19.herokuapp.com/query?name=Casa
will return {"title":"Casanova","price":63,"inventory_count":"0"}
. Queries made without the all
flag will return the first similar result.
Parameter instock can be used to only return items in our inventory. https://rcf-shopify-s19.herokuapp.com/query?name=Casa&instock
will return {}
. Optionally, true
and false
arguments can be supplied to the instock parameter. https://rcf-shopify-s19.herokuapp.com/query?name=Casa&instock=false
will return {"title":"Casanova","price":63,"inventory_count":"0"}
.
Examples
To return all out-of-stock items with and in the name, query /query?name=And&instock=false&all
The result will appear something like:
[
{
"title": "Cat and the Canary, The",
"price": 16,
"inventory_count": "0"
},
{
"title": "Male and Female",
"price": 27,
"inventory_count": "0"
},
{
"title": "Tortoise and the Hare, The",
"price": 42,
"inventory_count": "0"
},
{
"title": "Fast & Furious (Fast and the Furious 4, The)",
"price": 34,
"inventory_count": "0"
},
]
Using the All Path
https://rcf-shopify-s19.herokuapp.com/all
can be used with &instock
or &instock=false
to return all of the inventory results that are in the system, available, or out of stock.
Purchases
To purchase a product, first query an item, then POST use the full name as the name parameter to /purchase
.
First, find an item using query
or all
.
Ex. https://rcf-shopify-s19.herokuapp.com/query?name=alie
{
"title": "Alien Abduction",
"price": 37,
"inventory_count": "469"
}
If a item is out of stock, the user will be presented with this message:
https://rcf-shopify-s19.herokuapp.com/purchase?name=Ghost%20in%20the%20Machine
{
"error":"Out of stock.",
"message":"The item Ghost in the Machine (a.k.a. Deadly Terror)
is out of stock! Please check back soon."
}
If an item is in stock, the following message will be shown:
{
"message": "The film 'Alien Abduction' is available (469 in stock), but was not purchased. Use the flag &process=true to complete the transaction."
}
The item can then be purchased by appending &process=true
.
Ex. http://localhost:3000/purchase?name=Alien Abduction&process=true
{
"message": "The film 'Alien Abduction' was purchased. Inventory now at 468."
}
Querying Alien Abduction shows that the inventory_count
has been reduced by one.
{
"title": "Alien Abduction",
"price": 37,
"inventory_count": "469"
}
Postman is recommended for POSTing to the API.