lib/app42/command/base.rb in app42-0.6.0 vs lib/app42/command/base.rb in app42-0.6.1
- old
+ new
@@ -88,10 +88,17 @@
app_name = input "Enter App Name", [], true
valid_app_name = validate_app_and_service_name "App name", app_name.strip
valid_app_name ? (return valid_app_name) : get_app_name
end
+ # Ask custom URL from user and validate
+ def get_custom_url
+ url = input "Enter Custom URL", [], true
+ valid_url = validate_url url.strip
+ valid_url ? (return valid_url) : get_custom_url
+ end
+
# Ask wordpress name from user and
# will wait for user response (user will enter wordpress name)
def get_wordpress_name
wordpress_name = input "Enter Wordpress Name", [], true
valid_wordpress_name = validate_app_and_service_name "Wordpress name", wordpress_name.strip
@@ -739,9 +746,52 @@
response['success'] ? (return true) : (message "#{response['description']}", true, 'red')
rescue Interrupt
puts Paint[" Command cancelled.", :red]
exit!
end
+ end
+
+ # Custom operation will take placed like add, remove etc.
+ # expect +what+ as operation, +app_name+ as application name and +url+ custom url.
+ def costom_url_operation what, app_name, url
+ begin
+ if what.to_s == 'addcustomurl'
+ response = with_progress(Paint[ "Adding Custom URL To Application #{app_name}", :yellow]) do |s|
+ body = {'app42' => {"request"=> {
+ "appName" => app_name,
+ "url" => url
+ }}}.to_json
+ query_params = params
+ query_params.store('body', body)
+ build_post_request body, query_params, "app", "customurl"
+ end
+ else
+ response = with_progress(Paint[ "Removing Custom URL", :yellow]) do |s|
+ query_params = params
+ query_params.store('appName', app_name)
+ query_params.store('url', url)
+ build_delete_request query_params, "app", "customurl"
+ end
+ end
+
+ response['success'] ? (print Paint["#{response['message']}\n", :green]) : (message "#{response['message']}", true, 'red')
+ rescue Interrupt
+ puts Paint[" Command cancelled.", :red]
+ exit!
+ end
+ end
+
+ # Get custom URL details
+ def custom_url_information app_name
+ query_params = params
+ query_params.store('appName', app_name)
+ begin
+ response = build_get_request query_params, "app/customurl", nil
+ rescue Exception => e
+ puts e
+ exit!
+ end
+ return response
end
# create service and get all relevant service information post service creation.
#
# ==== Parameters
\ No newline at end of file