cli_commands 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. ## rails ##
  2. x rake db:drop && x rake db:migrate && rake db:seed && x rake db:test:prepare && rails c
  3. ## curl ##
  4. NAME='CurlChannel'
  5. BASE_URL=http://localhost:3000/clients
  6. NICKS='NickA,NickB'
  7. NICK='NickA'
  8. CLIENT_SECRET='' # via create client resp - required for auth
  9. ROOM_SECRET='' # via 'fetch rooms' resp - bridges ("rooms") other than own
  10. # - required to merge into other bridge (own secret is useless here)
  11. # create client (returns own CLIENT_SECRET and own ROOM_SECRET)
  12. curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d "{\"client\":{\"name\":\"$NAME\",\"nicks\":\"$NICKS\",\"type\":\"IrcClient\"}}" $BASE_URL/
  13. # fetch rooms (returns other ROOM_SECRETS)
  14. curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d "{\"client\":{\"secret\":\"$CLIENT_SECRET\"}}" $BASE_URL/$NAME/rooms
  15. # join bridge
  16. curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d "{\"client\":{\"secret\":\"$CLIENT_SECRET\"},\"room_secret\":\"$ROOM_SECRET\"}" $BASE_URL/$NAME/bridge
  17. # create message
  18. curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d "{\"client\":{\"secret\":\"$CLIENT_SECRET\"},\"message\":{\"nick\":\"$NICK\",\"text\":\"some text\"}}" $BASE_URL/$NAME/message
  19. # read messages
  20. curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d "{\"client\":{\"secret\":\"$CLIENT_SECRET\"},\"last_id\":0}" $BASE_URL/$NAME/messages