Skip to content

Commit

Permalink
Merge pull request #5 from jyoung488/add-apiapp
Browse files Browse the repository at this point in the history
Add apiapp
  • Loading branch information
jyoung488 authored Sep 13, 2017
2 parents 664b17e + 7992cf4 commit 8fd4dfd
Show file tree
Hide file tree
Showing 22 changed files with 226 additions and 197 deletions.
114 changes: 59 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.3)
actionpack (= 5.0.3)
actioncable (5.0.6)
actionpack (= 5.0.6)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.3)
actionpack (= 5.0.3)
actionview (= 5.0.3)
activejob (= 5.0.3)
actionmailer (5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.3)
actionview (= 5.0.3)
activesupport (= 5.0.3)
actionpack (5.0.6)
actionview (= 5.0.6)
activesupport (= 5.0.6)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.3)
activesupport (= 5.0.3)
actionview (5.0.6)
activesupport (= 5.0.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.3)
activesupport (= 5.0.3)
activejob (5.0.6)
activesupport (= 5.0.6)
globalid (>= 0.3.6)
activemodel (5.0.3)
activesupport (= 5.0.3)
activerecord (5.0.3)
activemodel (= 5.0.3)
activesupport (= 5.0.3)
activemodel (5.0.6)
activesupport (= 5.0.6)
activerecord (5.0.6)
activemodel (= 5.0.6)
activesupport (= 5.0.6)
arel (~> 7.0)
activesupport (5.0.3)
activesupport (5.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
bindex (0.5.0)
builder (3.2.3)
byebug (9.0.6)
byebug (9.1.0)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
Expand All @@ -56,18 +56,18 @@ GEM
railties (>= 3.2, < 5.2)
erubis (2.7.0)
execjs (2.7.0)
faraday (0.12.1)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
globalid (0.4.0)
activesupport (>= 4.2.0)
hellosign-ruby-sdk (3.2.15)
hellosign-ruby-sdk (3.5.0)
faraday
mime-types
multi_json
i18n (0.8.4)
jbuilder (2.6.4)
activesupport (>= 3.0.0)
i18n (0.8.6)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
Expand All @@ -78,52 +78,56 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.5)
mail (2.6.6)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.2)
multi_json (1.12.1)
mini_portile2 (2.2.0)
minitest (5.10.3)
multi_json (1.12.2)
multipart-post (2.0.0)
nio4r (2.1.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
pg (0.21.0)
puma (3.9.0)
puma (3.10.0)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.3)
actioncable (= 5.0.3)
actionmailer (= 5.0.3)
actionpack (= 5.0.3)
actionview (= 5.0.3)
activejob (= 5.0.3)
activemodel (= 5.0.3)
activerecord (= 5.0.3)
activesupport (= 5.0.3)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.3)
rails (5.0.6)
actioncable (= 5.0.6)
actionmailer (= 5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
activemodel (= 5.0.6)
activerecord (= 5.0.6)
activesupport (= 5.0.6)
bundler (>= 1.3.0)
railties (= 5.0.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.3)
actionpack (= 5.0.3)
activesupport (= 5.0.3)
railties (5.0.6)
actionpack (= 5.0.6)
activesupport (= 5.0.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
sass (3.4.24)
rake (12.1.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
sass (3.5.1)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
Expand All @@ -138,14 +142,14 @@ GEM
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.4)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.7)
tilt (2.0.8)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
Expand Down Expand Up @@ -186,4 +190,4 @@ DEPENDENCIES
web-console (>= 3.3.0)

BUNDLED WITH
1.15.1
1.16.0.pre.2
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

before_action :client

private

def client
client = ApplicationRecord.initiate_client
end
end
47 changes: 47 additions & 0 deletions app/controllers/apps_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class AppsController < ApplicationController
skip_before_action :verify_authenticity_token

def info
app = client.get_api_app :client_id => params[:client_id]

render json: app
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
22 changes: 21 additions & 1 deletion app/controllers/callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@ def index

def create
event = JSON.parse(params["json"], symbolize_names: true)
p event
event_type = event[:event][:event_type]
return "Hello API event received" if event_type == "callback_test"
p "******"
p "event type: #{event_type}"

id = event[:signature_request][:signature_request_id]
if event_type.include? "signature"
id = event[:signature_request][:signature_request_id]
elsif event_type.include? "template"
id = event[:template][:template_id]
end

# if !event[:signature_request][:signature_request_id].nil?
# id = event[:signature_request][:signature_request_id]
# elsif !event[:template][:template_id].nil?
# id = event[:template][:template_id]
# end

p "******"
p id

case event_type
when "signature_request_sent"
Expand All @@ -25,6 +41,10 @@ def create
when "signature_request_declined"
Sign.find_by(signature_request_id: id,
status: 'Declined')
when "template_created"
p "TEMPLATE CREATED"
when "template_error"
p "TEMPLATE ERROR"
end
end
end
Loading

0 comments on commit 8fd4dfd

Please sign in to comment.