From f443087e71a629bf49198671f70061ebf8661f3b Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 6 Oct 2011 19:09:56 +0200 Subject: [PATCH] Added a first simple test client to test the restbuck client --- examples/restbucks/client/client-safe.ecf | 18 ++++++ examples/restbucks/client/client.ecf | 18 ++++++ .../restbucks/client/src/restbuck_client.e | 58 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 examples/restbucks/client/client-safe.ecf create mode 100644 examples/restbucks/client/client.ecf create mode 100644 examples/restbucks/client/src/restbuck_client.e diff --git a/examples/restbucks/client/client-safe.ecf b/examples/restbucks/client/client-safe.ecf new file mode 100644 index 00000000..183f9a01 --- /dev/null +++ b/examples/restbucks/client/client-safe.ecf @@ -0,0 +1,18 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + + diff --git a/examples/restbucks/client/client.ecf b/examples/restbucks/client/client.ecf new file mode 100644 index 00000000..9e91c9dd --- /dev/null +++ b/examples/restbucks/client/client.ecf @@ -0,0 +1,18 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + + diff --git a/examples/restbucks/client/src/restbuck_client.e b/examples/restbucks/client/src/restbuck_client.e new file mode 100644 index 00000000..d340cb08 --- /dev/null +++ b/examples/restbucks/client/src/restbuck_client.e @@ -0,0 +1,58 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +class + RESTBUCK_CLIENT + +create + make + +feature {NONE} -- Initialization + + make + -- Initialize `Current'. + local + h: LIBCURL_HTTP_CLIENT + sess: HTTP_CLIENT_SESSION + s: READABLE_STRING_8 + do + create h.make + sess := h.new_session ("http://127.0.0.1") + s := "[ + { + "location":"takeAway", + "items":[ + { + "name":"Late", + "option":"skim", + "size":"Small", + "quantity":1 + } + ] + } + ]" + + if attached sess.post ("/order", Void, s) as r then + print (r.body) + end + + if attached sess.get ("/order/1", Void) as r then + print (r.body) + end + end + +feature -- Status + +feature -- Access + +feature -- Change + +feature {NONE} -- Implementation + +invariant +-- invariant_clause: True + +end