Marketing Opt-Ins - simple REST API using Grape and ActiveRecord.
Database configuration in config/dtabase.yml Create database using rake
$ rake db:creata
$ rake db:migrate
Create test database
$ DATABASE_ENV=test rake db:creata
$ DATABASE_ENV=test rake db:migrate
rackup
$ curl -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]","permission_type":"permanent","channel":"email","company_name":"xyz"}' http://localhost:9292/opt_ins
{"opt_in":{"channel":"email","company_name":"xyz","email":"[email protected]","first_name":null,"id":1,"last_name":null,"mobile":null,"permission_type":"permanent"}}
$ curl http://localhost:9292/opt_ins
[{"email":"[email protected]","mobile":null,"first_name":null,"last_name":null,"permission_type":"permanent","channel":"email","company_name":"xyz","links":[{"rel":"self","href":"/optins/1"}]}]
$ curl -X PUT -H "Content-Type: application/json" -d '{"permission_type":"one-time"}' http://localhost:9292/opt_ins/1
true
$ curl -X DELETE -H "Content-Type: application/json" http://localhost:9292/opt_ins/1
{"opt_in":{"channel":"email","company_name":"xyz","email":"[email protected]","first_name":null,"id":1,"last_name":null,"mobile":null,"permission_type":"one-time"}}