maestrano-connector-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/DEVELOPER.md +10 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +222 -0
- data/LICENSE +21 -0
- data/README.md +138 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/app/controllers/maestrano/account/group_users_controller.rb +20 -0
- data/app/controllers/maestrano/account/groups_controller.rb +22 -0
- data/app/controllers/maestrano/application_controller.rb +7 -0
- data/app/controllers/maestrano/auth/saml_controller.rb +31 -0
- data/app/controllers/maestrano/sessions_controller.rb +15 -0
- data/app/helpers/maestrano/connector/rails/session_helper.rb +17 -0
- data/app/jobs/maestrano/connector/rails/synchronization_job.rb +49 -0
- data/app/models/maestrano/connector/rails/complex_entity.rb +175 -0
- data/app/models/maestrano/connector/rails/concerns/entity.rb +231 -0
- data/app/models/maestrano/connector/rails/concerns/external.rb +13 -0
- data/app/models/maestrano/connector/rails/connector_logger.rb +9 -0
- data/app/models/maestrano/connector/rails/entity.rb +5 -0
- data/app/models/maestrano/connector/rails/external.rb +5 -0
- data/app/models/maestrano/connector/rails/id_map.rb +6 -0
- data/app/models/maestrano/connector/rails/organization.rb +60 -0
- data/app/models/maestrano/connector/rails/sub_entity_base.rb +32 -0
- data/app/models/maestrano/connector/rails/synchronization.rb +38 -0
- data/app/models/maestrano/connector/rails/user.rb +25 -0
- data/app/models/maestrano/connector/rails/user_organization_rel.rb +9 -0
- data/bin/rails +12 -0
- data/config/routes.rb +28 -0
- data/db/migrate/20151122162100_create_maestrano_connector_rails_users.rb +16 -0
- data/db/migrate/20151122162414_create_maestrano_connector_rails_organizations.rb +21 -0
- data/db/migrate/20151122162613_create_maestrano_connector_rails_user_organization_rels.rb +12 -0
- data/db/migrate/20151122163325_create_maestrano_connector_rails_synchronizations.rb +13 -0
- data/db/migrate/20151122163449_create_maestrano_connector_rails_id_maps.rb +18 -0
- data/lib/generators/connector/USAGE +2 -0
- data/lib/generators/connector/complex_entity_generator.rb +19 -0
- data/lib/generators/connector/install_generator.rb +70 -0
- data/lib/generators/connector/templates/admin_controller.rb +48 -0
- data/lib/generators/connector/templates/admin_index.html.erb +51 -0
- data/lib/generators/connector/templates/complex_entity_example/contact.rb +22 -0
- data/lib/generators/connector/templates/complex_entity_example/contact_and_lead.rb +56 -0
- data/lib/generators/connector/templates/complex_entity_example/contact_mapper.rb +17 -0
- data/lib/generators/connector/templates/complex_entity_example/lead.rb +22 -0
- data/lib/generators/connector/templates/complex_entity_example/lead_mapper.rb +15 -0
- data/lib/generators/connector/templates/complex_entity_example/person.rb +23 -0
- data/lib/generators/connector/templates/contact_and_lead.rb +55 -0
- data/lib/generators/connector/templates/entity.rb +48 -0
- data/lib/generators/connector/templates/example_entity.rb +26 -0
- data/lib/generators/connector/templates/external.rb +19 -0
- data/lib/generators/connector/templates/home_controller.rb +17 -0
- data/lib/generators/connector/templates/home_index.html.erb +42 -0
- data/lib/generators/connector/templates/oauth_controller.rb +45 -0
- data/lib/maestrano-connector-rails.rb +1 -0
- data/lib/maestrano/connector/rails.rb +13 -0
- data/maestrano-connector-rails.gemspec +197 -0
- data/maestrano.png +0 -0
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/admin_controller.rb +48 -0
- data/spec/dummy/app/controllers/application_controller.rb +8 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/home_controller.rb +17 -0
- data/spec/dummy/app/controllers/oauth_controller.rb +45 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/entities/example_entitiy.rb +26 -0
- data/spec/dummy/app/models/maestrano/connector/rails/entity.rb +10 -0
- data/spec/dummy/app/models/maestrano/connector/rails/external.rb +11 -0
- data/spec/dummy/app/views/admin/index.html.erb +51 -0
- data/spec/dummy/app/views/home/index.html.erb +36 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/maestrano.rb +135 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +9 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20151209134445_create_maestrano_connector_rails_users.maestrano_connector_rails.rb +17 -0
- data/spec/dummy/db/migrate/20151209134446_create_maestrano_connector_rails_organizations.maestrano_connector_rails.rb +22 -0
- data/spec/dummy/db/migrate/20151209134447_create_maestrano_connector_rails_user_organization_rels.maestrano_connector_rails.rb +13 -0
- data/spec/dummy/db/migrate/20151209134448_create_maestrano_connector_rails_synchronizations.maestrano_connector_rails.rb +14 -0
- data/spec/dummy/db/migrate/20151209134449_create_maestrano_connector_rails_id_maps.maestrano_connector_rails.rb +19 -0
- data/spec/dummy/db/schema.rb +83 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories.rb +33 -0
- data/spec/jobs/syncrhonization_job_spec.rb +53 -0
- data/spec/models/complex_entity_spec.rb +353 -0
- data/spec/models/connector_logger_spec.rb +21 -0
- data/spec/models/entity_spec.rb +457 -0
- data/spec/models/external_spec.rb +15 -0
- data/spec/models/id_map_spec.rb +12 -0
- data/spec/models/organizaztion_spec.rb +105 -0
- data/spec/models/sub_entity_base_spec.rb +51 -0
- data/spec/models/synchronization_spec.rb +75 -0
- data/spec/models/user_organization_rel_spec.rb +14 -0
- data/spec/models/user_spec.rb +15 -0
- data/spec/spec_helper.rb +19 -0
- metadata +327 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2df2109ee451552dfa445e1887b5048b7a457906
|
4
|
+
data.tar.gz: b85fbd4b76831b51093c99c757be09b722ae673b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aeb87f7f7db0490289fa878b39cc90c94be00ed471112420005da481b974fb7432820427cceb6725187de0b1fad87fb2c36a9d2cc3fce01ce667b02da27206cc
|
7
|
+
data.tar.gz: fba4495fb0e7510eb329232668f5f0e8a789b531be03f09be3f90476777315fe323752e9ea6ea6864b9f224869baa378a8225b3a517999da62f6514d6774c75d
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Add dependencies required to use your gem here.
|
4
|
+
gem 'maestrano-rails', '~> 0.14.0'
|
5
|
+
gem 'hash_mapper', '~> 0.2.1'
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
gem 'rspec-rails'
|
15
|
+
gem 'factory_girl_rails'
|
16
|
+
gem 'sqlite3'
|
17
|
+
gem 'shoulda-matchers'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (4.2.5)
|
5
|
+
actionpack (= 4.2.5)
|
6
|
+
actionview (= 4.2.5)
|
7
|
+
activejob (= 4.2.5)
|
8
|
+
mail (~> 2.5, >= 2.5.4)
|
9
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
+
actionpack (4.2.5)
|
11
|
+
actionview (= 4.2.5)
|
12
|
+
activesupport (= 4.2.5)
|
13
|
+
rack (~> 1.6)
|
14
|
+
rack-test (~> 0.6.2)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
actionview (4.2.5)
|
18
|
+
activesupport (= 4.2.5)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubis (~> 2.7.0)
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
23
|
+
activejob (4.2.5)
|
24
|
+
activesupport (= 4.2.5)
|
25
|
+
globalid (>= 0.3.0)
|
26
|
+
activemodel (4.2.5)
|
27
|
+
activesupport (= 4.2.5)
|
28
|
+
builder (~> 3.1)
|
29
|
+
activerecord (4.2.5)
|
30
|
+
activemodel (= 4.2.5)
|
31
|
+
activesupport (= 4.2.5)
|
32
|
+
arel (~> 6.0)
|
33
|
+
activesupport (4.2.5)
|
34
|
+
i18n (~> 0.7)
|
35
|
+
json (~> 1.7, >= 1.7.7)
|
36
|
+
minitest (~> 5.1)
|
37
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
38
|
+
tzinfo (~> 1.1)
|
39
|
+
addressable (2.4.0)
|
40
|
+
arel (6.0.3)
|
41
|
+
builder (3.2.2)
|
42
|
+
concurrent-ruby (1.0.0)
|
43
|
+
descendants_tracker (0.0.4)
|
44
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
45
|
+
diff-lcs (1.2.5)
|
46
|
+
docile (1.1.5)
|
47
|
+
domain_name (0.5.25)
|
48
|
+
unf (>= 0.0.5, < 1.0.0)
|
49
|
+
erubis (2.7.0)
|
50
|
+
factory_girl (4.5.0)
|
51
|
+
activesupport (>= 3.0.0)
|
52
|
+
factory_girl_rails (4.5.0)
|
53
|
+
factory_girl (~> 4.5.0)
|
54
|
+
railties (>= 3.0.0)
|
55
|
+
faraday (0.9.2)
|
56
|
+
multipart-post (>= 1.2, < 3)
|
57
|
+
git (1.2.9.1)
|
58
|
+
github_api (0.13.1)
|
59
|
+
addressable (~> 2.4.0)
|
60
|
+
descendants_tracker (~> 0.0.4)
|
61
|
+
faraday (~> 0.8, < 0.10)
|
62
|
+
hashie (>= 3.4)
|
63
|
+
multi_json (>= 1.7.5, < 2.0)
|
64
|
+
oauth2
|
65
|
+
globalid (0.3.6)
|
66
|
+
activesupport (>= 4.1.0)
|
67
|
+
hash_mapper (0.2.1)
|
68
|
+
activesupport (~> 4)
|
69
|
+
hashie (3.4.3)
|
70
|
+
highline (1.7.8)
|
71
|
+
http-cookie (1.0.2)
|
72
|
+
domain_name (~> 0.5)
|
73
|
+
httparty (0.13.7)
|
74
|
+
json (~> 1.8)
|
75
|
+
multi_xml (>= 0.5.2)
|
76
|
+
i18n (0.7.0)
|
77
|
+
jeweler (2.0.1)
|
78
|
+
builder
|
79
|
+
bundler (>= 1.0)
|
80
|
+
git (>= 1.2.5)
|
81
|
+
github_api
|
82
|
+
highline (>= 1.6.15)
|
83
|
+
nokogiri (>= 1.5.10)
|
84
|
+
rake
|
85
|
+
rdoc
|
86
|
+
jquery-rails (4.1.0)
|
87
|
+
rails-dom-testing (~> 1.0)
|
88
|
+
railties (>= 4.2.0)
|
89
|
+
thor (>= 0.14, < 2.0)
|
90
|
+
json (1.8.3)
|
91
|
+
jwt (1.5.2)
|
92
|
+
loofah (2.0.3)
|
93
|
+
nokogiri (>= 1.5.9)
|
94
|
+
macaddr (1.7.1)
|
95
|
+
systemu (~> 2.6.2)
|
96
|
+
maestrano (0.12.2)
|
97
|
+
httparty (~> 0.13)
|
98
|
+
json (~> 1.8)
|
99
|
+
mime-types (~> 1.25)
|
100
|
+
nokogiri (>= 1.5.0)
|
101
|
+
rest-client (~> 1.4)
|
102
|
+
uuid (~> 2.3)
|
103
|
+
maestrano-rails (0.14.0)
|
104
|
+
jquery-rails
|
105
|
+
maestrano (~> 0.12.2)
|
106
|
+
rails
|
107
|
+
mail (2.6.3)
|
108
|
+
mime-types (>= 1.16, < 3)
|
109
|
+
mime-types (1.25.1)
|
110
|
+
mini_portile2 (2.0.0)
|
111
|
+
minitest (5.8.3)
|
112
|
+
multi_json (1.11.2)
|
113
|
+
multi_xml (0.5.5)
|
114
|
+
multipart-post (2.0.0)
|
115
|
+
netrc (0.11.0)
|
116
|
+
nokogiri (1.6.7.2)
|
117
|
+
mini_portile2 (~> 2.0.0.rc2)
|
118
|
+
oauth2 (1.0.0)
|
119
|
+
faraday (>= 0.8, < 0.10)
|
120
|
+
jwt (~> 1.0)
|
121
|
+
multi_json (~> 1.3)
|
122
|
+
multi_xml (~> 0.5)
|
123
|
+
rack (~> 1.2)
|
124
|
+
rack (1.6.4)
|
125
|
+
rack-test (0.6.3)
|
126
|
+
rack (>= 1.0)
|
127
|
+
rails (4.2.5)
|
128
|
+
actionmailer (= 4.2.5)
|
129
|
+
actionpack (= 4.2.5)
|
130
|
+
actionview (= 4.2.5)
|
131
|
+
activejob (= 4.2.5)
|
132
|
+
activemodel (= 4.2.5)
|
133
|
+
activerecord (= 4.2.5)
|
134
|
+
activesupport (= 4.2.5)
|
135
|
+
bundler (>= 1.3.0, < 2.0)
|
136
|
+
railties (= 4.2.5)
|
137
|
+
sprockets-rails
|
138
|
+
rails-deprecated_sanitizer (1.0.3)
|
139
|
+
activesupport (>= 4.2.0.alpha)
|
140
|
+
rails-dom-testing (1.0.7)
|
141
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
142
|
+
nokogiri (~> 1.6.0)
|
143
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
144
|
+
rails-html-sanitizer (1.0.2)
|
145
|
+
loofah (~> 2.0)
|
146
|
+
railties (4.2.5)
|
147
|
+
actionpack (= 4.2.5)
|
148
|
+
activesupport (= 4.2.5)
|
149
|
+
rake (>= 0.8.7)
|
150
|
+
thor (>= 0.18.1, < 2.0)
|
151
|
+
rake (10.5.0)
|
152
|
+
rdoc (3.12.2)
|
153
|
+
json (~> 1.4)
|
154
|
+
rest-client (1.8.0)
|
155
|
+
http-cookie (>= 1.0.2, < 2.0)
|
156
|
+
mime-types (>= 1.16, < 3.0)
|
157
|
+
netrc (~> 0.7)
|
158
|
+
rspec-core (3.4.1)
|
159
|
+
rspec-support (~> 3.4.0)
|
160
|
+
rspec-expectations (3.4.0)
|
161
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
162
|
+
rspec-support (~> 3.4.0)
|
163
|
+
rspec-mocks (3.4.0)
|
164
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
165
|
+
rspec-support (~> 3.4.0)
|
166
|
+
rspec-rails (3.4.0)
|
167
|
+
actionpack (>= 3.0, < 4.3)
|
168
|
+
activesupport (>= 3.0, < 4.3)
|
169
|
+
railties (>= 3.0, < 4.3)
|
170
|
+
rspec-core (~> 3.4.0)
|
171
|
+
rspec-expectations (~> 3.4.0)
|
172
|
+
rspec-mocks (~> 3.4.0)
|
173
|
+
rspec-support (~> 3.4.0)
|
174
|
+
rspec-support (3.4.1)
|
175
|
+
shoulda (3.5.0)
|
176
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
177
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
178
|
+
shoulda-context (1.2.1)
|
179
|
+
shoulda-matchers (2.8.0)
|
180
|
+
activesupport (>= 3.0.0)
|
181
|
+
simplecov (0.11.1)
|
182
|
+
docile (~> 1.1.0)
|
183
|
+
json (~> 1.8)
|
184
|
+
simplecov-html (~> 0.10.0)
|
185
|
+
simplecov-html (0.10.0)
|
186
|
+
sprockets (3.5.2)
|
187
|
+
concurrent-ruby (~> 1.0)
|
188
|
+
rack (> 1, < 3)
|
189
|
+
sprockets-rails (3.0.0)
|
190
|
+
actionpack (>= 4.0)
|
191
|
+
activesupport (>= 4.0)
|
192
|
+
sprockets (>= 3.0.0)
|
193
|
+
sqlite3 (1.3.11)
|
194
|
+
systemu (2.6.5)
|
195
|
+
thor (0.19.1)
|
196
|
+
thread_safe (0.3.5)
|
197
|
+
tzinfo (1.2.2)
|
198
|
+
thread_safe (~> 0.1)
|
199
|
+
unf (0.1.4)
|
200
|
+
unf_ext
|
201
|
+
unf_ext (0.0.7.1)
|
202
|
+
uuid (2.3.8)
|
203
|
+
macaddr (~> 1.0)
|
204
|
+
|
205
|
+
PLATFORMS
|
206
|
+
ruby
|
207
|
+
|
208
|
+
DEPENDENCIES
|
209
|
+
bundler (~> 1.0)
|
210
|
+
factory_girl_rails
|
211
|
+
hash_mapper (~> 0.2.1)
|
212
|
+
jeweler (~> 2.0.1)
|
213
|
+
maestrano-rails (~> 0.14.0)
|
214
|
+
rdoc (~> 3.12)
|
215
|
+
rspec-rails
|
216
|
+
shoulda
|
217
|
+
shoulda-matchers
|
218
|
+
simplecov
|
219
|
+
sqlite3
|
220
|
+
|
221
|
+
BUNDLED WITH
|
222
|
+
1.10.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Maestrano
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img src="https://raw.github.com/berardpi/maestrano-connector-rails/master/maestrano.png" alt="Maestrano Logo">
|
3
|
+
<br/>
|
4
|
+
<br/>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
Maestrano Connector Engine to implements data syncrhonization between an external application API and Connec!.
|
8
|
+
|
9
|
+
Maestrano Connector Integration is currently in closed beta. Want to know more? Send us an email to <contact@maestrano.com>.
|
10
|
+
|
11
|
+
- - -
|
12
|
+
|
13
|
+
1. [Getting Setup](#getting-setup)
|
14
|
+
2. [Getting Started](#getting-started)
|
15
|
+
* [Integration with Maestrano](#integration-with-maestrano)
|
16
|
+
* [Integration with the external application](#integration-with-the-external-application)
|
17
|
+
3. [Preparing synchronizations](#preparing-synchronizations)
|
18
|
+
* [External.rb](#external.rb)
|
19
|
+
* [Entity.rb](#entity.rb)
|
20
|
+
* [Mapping entities](#mapping-entities)
|
21
|
+
4. [Pages controllers and views](#pages-controllers-and-views)
|
22
|
+
5. [Complex entities](#complex-entities)
|
23
|
+
|
24
|
+
- - -
|
25
|
+
|
26
|
+
## Getting Setup
|
27
|
+
Before integrating with us you will need an Connec!™ API ID and Connec!™ API Key. You'll also need to have the connector application created on Maestrano in order to realize the authentication with Maestrano.
|
28
|
+
|
29
|
+
## Getting Started
|
30
|
+
Create a new rails application using the connector template
|
31
|
+
```console
|
32
|
+
rails new <project_name> -m https://raw.githubusercontent.com/Berardpi/maestrano-connector-template/master/maestrano-connector-template.rb
|
33
|
+
```
|
34
|
+
|
35
|
+
If and only if you have an error in the template's rails generate step, you'll need to re-run the following command in your project folder:
|
36
|
+
```console
|
37
|
+
bundle
|
38
|
+
rails g connector:install
|
39
|
+
rails g delayed_job:active_record
|
40
|
+
rake db:migrate
|
41
|
+
```
|
42
|
+
|
43
|
+
### Integration with Maestrano
|
44
|
+
|
45
|
+
First thing to do is to put your Connec!™ API keys in the config/application.yml:
|
46
|
+
```ruby
|
47
|
+
connec_api_id: 'API_ID'
|
48
|
+
connec_api_key: 'API_KEY'
|
49
|
+
```
|
50
|
+
|
51
|
+
The only other thing you need to do is to set your configuration in config/initializers/maestrano.rb. The one line you need to look for and change is:
|
52
|
+
```ruby
|
53
|
+
config.app.host = 'http://path_to_app'
|
54
|
+
```
|
55
|
+
The rest of the config has default values, so you can take a look but you don't really need to change anything else.
|
56
|
+
|
57
|
+
Please note that the connectors support multi-tenancy, so you may have to set up configuration for tenant other than Maestrano (the default one).
|
58
|
+
|
59
|
+
Those configuration are automatically retrieve by Maestrano via a metadata endpoint that is provided by the gem, so you're all setup as it is.
|
60
|
+
|
61
|
+
Time to test! If your launch your application (please make sure that you launch the application on the same path as the one in the config file). If you click on the 'Link your Maestrano account' link on your connector home page, you should be able to do a full sso process with Maestrano.
|
62
|
+
|
63
|
+
### Integration with the external application
|
64
|
+
|
65
|
+
Now that you're all setup with Maestrano, it's time to take a look at the external application you are integrating with. Hopefully it has one or several gems for both the authentication process and the API calls. In any case, you'll need to take a look at their documentation.
|
66
|
+
|
67
|
+
You will probably have to request API keys and adds them to the application.yml alongside the Maestrano's ones.
|
68
|
+
|
69
|
+
The connector engine is thought to be able to use oauth authentication processes, and an oauth_controller is provided as an example. Please note that it is only an example and you will have to implements most of it, and to create the needed routes, and use them in the provided view.
|
70
|
+
|
71
|
+
If all went well, you should now be able to use the 'Link this company to...' link on the home page. Congrats!
|
72
|
+
|
73
|
+
## Preparing synchronizations
|
74
|
+
|
75
|
+
The aim of the connector is to perform synchronizations between Connec!™ and the external application, meaning fetching data on both ends, process them, and push the result to the relevant end. The Connec!™ part and the synchronization process itself is handle by the engine, so all you have to do is to implements some methods to work with the external application.
|
76
|
+
|
77
|
+
### External.rb
|
78
|
+
|
79
|
+
First file to look for is the external.rb class (in models/maestrano/connector/rails/). It contains two methods that you need to implements:
|
80
|
+
|
81
|
+
* external_name, which is used fr logging purpose only, and should only return the name of the external application, e.g.
|
82
|
+
```ruby
|
83
|
+
def self.external_name
|
84
|
+
'This awesome CRM'
|
85
|
+
end
|
86
|
+
```
|
87
|
+
* get_client, which should return either the external application gem api client, or, in the worst case, a custom HTTParty client.
|
88
|
+
|
89
|
+
|
90
|
+
### Entity.rb
|
91
|
+
|
92
|
+
The second important file is the entity.rb class (in the same folder). It contains a method to declare the entity synchronizable by your connector (more on that later), some methods to get and push data to the external application api, and lastly two methods to extract id and update date from the entity format sent by the external application.
|
93
|
+
|
94
|
+
The details of each methods are explained in the entity.rb file provided.
|
95
|
+
|
96
|
+
### Mapping entities
|
97
|
+
|
98
|
+
Now that you're all setup with both Connec!™ and the external application, it's time to decide which entities (contacts, accounts, events, ...) you want to synchronize. For each type of entity your connector will synchronize, you will need to create a class that inherits from Maestrano::Connector::Rails::Entity.
|
99
|
+
|
100
|
+
An example of such a class in provided in the models/entities/ folder, and demonstrates which methods you'll need to implements for each entity. The main thing to do is the mapping between the external entity and the Connec!™ entity. For the mapping, we use the hash_mapper gem (<https://github.com/ismasan/hash_mapper>).
|
101
|
+
|
102
|
+
This type of entity class enable 1 to 1 model correspondance. For more complex needs, please refer to the complex entity section below.
|
103
|
+
|
104
|
+
You'll find the connec API documentation here: <http://maestrano.github.io/connec/>, and should also refer to the external application API documentation.
|
105
|
+
|
106
|
+
Also don"t forget that each entity your connector synchronize should be declare in the entity.rb class, and, because the synchronizable entities are stored in th db for each organization, you'll need to create a migration for exisiting organization if you add an entity.
|
107
|
+
|
108
|
+
#### Overriding methods
|
109
|
+
|
110
|
+
To fit each entity specific need, you can overide all methods define in the entity class, including those implemented by the engine.
|
111
|
+
|
112
|
+
In particular, you will probably need to override the mapping methods to realize reference between entities (this can't be done during the mapping because it requires the organization id).
|
113
|
+
|
114
|
+
For example:
|
115
|
+
```ruby
|
116
|
+
def map_to_connec(entity, organization)
|
117
|
+
if id = entity['AccountId']
|
118
|
+
idmap = Maestrano::Connector::Rails::IdMap.find_by(external_entity: 'account', external_id: id, organization_id: organization.id, connec_entity: 'organization')
|
119
|
+
entity['AccountId'] = idmap ? idmap.connec_id : ''
|
120
|
+
end
|
121
|
+
self.mapper_class.denormalize(entity)
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
## Pages controllers and views
|
126
|
+
|
127
|
+
The home and admin pages views and controllers are provided as example, but you are free to customize them and the styling is left for you to do.
|
128
|
+
|
129
|
+
## Complex entities
|
130
|
+
|
131
|
+
For more complex correspondances, like 1 to many or many to many ones, you can use the complex entity workflow. To see how it works, you can run
|
132
|
+
```console
|
133
|
+
rails g connector:complex_entity
|
134
|
+
```
|
135
|
+
|
136
|
+
This will generate some example files demonstrating a 1 to 2 correspondance between Connec!™ person and external contact and lead data models.
|
137
|
+
|
138
|
+
The complex entities workflow uses two methods to pre-process data which you have to implements for each complex entity (see contact_and_lead.rb). They are called before the mapping step, and you can use them to perform any data model specific operations.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "maestrano-connector-rails"
|
18
|
+
gem.homepage = "http://github.com/maestrano/maestrano-connector-rails"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Rails framework to build connector with Maestrano"
|
21
|
+
gem.description = "Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details."
|
22
|
+
gem.email = "pierre.berard@maestrano.com"
|
23
|
+
gem.authors = ["Pierre Berard"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
29
|
+
load 'rails/tasks/engine.rake'
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
|
34
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
35
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
36
|
+
|
37
|
+
task :default => :spec
|