From 7951aa3206d6aa30f5e89db0918b0660ed406167 Mon Sep 17 00:00:00 2001
From: cronosteam <info@galicloud.com>
Date: Wed, 15 May 2013 17:25:13 +0200
Subject: [PATCH] Issue #1344882 by desarrollo2.0 : modified previus patch
 paths and added array_merge with  and  for the request

---
 wsclient_rest/wsclient_rest.module |    4 ++++
 wsclient_ui/wsclient_ui.inc        |   19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/wsclient_rest/wsclient_rest.module b/wsclient_rest/wsclient_rest.module
index caa426d..e2c1edd 100644
--- a/wsclient_rest/wsclient_rest.module
+++ b/wsclient_rest/wsclient_rest.module
@@ -77,6 +77,10 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
       $data = $arguments[$operation['data']];
       unset($arguments[$operation['data']]);
     }
+    if ($type == 'POST') {
+      $data = array_merge((array) $data, $arguments);
+      $arguments = array();
+    }
     try {
       $response = $client->execute(new HttpClientRequest($this->service->url . $operation_url, array(
         'method' => $type,
diff --git a/wsclient_ui/wsclient_ui.inc b/wsclient_ui/wsclient_ui.inc
index 0df37be..80a5300 100644
--- a/wsclient_ui/wsclient_ui.inc
+++ b/wsclient_ui/wsclient_ui.inc
@@ -332,6 +332,21 @@ function wsclient_ui_operation($form, &$form_state, $service, $operation, $op =
     '#element_validate' => array('wsclient_ui_operation_name_validate'),
     '#weight' => -10,
   );
+  if ($service->type == 'rest'){
+      $form['type'] = array(
+        '#type' => 'select',
+        '#element_validate' => array('wsclient_ui_validate_parameters'),
+        '#title' => t('HTTP Method'),
+        '#default_value' => isset($operation['type']) ? $operation['type'] : 'GET',
+        '#description' => t('Specify the variables transmission method'),
+        '#options' => array(
+            'GET' => 'GET',
+            'POST' => 'POST',
+            'PUT' => 'PUT',
+            'DELETE' => 'DELETE',
+        ),
+      );
+  }
   $form['parameters'] = array(
     '#tree' => TRUE,
     '#element_validate' => array('wsclient_ui_validate_parameters'),
@@ -497,6 +512,10 @@ function wsclient_ui_operation_submit($form, &$form_state) {
   $operation = $form_state['operation'];
 
   $operation['label'] = $form_state['values']['label'];
+
+  if ($service->type == 'rest') {
+    $operation['type'] = $form_state['values']['type'];
+  }
   $operation['parameter'] = array();
   foreach ($form_state['values']['parameters']['items'] as $key => $item) {
     if (!empty($item['name'])) {
-- 
1.7.9.5

