infunnel_cli 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +10 -0
- data/Rakefile +1 -0
- data/bin/infunnel_cli +5 -0
- data/infunnel_cli.gemspec +29 -0
- data/lib/eloqua_api_service/credential.rb +56 -0
- data/lib/eloqua_api_service/email.rb +21 -0
- data/lib/eloqua_api_service/form.rb +24 -0
- data/lib/eloqua_api_service/login.rb +40 -0
- data/lib/eloqua_api_service/service.rb +23 -0
- data/lib/infunnel_cli.rb +6 -0
- data/lib/infunnel_cli/cli.rb +18 -0
- data/lib/infunnel_cli/cli/base.rb +86 -0
- data/lib/infunnel_cli/cli/eloqua.rb +42 -0
- data/lib/infunnel_cli/cli/email.rb +82 -0
- data/lib/infunnel_cli/cli/form.rb +88 -0
- data/lib/infunnel_cli/version.rb +3 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0c4c87451277056cb21287fa79e618dd27fa45c
|
4
|
+
data.tar.gz: 975ab2fd15ef0089e5e1c8fd748371f755f87df5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22ebd295cf809d9d68da614a774cdbc3e7b204d5d6e8c4ad8044842dc6d3ec30137212c6d3b4b96c2fcde1a4f3bf20ed35dc451b1ef30f1f2d17ef4ab2ad65ba
|
7
|
+
data.tar.gz: 854da4b76ee73595fab856e23540d86130d7936dcd8ab3743ffa5f4a27890c9cf2a84b17f5f1ee922d4dae2027f2545f7f438d88bccb773373978aa740687b57
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 lundevallan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
gem build infunnel_cli.gemspec
|
2
|
+
|
3
|
+
And dont forget to commit to git in case you get "are not files" error when running gem build due to this row:
|
4
|
+
|
5
|
+
spec.files = `git ls-files -z`.split("\x0")
|
6
|
+
|
7
|
+
https://rubygems.org/gems/ruby-keychain
|
8
|
+
https://github.com/fcheung/keychain
|
9
|
+
gem 'ruby-keychain', '~> 0.3.2'
|
10
|
+
gem 'ruby-keychain', :require => 'keychain'
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/infunnel_cli
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'infunnel_cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "infunnel_cli"
|
8
|
+
spec.version = InfunnelCli::VERSION
|
9
|
+
spec.authors = ["lundevallan"]
|
10
|
+
spec.email = ["linus.lundevall@infunnel.se"]
|
11
|
+
spec.summary = "A cli for working with marketing automation."
|
12
|
+
spec.description = "A cli for working with marketing automation."
|
13
|
+
spec.homepage = "http://infunnel.se"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["infunnel_cli"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
22
|
+
spec.add_dependency 'httparty', '~> 0.13.7'
|
23
|
+
spec.add_dependency 'nokogiri', '1.6.7.2'
|
24
|
+
spec.add_dependency 'keychain', '~> 0.2.3'
|
25
|
+
spec.add_dependency 'ruby-keychain', '~> 0.3.2'
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
28
|
+
spec.add_development_dependency "rake", '>= 11.2.2'
|
29
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module EloquaApiService
|
2
|
+
class Credential
|
3
|
+
|
4
|
+
attr_reader :key, :defaults
|
5
|
+
|
6
|
+
DEFAULT_SERVICE = 'infunnel_cli_default'
|
7
|
+
LABEL = 'infunnel_cli'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@key = nil
|
11
|
+
@defaults = {
|
12
|
+
label: LABEL
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def find(account: nil)
|
17
|
+
unless account
|
18
|
+
@key = default
|
19
|
+
return @key
|
20
|
+
end
|
21
|
+
|
22
|
+
@key ||= Keychain.generic_passwords.where(account: account).first
|
23
|
+
end
|
24
|
+
|
25
|
+
def all
|
26
|
+
Keychain.generic_passwords.where(label: LABEL).all
|
27
|
+
end
|
28
|
+
|
29
|
+
def create(make_default: nil, options: {})
|
30
|
+
find(account: options[:account]).delete
|
31
|
+
|
32
|
+
Keychain.generic_passwords.create(@defaults.merge(options))
|
33
|
+
|
34
|
+
if make_default || !default
|
35
|
+
set_default(account: options[:account])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def default
|
40
|
+
default_account = Keychain.generic_passwords.where(service: DEFAULT_SERVICE).first
|
41
|
+
|
42
|
+
@default ||= Keychain.generic_passwords.where(account: default_account.account).first
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_default(account:)
|
46
|
+
default = Keychain.generic_passwords.where(service: DEFAULT_SERVICE).first
|
47
|
+
default.delete if default
|
48
|
+
|
49
|
+
Keychain.generic_passwords.create({
|
50
|
+
password: 'none',
|
51
|
+
service: DEFAULT_SERVICE,
|
52
|
+
account: account
|
53
|
+
})
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'eloqua_api_service/service'
|
2
|
+
|
3
|
+
module EloquaApiService
|
4
|
+
class Email < Service
|
5
|
+
|
6
|
+
def find(id:)
|
7
|
+
response = self.class.get("/API/REST/1.0/assets/email/#{id}", @options)
|
8
|
+
parsed_response = JSON.parse(response.body, symbolize_names: true) rescue nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def preview(contact_id:, id:)
|
12
|
+
response = self.class.get("/API/REST/1.0//assets/email/#{id}/preview?contactId=#{contact_id}", @options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def campaign(campaign_id:)
|
16
|
+
response = self.class.get("/API/REST/1.0//assets/campaign/#{campaign_id}", @options)
|
17
|
+
JSON.parse(response.body, symbolize_names: true )[:elements]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'eloqua_api_service/service'
|
2
|
+
|
3
|
+
module EloquaApiService
|
4
|
+
class Form < Service
|
5
|
+
|
6
|
+
def find(id:)
|
7
|
+
response = self.class.get("/API/REST/1.0/assets/form/#{id}", @options)
|
8
|
+
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
def all
|
12
|
+
response = self.class.get("/API/REST/1.0/assets/forms", @options)
|
13
|
+
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
14
|
+
end
|
15
|
+
|
16
|
+
def data(id:, options: {})
|
17
|
+
start_at = options[:start_at] || 0
|
18
|
+
|
19
|
+
response = self.class.get("/API/REST/1.0/data/form/#{id}?startAt=#{start_at.to_i}", @options)
|
20
|
+
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module EloquaApiService
|
4
|
+
class Login
|
5
|
+
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
attr_accessor :options, :eloqua_auth, :eloqua_base_uri
|
9
|
+
|
10
|
+
def initialize(account: nil)
|
11
|
+
@credentials = Credential.new.find(account: account)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_options
|
15
|
+
@options = { headers: {
|
16
|
+
"Authorization" => "Basic #{@credentials.password}",
|
17
|
+
'Content-Type' => 'application/json'
|
18
|
+
},
|
19
|
+
body: {}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def define_credentials(company:, user_name:, password:)
|
24
|
+
@eloqua_auth = Base64.urlsafe_encode64( company + '\\' + user_name + ':' + password)
|
25
|
+
|
26
|
+
@options = {
|
27
|
+
headers: {
|
28
|
+
"Authorization" => "Basic #{@eloqua_auth}",
|
29
|
+
'Content-Type' => 'application/json'
|
30
|
+
},
|
31
|
+
body: {}
|
32
|
+
}
|
33
|
+
|
34
|
+
request = self.class.get('https://login.eloqua.com/id', @options)
|
35
|
+
return false unless request.success?
|
36
|
+
return JSON.parse(request.body)['urls']['base']
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'eloqua_api_service/credential'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
|
5
|
+
module EloquaApiService
|
6
|
+
class Service
|
7
|
+
|
8
|
+
include HTTParty
|
9
|
+
|
10
|
+
def initialize(account: nil)
|
11
|
+
@credentials = Credential.new.find(account: account)
|
12
|
+
|
13
|
+
self.class.base_uri @credentials.service
|
14
|
+
|
15
|
+
@options = { headers: {
|
16
|
+
"Authorization" => "Basic #{@credentials.password}",
|
17
|
+
'Content-Type' => 'application/json'
|
18
|
+
},
|
19
|
+
body: {}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/infunnel_cli.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'infunnel_cli/cli/email'
|
3
|
+
require 'infunnel_cli/cli/eloqua'
|
4
|
+
require 'infunnel_cli/cli/form'
|
5
|
+
require 'keychain'
|
6
|
+
#require 'ruby-keychain'
|
7
|
+
|
8
|
+
module InfunnelCli
|
9
|
+
class HammerOfTheGods < Thor
|
10
|
+
|
11
|
+
desc "email COMMANDS", ""
|
12
|
+
subcommand "email", InfunnelCli::CLI::Email
|
13
|
+
desc "login COMMANDS", ""
|
14
|
+
subcommand "eloqua", InfunnelCli::CLI::Eloqua
|
15
|
+
desc "form COMMANDS", ""
|
16
|
+
subcommand "form", InfunnelCli::CLI::Form
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'eloqua_api_service/login'
|
2
|
+
require 'eloqua_api_service/credential'
|
3
|
+
require 'eloqua_api_service/email'
|
4
|
+
require 'eloqua_api_service/form'
|
5
|
+
|
6
|
+
module InfunnelCli
|
7
|
+
module CLI
|
8
|
+
class Base < Thor
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def clear(text)
|
13
|
+
"\e[0m#{text}\e[0m"
|
14
|
+
end
|
15
|
+
|
16
|
+
def bold(text)
|
17
|
+
"\e[1m#{text}\e[0m"
|
18
|
+
end
|
19
|
+
|
20
|
+
def black(text)
|
21
|
+
"\e[30m#{text}\e[0m"
|
22
|
+
end
|
23
|
+
|
24
|
+
def red(text)
|
25
|
+
"\e[31m#{text}\e[0m"
|
26
|
+
end
|
27
|
+
|
28
|
+
def green(text)
|
29
|
+
"\e[32m#{text}\e[0m"
|
30
|
+
end
|
31
|
+
|
32
|
+
def yellow(text)
|
33
|
+
"\e[33m#{text}\e[0m"
|
34
|
+
end
|
35
|
+
|
36
|
+
def blue(text)
|
37
|
+
"\e[34m#{text}\e[0m"
|
38
|
+
end
|
39
|
+
|
40
|
+
def magenta(text)
|
41
|
+
"\e[35m#{text}\e[0m"
|
42
|
+
end
|
43
|
+
|
44
|
+
def cyan(text)
|
45
|
+
"\e[36m#{text}\e[0m"
|
46
|
+
end
|
47
|
+
|
48
|
+
def white(text)
|
49
|
+
"\e[37m#{text}\e[0m"
|
50
|
+
end
|
51
|
+
|
52
|
+
def on_black(text)
|
53
|
+
"\e[40m#{text}\e[0m"
|
54
|
+
end
|
55
|
+
|
56
|
+
def on_red(text)
|
57
|
+
"\e[41m#{text}\e[0m"
|
58
|
+
end
|
59
|
+
|
60
|
+
def on_green(text)
|
61
|
+
"\e[42m#{text}\e[0m"
|
62
|
+
end
|
63
|
+
|
64
|
+
def on_yellow(text)
|
65
|
+
"\e[43m#{text}\e[0m"
|
66
|
+
end
|
67
|
+
|
68
|
+
def on_blue(text)
|
69
|
+
"\e[44m#{text}\e[0m"
|
70
|
+
end
|
71
|
+
|
72
|
+
def on_magenta(text)
|
73
|
+
"\e[45m#{text}\e[0m"
|
74
|
+
end
|
75
|
+
|
76
|
+
def on_cyan(text)
|
77
|
+
"\e[46m#{text}\e[0m"
|
78
|
+
end
|
79
|
+
|
80
|
+
def on_white(text)
|
81
|
+
"\e[47m#{text}\e[0m"
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module InfunnelCli
|
2
|
+
module CLI
|
3
|
+
class Eloqua < Base
|
4
|
+
|
5
|
+
desc "Login", "Login to eloqua and save credentials in keychain"
|
6
|
+
option :default, aliases: :d, :type => :boolean
|
7
|
+
def login
|
8
|
+
say("Login to eloqua and save credentials in keychain")
|
9
|
+
company = ask("Company:")
|
10
|
+
user_name = ask("Username:")
|
11
|
+
password = ask("Password:")
|
12
|
+
|
13
|
+
login = EloquaApiService::Login.new
|
14
|
+
response = login.define_credentials(company: company, user_name: user_name, password: password)
|
15
|
+
|
16
|
+
if response
|
17
|
+
puts EloquaApiService::Credential.new.create(
|
18
|
+
make_default: options[:default],
|
19
|
+
options: {
|
20
|
+
password: login.eloqua_auth,
|
21
|
+
account: company,
|
22
|
+
service: response
|
23
|
+
})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Default login', 'Shows the default login'
|
28
|
+
def default_login
|
29
|
+
puts EloquaApiService::Credential.new.default.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'All logins', 'Show all logins saved in keychain'
|
33
|
+
def all_logins
|
34
|
+
puts yellow 'Accounts:'
|
35
|
+
puts EloquaApiService::Credential.new.all.map { |k| "#{bold k.account}, pod: #{k.service}" }
|
36
|
+
puts ''
|
37
|
+
puts yellow 'Default:'
|
38
|
+
puts bold EloquaApiService::Credential.new.default.account
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'infunnel_cli/cli/base'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'cgi'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
# docs for thor: http://whatisthor.com/
|
7
|
+
# more docs for thor: http://www.rubydoc.info/github/wycats/thor/Thor/Shell/Color
|
8
|
+
module InfunnelCli
|
9
|
+
module CLI
|
10
|
+
class Email < Base
|
11
|
+
#class_option :account
|
12
|
+
|
13
|
+
desc "find id", "Find email by id"
|
14
|
+
option :links, aliases: :l
|
15
|
+
option :full, aliases: :f
|
16
|
+
option :account, aliases: :a
|
17
|
+
def find( id )
|
18
|
+
|
19
|
+
email = EloquaApiService::Email.new(account: options[:account])
|
20
|
+
body = email.find(id: id)
|
21
|
+
|
22
|
+
if body.nil?
|
23
|
+
puts "\e[31m" + "#{id} not found"
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
puts '#' * 90
|
28
|
+
puts "\e[36m" + " Email name: #{body[:name]} (id: #{id})" + "\e[0m"
|
29
|
+
puts body[:hyperlinks].map.count
|
30
|
+
|
31
|
+
html = body[:htmlContent][:html]
|
32
|
+
puts "Rows: " + html.count("\n").to_s
|
33
|
+
n = Nokogiri::HTML.parse(html)
|
34
|
+
puts '-' * 90
|
35
|
+
|
36
|
+
n.css('a').each_with_index do |link, index|
|
37
|
+
|
38
|
+
puts "Link #{index + 1}:"
|
39
|
+
puts link[:href] =~ /\A#{URI::regexp()}\z/ ? 'Valid link' : 'invalid link'
|
40
|
+
|
41
|
+
puts link[:href]
|
42
|
+
puts link.to_s if options[:full]
|
43
|
+
puts ''
|
44
|
+
puts 'Params: '
|
45
|
+
|
46
|
+
unless link[:href] == ""
|
47
|
+
uri = URI.parse(link[:href])
|
48
|
+
params = CGI.parse(uri.query)
|
49
|
+
params.each do |param|
|
50
|
+
puts "#{param[0]}:"
|
51
|
+
puts "#{param[1].join(', ')}"
|
52
|
+
puts
|
53
|
+
end
|
54
|
+
end
|
55
|
+
#CGI::parse(link['href']).map {|k, v| puts "#{k} = #{v.join(',')}"}
|
56
|
+
puts '-' * 90
|
57
|
+
end
|
58
|
+
# Look for stray anchor tags
|
59
|
+
puts html.gsub(/<a /).count
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "find id", "Find email by id"
|
64
|
+
def preview(email_id, contact_id)
|
65
|
+
puts body = EloquaApiService::Email.new.preview(contact_id: contact_id, id: email_id)
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "find id", "Find email by id"
|
69
|
+
def campaign(campaign_id)
|
70
|
+
elements = EloquaApiService::Email.new.campaign(campaign_id: campaign_id)
|
71
|
+
puts elements.select { |e| e[:type] == 'CampaignEmail' }.map{ |e| find(e[:id]) }
|
72
|
+
end
|
73
|
+
|
74
|
+
# desc "find id", "Find email by id"
|
75
|
+
# option :links
|
76
|
+
# option :full
|
77
|
+
# def deliver( email_id )
|
78
|
+
# puts EloquaApiService::Email.new.deliver(email_id: email_id)
|
79
|
+
# end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'infunnel_cli/cli/base'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'cgi'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
|
7
|
+
module InfunnelCli
|
8
|
+
module CLI
|
9
|
+
class Form < Base
|
10
|
+
|
11
|
+
desc "find id", "Find email by id"
|
12
|
+
option :links, aliases: :l
|
13
|
+
option :full, aliases: :f
|
14
|
+
option :account, aliases: :a
|
15
|
+
def find( id )
|
16
|
+
puts EloquaApiService::Form.new.find(id: 50)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
desc "find id", "Find email by id"
|
21
|
+
option :links, aliases: :l
|
22
|
+
option :full, aliases: :f
|
23
|
+
option :account, aliases: :a
|
24
|
+
def all
|
25
|
+
puts EloquaApiService::Form.new.all[:elements] #.map{ |f| f[:id]}
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
desc "find id", "Find email by id"
|
30
|
+
option :live, aliases: :l
|
31
|
+
option :full, aliases: :f
|
32
|
+
option :account, aliases: :a
|
33
|
+
def data(form_id)
|
34
|
+
|
35
|
+
start_at = options[:full] ? 0 : Time.now - (76*3600)
|
36
|
+
fetch_options = { start_at: start_at }
|
37
|
+
|
38
|
+
form = EloquaApiService::Form.new.find(id: form_id)
|
39
|
+
elements = form[:elements]
|
40
|
+
|
41
|
+
puts black on_white "Form name: " + form[:name]
|
42
|
+
puts black on_white "Id: " + form[:id]
|
43
|
+
puts black on_white "Submits after: #{start_at}"
|
44
|
+
|
45
|
+
submissions = data_fetch(form_id: form_id, options: fetch_options)
|
46
|
+
|
47
|
+
first = true
|
48
|
+
|
49
|
+
if options[:live]
|
50
|
+
while true
|
51
|
+
new_data = data_fetch(form_id: form_id, options: fetch_options)
|
52
|
+
data_print(submissions: new_data, elements: elements) if first
|
53
|
+
|
54
|
+
only_new = new_data.reject { |s| submissions.map{ |old| old[:id] }.include?(s[:id]) }
|
55
|
+
data_print(submissions: only_new, elements: elements) if only_new != submissions && !first
|
56
|
+
|
57
|
+
submissions = new_data
|
58
|
+
first = false
|
59
|
+
sleep 7
|
60
|
+
end
|
61
|
+
else
|
62
|
+
data_print(submissions: submissions, elements: elements)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def data_fetch(form_id: nil, options: {})
|
69
|
+
start_at = options[:start_at] || Time.now - (76*3600)
|
70
|
+
EloquaApiService::Form.new.data(id: form_id, options: {start_at: start_at})[:elements]
|
71
|
+
end
|
72
|
+
|
73
|
+
def data_print(submissions: [], elements: {})
|
74
|
+
submissions.reverse.each do |submission|
|
75
|
+
row = []
|
76
|
+
row << "Id: #{submission[:id]}"
|
77
|
+
submission[:fieldValues].each do |field|
|
78
|
+
field_name = elements.find { |element| element[:id] == field[:id] }
|
79
|
+
row << "#{magenta(field_name[:htmlName])}: #{yellow(field[:value])}"
|
80
|
+
end
|
81
|
+
row << "At: #{Time.at(submission[:submittedAt].to_i)} \n\n"
|
82
|
+
puts row.join(', ')
|
83
|
+
end
|
84
|
+
return submissions
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: infunnel_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.13
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lundevallan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.13.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.13.7
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.7.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.7.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: keychain
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ruby-keychain
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.3.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.3.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 11.2.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 11.2.2
|
111
|
+
description: A cli for working with marketing automation.
|
112
|
+
email:
|
113
|
+
- linus.lundevall@infunnel.se
|
114
|
+
executables:
|
115
|
+
- infunnel_cli
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".DS_Store"
|
120
|
+
- ".gitignore"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/infunnel_cli
|
126
|
+
- infunnel_cli.gemspec
|
127
|
+
- lib/eloqua_api_service/credential.rb
|
128
|
+
- lib/eloqua_api_service/email.rb
|
129
|
+
- lib/eloqua_api_service/form.rb
|
130
|
+
- lib/eloqua_api_service/login.rb
|
131
|
+
- lib/eloqua_api_service/service.rb
|
132
|
+
- lib/infunnel_cli.rb
|
133
|
+
- lib/infunnel_cli/cli.rb
|
134
|
+
- lib/infunnel_cli/cli/base.rb
|
135
|
+
- lib/infunnel_cli/cli/eloqua.rb
|
136
|
+
- lib/infunnel_cli/cli/email.rb
|
137
|
+
- lib/infunnel_cli/cli/form.rb
|
138
|
+
- lib/infunnel_cli/version.rb
|
139
|
+
homepage: http://infunnel.se
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.6.4
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: A cli for working with marketing automation.
|
163
|
+
test_files: []
|