Skip to content

Commit

Permalink
Add methods for updating and deleting API apps
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung488 committed Sep 13, 2017
1 parent e688e02 commit 7992cf4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
34 changes: 34 additions & 0 deletions app/controllers/apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@ def info
end

def list
app_list = client.get_api_apps :page => 2

render json: app_list
end

def create

white_labeling = {
"primary_button_color":"#778899",
"primary_button_text_color":"#ffffff"
}

app = client.create_api_app(
:name => params[:app_name],
:domain => 'www.rubyonrails.com',
:white_labeling_options => white_labeling.to_json
)

render json: app
end

def update
app = client.update_api_app(
:name => params[:app_name],
:client_id => params[:client_id]
)

render json: app
end

def delete
client.delete_api_app :client_id => params[:client_id]

flash[:notice] = "App deleted!"
redirect_to root_path
end
end
2 changes: 1 addition & 1 deletion app/controllers/signs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def send_request
:name => 'Jen',
:order => 0
}
],
],
# :form_fields_per_document => [
# [
# {
Expand Down
Empty file added app/views/apps/create.html.erb
Empty file.
Empty file added app/views/apps/update.html.erb
Empty file.
19 changes: 19 additions & 0 deletions app/views/signs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ Hello API event received
<li>
<%= link_to 'List API Apps', apps_list_path %>
</li>
<li>
<%= form_tag("/apps/create", method: "get") do %>
<%= text_field_tag(:app_name, nil, :placeholder => 'App Name') %>
<%= submit_tag("Create API App") %>
<% end %>
</li>
<li>
<%= form_tag("/apps/update", method: "get") do %>
<%= text_field_tag(:client_id, nil, :placeholder => 'Client ID') %>
<%= text_field_tag(:app_name, nil, :placeholder => 'App Name') %>
<%= submit_tag("Update API App") %>
<% end %>
</li>
<li>
<%= form_tag("/apps/delete", method: "get") do %>
<%= text_field_tag(:client_id, nil, :placeholder => 'Client ID') %>
<%= submit_tag("Delete API App") %>
<% end %>
</li>
</ul>
</div>
<div align="center">
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@

get '/apps/info' => 'apps#info'
get '/apps/list' => 'apps#list'
get '/apps/create' => 'apps#create'
get '/apps/update' => 'apps#update'
get '/apps/delete' => 'apps#delete'
end

0 comments on commit 7992cf4

Please sign in to comment.