Linked Questions

Popular Questions

Ruby on Rails. Using Google Client API to parse emails

Asked by At

I am new to Ruby and have a question about how to do a specific task on Rails.

I have a list of inventory and each item has a specific Stock ID that is emailed to my personal Gmail account. I want my web application to listen for emails from a specific email account. When my gmail receives an email from that specific account I want my application to parse it for a couple of fields and insert the stock ID into my database.

For example: Let's say my database has an item with style code: A5U31 and size:10. The email will say something like item with style code: A5U31 and size:10 has Stock ID:329193020. I want my Rails application to search the database for an entry with that specific style code and size, and when it finds an entry to simply insert the stock ID into the row.

I am trying to using the Google-API-Client gem to this, but I am struggling, because I am still a beginner. So far I have done this quick-start guide to authenticate my gmail account with my rails app.

https://developers.google.com/gmail/api/quickstart/ruby?authuser=2

If someone could help me figure out how to write this sort of code and where to put it in my app(models, controllers, views) that would be very appreciated. Thanks!

Related Questions