Skip to content

Commit 8fd4dfd

Browse files
authored
Merge pull request #5 from jyoung488/add-apiapp
Add apiapp
2 parents 664b17e + 7992cf4 commit 8fd4dfd

22 files changed

Lines changed: 226 additions & 197 deletions

Gemfile.lock

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (5.0.3)
5-
actionpack (= 5.0.3)
4+
actioncable (5.0.6)
5+
actionpack (= 5.0.6)
66
nio4r (>= 1.2, < 3.0)
77
websocket-driver (~> 0.6.1)
8-
actionmailer (5.0.3)
9-
actionpack (= 5.0.3)
10-
actionview (= 5.0.3)
11-
activejob (= 5.0.3)
8+
actionmailer (5.0.6)
9+
actionpack (= 5.0.6)
10+
actionview (= 5.0.6)
11+
activejob (= 5.0.6)
1212
mail (~> 2.5, >= 2.5.4)
1313
rails-dom-testing (~> 2.0)
14-
actionpack (5.0.3)
15-
actionview (= 5.0.3)
16-
activesupport (= 5.0.3)
14+
actionpack (5.0.6)
15+
actionview (= 5.0.6)
16+
activesupport (= 5.0.6)
1717
rack (~> 2.0)
1818
rack-test (~> 0.6.3)
1919
rails-dom-testing (~> 2.0)
2020
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21-
actionview (5.0.3)
22-
activesupport (= 5.0.3)
21+
actionview (5.0.6)
22+
activesupport (= 5.0.6)
2323
builder (~> 3.1)
2424
erubis (~> 2.7.0)
2525
rails-dom-testing (~> 2.0)
2626
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27-
activejob (5.0.3)
28-
activesupport (= 5.0.3)
27+
activejob (5.0.6)
28+
activesupport (= 5.0.6)
2929
globalid (>= 0.3.6)
30-
activemodel (5.0.3)
31-
activesupport (= 5.0.3)
32-
activerecord (5.0.3)
33-
activemodel (= 5.0.3)
34-
activesupport (= 5.0.3)
30+
activemodel (5.0.6)
31+
activesupport (= 5.0.6)
32+
activerecord (5.0.6)
33+
activemodel (= 5.0.6)
34+
activesupport (= 5.0.6)
3535
arel (~> 7.0)
36-
activesupport (5.0.3)
36+
activesupport (5.0.6)
3737
concurrent-ruby (~> 1.0, >= 1.0.2)
3838
i18n (~> 0.7)
3939
minitest (~> 5.1)
4040
tzinfo (~> 1.1)
4141
arel (7.1.4)
4242
bindex (0.5.0)
4343
builder (3.2.3)
44-
byebug (9.0.6)
44+
byebug (9.1.0)
4545
coffee-rails (4.2.2)
4646
coffee-script (>= 2.2.0)
4747
railties (>= 4.0.0)
@@ -56,18 +56,18 @@ GEM
5656
railties (>= 3.2, < 5.2)
5757
erubis (2.7.0)
5858
execjs (2.7.0)
59-
faraday (0.12.1)
59+
faraday (0.13.1)
6060
multipart-post (>= 1.2, < 3)
6161
ffi (1.9.18)
6262
globalid (0.4.0)
6363
activesupport (>= 4.2.0)
64-
hellosign-ruby-sdk (3.2.15)
64+
hellosign-ruby-sdk (3.5.0)
6565
faraday
6666
mime-types
6767
multi_json
68-
i18n (0.8.4)
69-
jbuilder (2.6.4)
70-
activesupport (>= 3.0.0)
68+
i18n (0.8.6)
69+
jbuilder (2.7.0)
70+
activesupport (>= 4.2.0)
7171
multi_json (>= 1.2)
7272
jquery-rails (4.3.1)
7373
rails-dom-testing (>= 1, < 3)
@@ -78,52 +78,56 @@ GEM
7878
rb-inotify (~> 0.9, >= 0.9.7)
7979
loofah (2.0.3)
8080
nokogiri (>= 1.5.9)
81-
mail (2.6.5)
81+
mail (2.6.6)
8282
mime-types (>= 1.16, < 4)
8383
method_source (0.8.2)
8484
mime-types (3.1)
8585
mime-types-data (~> 3.2015)
8686
mime-types-data (3.2016.0521)
87-
mini_portile2 (2.1.0)
88-
minitest (5.10.2)
89-
multi_json (1.12.1)
87+
mini_portile2 (2.2.0)
88+
minitest (5.10.3)
89+
multi_json (1.12.2)
9090
multipart-post (2.0.0)
9191
nio4r (2.1.0)
92-
nokogiri (1.7.2)
93-
mini_portile2 (~> 2.1.0)
92+
nokogiri (1.8.0)
93+
mini_portile2 (~> 2.2.0)
9494
pg (0.21.0)
95-
puma (3.9.0)
95+
puma (3.10.0)
9696
rack (2.0.3)
9797
rack-test (0.6.3)
9898
rack (>= 1.0)
99-
rails (5.0.3)
100-
actioncable (= 5.0.3)
101-
actionmailer (= 5.0.3)
102-
actionpack (= 5.0.3)
103-
actionview (= 5.0.3)
104-
activejob (= 5.0.3)
105-
activemodel (= 5.0.3)
106-
activerecord (= 5.0.3)
107-
activesupport (= 5.0.3)
108-
bundler (>= 1.3.0, < 2.0)
109-
railties (= 5.0.3)
99+
rails (5.0.6)
100+
actioncable (= 5.0.6)
101+
actionmailer (= 5.0.6)
102+
actionpack (= 5.0.6)
103+
actionview (= 5.0.6)
104+
activejob (= 5.0.6)
105+
activemodel (= 5.0.6)
106+
activerecord (= 5.0.6)
107+
activesupport (= 5.0.6)
108+
bundler (>= 1.3.0)
109+
railties (= 5.0.6)
110110
sprockets-rails (>= 2.0.0)
111111
rails-dom-testing (2.0.3)
112112
activesupport (>= 4.2.0)
113113
nokogiri (>= 1.6)
114114
rails-html-sanitizer (1.0.3)
115115
loofah (~> 2.0)
116-
railties (5.0.3)
117-
actionpack (= 5.0.3)
118-
activesupport (= 5.0.3)
116+
railties (5.0.6)
117+
actionpack (= 5.0.6)
118+
activesupport (= 5.0.6)
119119
method_source
120120
rake (>= 0.8.7)
121121
thor (>= 0.18.1, < 2.0)
122-
rake (12.0.0)
123-
rb-fsevent (0.9.8)
124-
rb-inotify (0.9.8)
125-
ffi (>= 0.5.0)
126-
sass (3.4.24)
122+
rake (12.1.0)
123+
rb-fsevent (0.10.2)
124+
rb-inotify (0.9.10)
125+
ffi (>= 0.5.0, < 2)
126+
sass (3.5.1)
127+
sass-listen (~> 4.0.0)
128+
sass-listen (4.0.0)
129+
rb-fsevent (~> 0.9, >= 0.9.4)
130+
rb-inotify (~> 0.9, >= 0.9.7)
127131
sass-rails (5.0.6)
128132
railties (>= 4.0.0, < 6)
129133
sass (~> 3.1)
@@ -138,14 +142,14 @@ GEM
138142
sprockets (3.7.1)
139143
concurrent-ruby (~> 1.0)
140144
rack (> 1, < 3)
141-
sprockets-rails (3.2.0)
145+
sprockets-rails (3.2.1)
142146
actionpack (>= 4.0)
143147
activesupport (>= 4.0)
144148
sprockets (>= 3.0.0)
145149
sqlite3 (1.3.13)
146-
thor (0.19.4)
150+
thor (0.20.0)
147151
thread_safe (0.3.6)
148-
tilt (2.0.7)
152+
tilt (2.0.8)
149153
turbolinks (5.0.1)
150154
turbolinks-source (~> 5)
151155
turbolinks-source (5.0.3)
@@ -186,4 +190,4 @@ DEPENDENCIES
186190
web-console (>= 3.3.0)
187191

188192
BUNDLED WITH
189-
1.15.1
193+
1.16.0.pre.2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
class ApplicationController < ActionController::Base
22
protect_from_forgery with: :exception
3+
4+
before_action :client
5+
6+
private
7+
8+
def client
9+
client = ApplicationRecord.initiate_client
10+
end
311
end

app/controllers/apps_controller.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
class AppsController < ApplicationController
2+
skip_before_action :verify_authenticity_token
3+
4+
def info
5+
app = client.get_api_app :client_id => params[:client_id]
6+
7+
render json: app
8+
end
9+
10+
def list
11+
app_list = client.get_api_apps :page => 2
12+
13+
render json: app_list
14+
end
15+
16+
def create
17+
18+
white_labeling = {
19+
"primary_button_color":"#778899",
20+
"primary_button_text_color":"#ffffff"
21+
}
22+
23+
app = client.create_api_app(
24+
:name => params[:app_name],
25+
:domain => 'www.rubyonrails.com',
26+
:white_labeling_options => white_labeling.to_json
27+
)
28+
29+
render json: app
30+
end
31+
32+
def update
33+
app = client.update_api_app(
34+
:name => params[:app_name],
35+
:client_id => params[:client_id]
36+
)
37+
38+
render json: app
39+
end
40+
41+
def delete
42+
client.delete_api_app :client_id => params[:client_id]
43+
44+
flash[:notice] = "App deleted!"
45+
redirect_to root_path
46+
end
47+
end

app/controllers/callbacks_controller.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,26 @@ def index
77

88
def create
99
event = JSON.parse(params["json"], symbolize_names: true)
10+
p event
1011
event_type = event[:event][:event_type]
1112
return "Hello API event received" if event_type == "callback_test"
13+
p "******"
14+
p "event type: #{event_type}"
1215

13-
id = event[:signature_request][:signature_request_id]
16+
if event_type.include? "signature"
17+
id = event[:signature_request][:signature_request_id]
18+
elsif event_type.include? "template"
19+
id = event[:template][:template_id]
20+
end
21+
22+
# if !event[:signature_request][:signature_request_id].nil?
23+
# id = event[:signature_request][:signature_request_id]
24+
# elsif !event[:template][:template_id].nil?
25+
# id = event[:template][:template_id]
26+
# end
27+
28+
p "******"
29+
p id
1430

1531
case event_type
1632
when "signature_request_sent"
@@ -25,6 +41,10 @@ def create
2541
when "signature_request_declined"
2642
Sign.find_by(signature_request_id: id,
2743
status: 'Declined')
44+
when "template_created"
45+
p "TEMPLATE CREATED"
46+
when "template_error"
47+
p "TEMPLATE ERROR"
2848
end
2949
end
3050
end

0 commit comments

Comments
 (0)