Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
gitlab-com
marketo-tools
Commits
c996ca4b
Commit
c996ca4b
authored
Nov 12, 2015
by
Robert Speicher
Browse files
Add application
parent
2df9a52c
Changes
5
Hide whitespace changes
Inline
Side-by-side
.env
0 → 100644
View file @
c996ca4b
# HTTP Basic Auth
AUTH_USERNAME="username"
AUTH_PASSWORD="password"
# Marketo API
MRKT_HOST=""
MRKT_ID=""
MRKT_SECRET=""
app.rb
0 → 100644
View file @
c996ca4b
require
'json'
require
'./lib/marketo_client'
require
'./lib/user'
class
MarketoTools
<
Sinatra
::
Base
use
Rack
::
Auth
::
Basic
do
|
username
,
password
|
username
==
ENV
[
'AUTH_USERNAME'
]
&&
password
==
ENV
[
'AUTH_PASSWORD'
]
end
# Receives GitLab System Hooks
#
# Specifically, we're interested in the `user_create` event.
#
# See http://gitlab.com/help/system_hooks/system_hooks
post
'/'
do
begin
params
=
JSON
.
parse
(
request
.
body
.
read
)
rescue
JSON
::
ParserError
params
=
{}
end
if
params
[
'event_name'
]
==
'user_create'
user
=
User
.
new
(
params
)
# TODO (rspeicher): Do we need to do anything with this besides
# create/update a lead?
client
.
createupdate_leads
([
user
.
to_param
],
lookup_field: :email
)
end
# https://dev.gitlab.org/gitlab/mailchimp-tools/commit/a93a0b97a906008e97c0fe6eccdf09ce32f944ea
'success'
end
private
def
client
@client
||=
MarketoClient
.
new
end
end
config.ru
0 → 100644
View file @
c996ca4b
require
'bundler'
Bundler
.
require
Dotenv
.
load
require
'./app'
run
MarketoTools
lib/marketo_client.rb
0 → 100644
View file @
c996ca4b
class
MarketoClient
<
SimpleDelegator
attr_reader
:client
def
initialize
@client
=
Mrkt
::
Client
.
new
(
host:
ENV
[
'MRKT_HOST'
],
client_id:
ENV
[
'MRKT_ID'
],
client_secret:
ENV
[
'MRKT_SECRET'
]
)
super
(
@client
)
end
end
lib/user.rb
0 → 100644
View file @
c996ca4b
class
User
include
FullNameSplitter
attr_accessor
:first_name
,
:last_name
,
:email
def
initialize
(
params
)
self
.
full_name
=
params
[
'name'
]
self
.
email
=
params
[
'email'
]
end
def
to_param
{
email:
email
,
firstName:
first_name
,
lastName:
last_name
}
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment