Elliot
Elliot

Reputation: 13835

Creating a simple / pseudo API on rails 3?

I'm trying to create something which does the following:

if I have a products table that lists all products.

then I have a "purchase" table, which contains all transactions for people buying products.

lets say the products are like groupons (digital products) - they have to be set to "used" once they're used, either by the person who bought them, or the person who sold them.

person X buys a product, with key "XYZABC123"

the product is from company Micromartsystems

Micromartsystems has the api key "DFJSDda3290dssdj1"

if someone redeems their product on Micromartsystems, and uses the redemption key "XYZABC123", The admin of Micromartsystems see that in their backend.

Then lets say say they visit a link like mysite.com/redeem?api_key=DFJSDda3290dssdj1&redemption_key=XYZABC123

Because only Micromartsystems knows their API key, and only they should see a product with the key XYZABC123 (as each key will be unique for each purchase) - they can make links in their backend which automatically mark products as used on mysite.com.

From my side of things, it'll be pretty easy to grab those params and mark a transaction as redeemed if the URL has been accessed.

Does this make sense as a good way to do this?

I've never built an api, or something that links up with external apps, so I'm kind of just guessing here.

Upvotes: 0

Views: 212

Answers (1)

ez.
ez.

Reputation: 7654

That will work. Personally, I will design the api restfully instead of using url params. something like this:

http://yousite.com/account/DFJSDda3290dssdj1/redeem/XYZABC123

Upvotes: 2

Related Questions