delivery step actions
This commit is contained in:
@@ -51,6 +51,19 @@ class Wiass_REST_Delivery_Process_API {
|
||||
'callback' => array(__CLASS__, 'upload_file'),
|
||||
'permission_callback' => 'is_user_logged_in'
|
||||
) );
|
||||
|
||||
|
||||
register_rest_route( self::$namespace, 'customer-questionnaires/(?P<order_id>\d+)', array(
|
||||
'methods' => 'GET',
|
||||
'callback' => array(__CLASS__, 'get_customer_questionnaires'),
|
||||
//'permission_callback' => 'is_user_logged_in'
|
||||
) );
|
||||
|
||||
register_rest_route( self::$namespace, 'customer-questionnaires/(?P<order_id>\d+)/upload/(?P<action_id>\d+)', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => array(__CLASS__, 'upload_customer_questionnaire'),
|
||||
//'permission_callback' => 'is_user_logged_in'
|
||||
) );
|
||||
}
|
||||
|
||||
public static function get_next_actions_for_user() {
|
||||
@@ -97,6 +110,42 @@ class Wiass_REST_Delivery_Process_API {
|
||||
return rest_ensure_response($data);
|
||||
}
|
||||
|
||||
public function get_customer_questionnaires(WP_REST_Request $request) {
|
||||
|
||||
$order_id = absint($request['order_id']);
|
||||
|
||||
|
||||
$data = Wiaas_Delivery_Process::get_current_delivery_step_info($order_id);
|
||||
|
||||
return rest_ensure_response($data);
|
||||
}
|
||||
|
||||
public function upload_customer_questionnaire(WP_REST_Request $request) {
|
||||
|
||||
$action_id = absint($request['action_id']);
|
||||
|
||||
try {
|
||||
|
||||
$result = Wiaas_Document_Upload::upload_document_version();
|
||||
|
||||
$entry = GFAPI::get_entry($action_id);
|
||||
|
||||
$document_field = GFCommon::get_fields_by_type(GFAPI::get_form($entry['form_id']), 'wiaas_order_bundle_document')[0];
|
||||
|
||||
$entry[$document_field->id] = $result;
|
||||
|
||||
GFAPI::update_entry($entry);
|
||||
|
||||
Wiaas_Delivery_Process::complete_action_step($action_id);
|
||||
|
||||
return rest_ensure_response($result);
|
||||
|
||||
} catch( Exception $e) {
|
||||
}
|
||||
|
||||
return wiaas_api_notice('INSTALLATION_ACCEPTED', 'success');
|
||||
}
|
||||
|
||||
public static function get_customer_acceptance(WP_REST_Request $request){
|
||||
$entry = GFAPI::get_entry($request['entry_id']);
|
||||
if (is_wp_error($entry)){
|
||||
@@ -121,6 +170,7 @@ class Wiass_REST_Delivery_Process_API {
|
||||
'extension' => $file_name_with_extension_parts[1],
|
||||
'url' => $file_url
|
||||
);
|
||||
|
||||
array_push($acceptance_documents, $acceptance_documents_entry);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user