infunnel_cli 0.0.162 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eda30ecb7514dffd323d458bccb53bb41af889f4
4
- data.tar.gz: ed8eeecaaaa2ab071d1da988906806a1d9279037
3
+ metadata.gz: 173b256e237a97297b40432378f6edd16b08ffe7
4
+ data.tar.gz: 942d25c8ff28e5f89898a56f8927be088bbbba9f
5
5
  SHA512:
6
- metadata.gz: 405e75e51306e65b9057f7366c0fe897d9eade2e029d9a7c6c618398f486140f9c8acb7b58958583add1a1185ed2af0245518691f45a59f72a97f1cabf0a41fb
7
- data.tar.gz: 23d612b77e988ddfd04fafc7e0ac5ddf0012a530373d5241b24c903d712ac979fb46aee4cdb9a353ac5eff57acd71e63987a86297508f03cdd97261d875465e4
6
+ metadata.gz: 490471b40fb6d70688efde3dabf66f2c5b8d6938bb9c9e19c76f05dfeae7c77fbaea4432c24444564610861b86d1d5f72f9c24e968b07ebb814338803d84ce96
7
+ data.tar.gz: 7037d10a1b4e345bea6572e17180ed3703162e3aa4867c9803a7266a3d2a2c403957dbbdd8160d3a06c1d1a05303d11a24c194b54c7ba85c5c0a3b99a4222808
data/README.md CHANGED
@@ -19,4 +19,12 @@ Add warnings if no eloqua credentials are stored in keychain.
19
19
 
20
20
  docs for thor: http://whatisthor.com/
21
21
 
22
- more docs for thor: http://www.rubydoc.info/github/wycats/thor/Thor/Shell/Color
22
+ more docs for thor: http://www.rubydoc.info/github/wycats/thor/Thor/Shell/Color
23
+
24
+ ### Usage of the cli on mac
25
+
26
+ pipe results into copy memory: infunnel_cli option_list find 4 --html | pbcopy
27
+
28
+ ## Future improvements
29
+
30
+ Make account name editable so you dont have to spell out the full company name
@@ -0,0 +1,15 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class Campaign < Service
5
+ BASE_PATH = "/API/REST/2.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/assets/campaign/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/assets/campaigns?depth=complete", @options))
13
+ end
14
+ end
15
+ end
@@ -9,8 +9,14 @@ module EloquaApiService
9
9
  end
10
10
 
11
11
  def activities(contact_id:)
12
- response = self.class.get("#{BASE_PATH}/data/activities/contact/#{contact_id}?type=formSubmit&startDate=#{Time.new(2014,7,6).strftime('%s')}&endDate=#{Time.new(2017,7,9).strftime('%s')}&count=1000&depth=complete", @options)
13
- parse(response)
12
+
13
+ responses = []
14
+ types = ['emailOpen', 'emailSend', 'emailClickThrough', 'emailSubscribe', 'emailUnsubscribe', 'formSubmit', 'webVisit', 'campaignMembership']
15
+ types.each do |type|
16
+ response = self.class.get("#{BASE_PATH}/data/activities/contact/#{contact_id}?type=#{type}&startDate=#{Time.new(2000,7,6).strftime('%s')}&endDate=#{Time.new(2100,7,9).strftime('%s')}&count=1000&depth=complete", @options)
17
+ responses << parse(response) rescue []
18
+ end
19
+ responses
14
20
  end
15
21
 
16
22
  def search(term: '')
@@ -0,0 +1,15 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class ContactList < Service
5
+ BASE_PATH = "/API/REST/1.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/assets/contact/list/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/assets/contact/lists?depth=complete", @options))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class ContactSegment < Service
5
+ BASE_PATH = "/API/REST/1.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/assets/contact/segment/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/assets/contact/segments?depth=complete", @options))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class CustomObject < Service
5
+ BASE_PATH = "/API/REST/1.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/assets/customObject/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/assets/customObjects?depth=complete", @options))
13
+ end
14
+
15
+ def data_by_id(id:)
16
+ parse(self.class.get("#{BASE_PATH}/data/customObject/#{id}?depth=complete", @options))
17
+ end
18
+ end
19
+ end
@@ -13,7 +13,7 @@ module EloquaApiService
13
13
 
14
14
  def get_options
15
15
  @options = { headers: {
16
- "Authorization" => "Basic #{@credentials.password}",
16
+ 'Authorization' => "Basic #{@credentials.password}",
17
17
  'Content-Type' => 'application/json'
18
18
  },
19
19
  body: {}
@@ -25,7 +25,7 @@ module EloquaApiService
25
25
 
26
26
  @options = {
27
27
  headers: {
28
- "Authorization" => "Basic #{@eloqua_auth}",
28
+ 'Authorization' => "Basic #{@eloqua_auth}",
29
29
  'Content-Type' => 'application/json'
30
30
  },
31
31
  body: {}
@@ -0,0 +1,15 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class OptionList < Service
5
+ BASE_PATH = "/API/REST/1.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/assets/optionList/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/assets/optionLists?depth=complete", @options))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class Program < Service
5
+ BASE_PATH = "/API/REST/1.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/assets/program/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/assets/programs?depth=complete", @options))
13
+ end
14
+
15
+ def find_step(id)
16
+ parse(self.class.get("#{BASE_PATH}/assets/program/step/#{id}?depth=Complete", @options))
17
+ end
18
+ end
19
+ end
@@ -12,7 +12,7 @@ module EloquaApiService
12
12
  self.class.base_uri @credentials.service
13
13
 
14
14
  @options = { headers: {
15
- "Authorization" => "Basic #{@credentials.password}",
15
+ 'Authorization' => "Basic #{@credentials.password}",
16
16
  'Content-Type' => 'application/json'
17
17
  },
18
18
  body: {}
@@ -22,5 +22,9 @@ module EloquaApiService
22
22
  def parse(response)
23
23
  JSON.parse(response.body, symbolize_names: true)
24
24
  end
25
+
26
+ def parse_body(body)
27
+ JSON.parse(body, symbolize_names: true)
28
+ end
25
29
  end
26
30
  end
@@ -0,0 +1,15 @@
1
+ require 'eloqua_api_service/service'
2
+
3
+ module EloquaApiService
4
+ class User < Service
5
+ BASE_PATH = "/API/REST/1.0"
6
+
7
+ def find(id:)
8
+ parse(self.class.get("#{BASE_PATH}/system/user/#{id}?depth=complete", @options))
9
+ end
10
+
11
+ def all
12
+ parse(self.class.get("#{BASE_PATH}/system/users?depth=complete", @options))
13
+ end
14
+ end
15
+ end
@@ -6,8 +6,6 @@ module EloquaApiService
6
6
 
7
7
  def find_by_guid(guid:)
8
8
  response = self.class.get("#{BASE_PATH}/data/visitors?search=externalId=#{guid}&page=1&count=5", @options)
9
- # puts response.request.inspect
10
- # puts response.inspect
11
9
  parse(response)
12
10
  end
13
11
 
@@ -7,6 +7,13 @@ require 'eloqua_api_service/email'
7
7
  require 'eloqua_api_service/form'
8
8
  require 'eloqua_api_service/contact'
9
9
  require 'eloqua_api_service/visitor'
10
+ require 'eloqua_api_service/option_list'
11
+ require 'eloqua_api_service/program'
12
+ require 'eloqua_api_service/campaign'
13
+ require 'eloqua_api_service/user'
14
+ require 'eloqua_api_service/custom_object'
15
+ require 'eloqua_api_service/contact_segment'
16
+ require 'eloqua_api_service/contact_list'
10
17
 
11
18
  module InfunnelCli
12
19
  module CLI
@@ -14,6 +21,17 @@ module InfunnelCli
14
21
 
15
22
  private
16
23
 
24
+ def format_value(key, value)
25
+ if ['createdAt', 'updatedAt', 'activityDate'].any? { |word| key.to_s.include?(word) }
26
+ return parse_date(value)
27
+ end
28
+ return value
29
+ end
30
+
31
+ def parse_date(unix_date)
32
+ DateTime.strptime(unix_date, '%s').strftime('%Y-%m-%d %H:%M:%S')
33
+ end
34
+
17
35
  def clear(text)
18
36
  "\e[0m#{text}\e[0m"
19
37
  end
@@ -0,0 +1,29 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class Campaign < Base
6
+
7
+ desc "find :id", "Show Campaign with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ EloquaApiService::Campaign.new(account: options[:account]).find(id: id).each do |k, v|
13
+ puts "#{k}: #{v}"
14
+ end
15
+ end
16
+
17
+ desc "all", "All Campaigns in current eloqua account"
18
+ option :account, aliases: :a
19
+ def all
20
+ EloquaApiService::Campaign.new(account: options[:account]).all[:elements].each do |program|
21
+ puts '-'*90
22
+ program.each do |k, v|
23
+ puts "#{k}: #{v}"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -25,8 +25,19 @@ module InfunnelCli
25
25
  activities = EloquaApiService::Contact.new(account: options[:account]).activities(contact_id: contact_id)
26
26
 
27
27
  activities.each do |a|
28
- puts a
29
- puts '*' * 90
28
+ a.each do |e|
29
+ puts
30
+ e.each do |k, v|
31
+ if k == :details
32
+ puts "#{white k}:"
33
+ v.each do |_k, _v|
34
+ puts "#{ clear _k } #{ clear _v}"
35
+ end
36
+ else
37
+ puts "#{ white k }: #{ clear format_value(k,v)}"
38
+ end
39
+ end
40
+ end
30
41
  end
31
42
  puts activities.count
32
43
  end
@@ -45,8 +56,8 @@ module InfunnelCli
45
56
  :updatedAt,
46
57
  :createdAt,
47
58
  :id,
48
- :emailAddress,
49
- :fieldValues
59
+ :emailAddress#,
60
+ #:fieldValues
50
61
  ]
51
62
 
52
63
  string += "\n\nFields: \n"
@@ -57,7 +68,7 @@ module InfunnelCli
57
68
  end
58
69
  end
59
70
 
60
- def parse_date(unix_date)
71
+ def parse_date(unix_date)
61
72
  DateTime.strptime(unix_date, '%s').strftime('%Y-%m-%d %H:%M')
62
73
  end
63
74
  end
@@ -0,0 +1,30 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class ContactList < Base
6
+
7
+ desc "find :id", "Show contact list with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ EloquaApiService::ContactList.new(account: options[:account]).find(id: id).each do |k, v|
13
+
14
+ puts "#{k}: #{v}"
15
+ end
16
+ end
17
+
18
+ desc "all", "All contact lists in current eloqua account"
19
+ option :account, aliases: :a
20
+ def all
21
+ EloquaApiService::ContactList.new(account: options[:account]).all[:elements].each do |list|
22
+ puts '-'*90
23
+ list.each do |k, v|
24
+ puts "#{k}: #{v}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class ContactSegment < Base
6
+
7
+ desc "find :id", "Show contact segment with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ EloquaApiService::ContactSegment.new(account: options[:account]).find(id: id).each do |k, v|
13
+
14
+ puts "#{k}: #{v}"
15
+ end
16
+ end
17
+
18
+ desc "all", "All contact segments in current eloqua account"
19
+ option :account, aliases: :a
20
+ def all
21
+ EloquaApiService::ContactSegment.new(account: options[:account]).all[:elements].each do |segment|
22
+ puts '-'*90
23
+ segment.each do |k, v|
24
+ puts "#{k}: #{v}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,47 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class CustomObject < Base
6
+
7
+ desc "find :id", "Show CustomObject with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ EloquaApiService::CustomObject.new(account: options[:account]).find(id: id).each do |k, v|
13
+
14
+ puts "#{k}: #{v}"
15
+ end
16
+ end
17
+
18
+ desc "all", "All CustomObjects in current eloqua account"
19
+ option :account, aliases: :a
20
+ def all
21
+ EloquaApiService::CustomObject.new(account: options[:account]).all[:elements].each do |custom_object|
22
+ puts '-'*90
23
+ custom_object.each do |k, v|
24
+ puts "#{k}: #{v}"
25
+ end
26
+ end
27
+ end
28
+
29
+ desc "get data by id", "CustomObjects data by id"
30
+ option :account, aliases: :a
31
+ def data(id)
32
+ EloquaApiService::CustomObject.new(account: options[:account]).data_by_id(id: id)[:elements].each do |custom_object|
33
+ puts '-'*90
34
+ custom_object.each do |k, v|
35
+ if k == :fieldValues
36
+ v.each do |_k, _v|
37
+ puts "#{_k}: #{_v}"
38
+ end
39
+ else
40
+ puts "#{k}: #{v}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -2,7 +2,7 @@ module InfunnelCli
2
2
  module CLI
3
3
  class Eloqua < Base
4
4
 
5
- desc "Login", "Login to eloqua and save credentials in keychain"
5
+ desc "login", "Login to eloqua and save credentials in keychain"
6
6
  option :default, aliases: :d, :type => :boolean
7
7
  def login
8
8
  say("Login to eloqua and save credentials in keychain")
@@ -10,105 +10,156 @@ module InfunnelCli
10
10
  option :account, aliases: :a
11
11
  option :verbose, aliases: :v
12
12
  def find( id )
13
- form_print(forms: [EloquaApiService::Form.new(account: options[:account]).find(id: id)], options: options)
14
- end
13
+ form_print(forms: [EloquaApiService::Form.new(account: options[:account]).find(id: id)], options: options)
14
+ end
15
+
16
+ desc "all", "All forms in current eloqua account"
17
+ option :links, aliases: :l
18
+ option :full, aliases: :f
19
+ option :account, aliases: :a
20
+ option :verbose, aliases: :v
21
+ def all
22
+ form_print(forms: EloquaApiService::Form.new(account: options[:account]).all[:elements], options: options)
23
+ end
24
+
25
+ desc "search :term", "Find form by search on it's name"
26
+ option :account, aliases: :a
27
+ option :verbose, aliases: :v
28
+ def search(term)
29
+ form_print(forms: EloquaApiService::Form.new(account: options[:account]).search(term: term)[:elements], options: options)
30
+ end
15
31
 
16
- desc "all", "All forms in current eloqua account"
17
- option :links, aliases: :l
18
- option :full, aliases: :f
19
- option :account, aliases: :a
20
- option :verbose, aliases: :v
21
- def all
22
- form_print(forms: EloquaApiService::Form.new(account: options[:account]).all[:elements], options: options)
23
- end
32
+ desc "data :id", "Get form submissions by form id"
33
+ option :live, aliases: :l
34
+ option :raw, aliases: :r
35
+ option :count, aliases: :c
36
+ option :csv
37
+ option :full, aliases: :f
38
+ option :account, aliases: :a
39
+ def data(form_id)
24
40
 
25
- desc "search :term", "Find form by search on it's name"
26
- option :account, aliases: :a
27
- option :verbose, aliases: :v
28
- def search(term)
29
- form_print(forms: EloquaApiService::Form.new(account: options[:account]).search(term: term)[:elements], options: options)
30
- end
41
+ start_at = options[:full] ? 0 : Time.now - (5*360*24*3600)
42
+ fetch_options = { start_at: start_at, account: options[:account]}
31
43
 
32
- desc "data :id", "Get form submissions by form id"
33
- option :live, aliases: :l
34
- option :full, aliases: :f
35
- option :account, aliases: :a
36
- def data(form_id)
44
+ form = EloquaApiService::Form.new(account: options[:account]).find(id: form_id)
45
+ elements = form[:elements]
37
46
 
38
- start_at = options[:full] ? 0 : Time.now - (76*3600)
39
- fetch_options = { start_at: start_at, account: options[:account] }
47
+ unless options[:csv]
48
+ puts black on_white "Form name: #{form[:name]}"
49
+ puts black on_white "Id: #{form[:id]}"
50
+ puts black on_white "Submits after: #{start_at}"
51
+ end
40
52
 
41
- form = EloquaApiService::Form.new(account: options[:account]).find(id: form_id)
42
- elements = form[:elements]
53
+ submissions = data_fetch(form_id: form_id, options: fetch_options)
43
54
 
44
- puts black on_white "Form name: " + form[:name]
45
- puts black on_white "Id: " + form[:id]
46
- puts black on_white "Submits after: #{start_at}"
55
+ if options[:count]
56
+ puts submissions.size
57
+ return
58
+ end
47
59
 
48
- submissions = data_fetch(form_id: form_id, options: fetch_options)
60
+ if options[:raw]
61
+ puts submissions.to_json
62
+ return
63
+ end
49
64
 
50
- first = true
65
+ first = true
51
66
 
52
- if options[:live]
53
- while true
54
- new_data = data_fetch(form_id: form_id, options: fetch_options)
55
- data_print(submissions: new_data, elements: elements) if first
67
+ if options[:live]
68
+ while true
69
+ new_data = data_fetch(form_id: form_id, options: fetch_options)
70
+ data_print(submissions: new_data, elements: elements) if first
56
71
 
57
- only_new = new_data.reject { |s| submissions.map{ |old| old[:id] }.include?(s[:id]) }
58
- data_print(submissions: only_new, elements: elements) if only_new != submissions && !first
72
+ only_new = new_data.reject { |s| submissions.map{ |old| old[:id] }.include?(s[:id]) }
73
+ data_print(submissions: only_new, elements: elements) if only_new != submissions && !first
59
74
 
60
- submissions = new_data
61
- first = false
62
- sleep 7
63
- end
64
- else
65
- data_print(submissions: submissions, elements: elements)
75
+ submissions = new_data
76
+ first = false
77
+ sleep 7
78
+ end
79
+ else
80
+ data_print(submissions: submissions, elements: elements, options: { csv: options[:csv] } )
81
+ if options[:full]
82
+ puts "Total submissions: #{submissions.count}"
66
83
  end
67
84
  end
85
+ end
86
+
87
+ private
88
+
89
+ def form_print(forms: [], options: {})
68
90
 
69
- private
70
-
71
- def form_print(forms: [], options: {})
72
- forms.each_with_index do |form, index|
73
- string = "Id: #{form[:id]}, "
74
- string += "name: #{form[:name]}, "
75
- string += "fields: #{form[:elements].count}, "
76
- string += "created_at: #{parse_date(form[:createdAt])}, "
77
- string += "updated_at: #{parse_date(form[:updatedAt])} "
78
- if options[:verbose]
79
- string += "\n\nFields: \n"
80
- string += form[:elements].map{ |e| " " +
81
- e.reject{ |k| [:style, :validations].include?(k)
91
+ forms.each_with_index do |form, index|
92
+ string = "Id: #{form[:id]}, "
93
+ string += "name: #{form[:name]}, "
94
+ string += "fields: #{form[:elements].count}, "
95
+ string += "created_at: #{parse_date(form[:createdAt])}, "
96
+ string += "updated_at: #{parse_date(form[:updatedAt])} "
97
+ if options[:verbose]
98
+ string += "\n\nFields: \n"
99
+ string += form[:elements].map{ |e| " " +
100
+ e.reject{ |k| [:style, :validations].include?(k)
82
101
  }.map{ |k, v| "#{k}: #{v}" }.join(', ')
83
102
  }.join("\n")
103
+ end
104
+ puts (index.odd? ? black(on_white(string)) : white(on_black(string)))
105
+ puts ''
84
106
  end
85
- puts (index.odd? ? black(on_white(string)) : white(on_black(string)))
86
- puts ''
87
107
  end
88
- end
89
108
 
90
- def data_fetch(form_id: nil, options: {})
91
- start_at = options[:start_at] || Time.now - (76*3600)
92
- EloquaApiService::Form.new(account: options[:account]).data(id: form_id, options: {start_at: start_at})[:elements]
93
- end
109
+ def data_fetch(form_id: nil, options: {})
110
+ start_at = options[:start_at] || Time.now - (76*3600)
111
+ EloquaApiService::Form.new(account: options[:account]).data(id: form_id, options: {start_at: start_at})[:elements]
112
+ end
94
113
 
95
- def data_print(submissions: [], elements: {})
96
- submissions.reverse.each do |submission|
97
- row = []
98
- row << "Id: #{submission[:id]}"
99
- submission[:fieldValues].each do |field|
100
- field_name = elements.find { |element| element[:id] == field[:id] }
101
- row << "#{magenta(field_name[:htmlName])}: #{yellow(field[:value])}" rescue nil
114
+ def data_print(submissions: [], elements: {}, options: {})
115
+
116
+ if options[:csv]
117
+ csv_heading = []
118
+ rows = []
119
+ submissions.reverse.each_with_index do |submission, index|
120
+
121
+ row = []
122
+ if index == 0
123
+ csv_heading = elements.map {|e| e[:htmlName] }
124
+ csv_heading << "submittedAt"
125
+ end
126
+ submission[:fieldValues].each_with_index do |field, index|
127
+ field_name = elements.find { |element| element[:id] == field[:id] }
128
+ row << field[:value] rescue ''
129
+ end
130
+
131
+ rows << row
132
+ row << Time.at(submission[:submittedAt].to_i)
133
+
134
+ end
135
+
136
+ csv_string = CSV.generate do |csv|
137
+ csv << csv_heading
138
+ rows.each do |row|
139
+ csv << row
140
+ end
141
+ end
142
+
143
+ puts csv_string
144
+ return submissions
102
145
  end
103
- row << "At: #{Time.at(submission[:submittedAt].to_i)} \n\n"
104
- puts row.join(', ')
146
+
147
+ submissions.reverse.each do |submission|
148
+ row = []
149
+ row << "Id: #{submission[:id]}"
150
+ submission[:fieldValues].each do |field|
151
+ field_name = elements.find { |element| element[:id] == field[:id] }
152
+ row << "#{magenta(field_name[:htmlName])}: #{yellow(field[:value])}" rescue nil
153
+ end
154
+ row << "At: #{Time.at(submission[:submittedAt].to_i)} \n\n"
155
+ puts row.join(', ')
156
+ end
157
+ return submissions
105
158
  end
106
- return submissions
107
- end
108
159
 
109
- def parse_date(unix_date)
110
- DateTime.strptime(unix_date, '%s').strftime('%Y-%m-%d %H:%M')
160
+ def parse_date(unix_date)
161
+ DateTime.strptime(unix_date, '%s').strftime('%Y-%m-%d %H:%M')
162
+ end
111
163
  end
112
164
  end
113
165
  end
114
- end
@@ -0,0 +1,41 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class OptionList < Base
6
+
7
+ desc "find :id", "Sow option list with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ ol = EloquaApiService::OptionList.new(account: options[:account]).find(id: id)
13
+
14
+ if options[:format]
15
+ ol[:elements].each do |f|
16
+ puts "#{f[:displayName]}|#{f[:value]}"
17
+ end
18
+ elsif options[:html]
19
+ puts "<select name='#{ol[:name]}'>"
20
+ ol[:elements].each do |f|
21
+ puts "<option value='#{f[:value]}'>#{f[:displayName]}</option>"
22
+ end
23
+ puts "</select>"
24
+ else
25
+ puts ol
26
+ end
27
+ end
28
+
29
+ desc "all", "All option lists in current eloqua account"
30
+ option :account, aliases: :a
31
+ def all
32
+ EloquaApiService::OptionList.new(account: options[:account]).all[:elements].each do |ol|
33
+ puts '-' * 90
34
+ ol.each do |k, v|
35
+ puts "#{k}: #{v}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,46 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class Program < Base
6
+
7
+ desc "find :id", "Show program with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ EloquaApiService::Program.new(account: options[:account]).find(id: id).each do |k, v|
13
+
14
+ if k == :steps
15
+ puts 'Steps: '
16
+ v.each do |_k, _v|
17
+ find_step(_k[:id])
18
+ end
19
+ else
20
+ puts "#{k}: #{v}"
21
+ end
22
+ end
23
+ end
24
+
25
+ desc "all", "All programs in current eloqua account"
26
+ option :account, aliases: :a
27
+ def all
28
+ EloquaApiService::Program.new(account: options[:account]).all[:elements].each do |program|
29
+ puts '-'*90
30
+ program.each do |k, v|
31
+ puts "#{black on_white k}: #{v}"
32
+ end
33
+ end
34
+ end
35
+
36
+ desc "find_sted", "Find a program step by id"
37
+ option :account, aliases: :a
38
+ def find_step(id)
39
+ puts '-'*90
40
+ EloquaApiService::Program.new(account: options[:account]).find_step(id).each do |k, v|
41
+ puts "#{k}: #{v}"
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,30 @@
1
+ require 'infunnel_cli/cli/base'
2
+
3
+ module InfunnelCli
4
+ module CLI
5
+ class User < Base
6
+
7
+ desc "find :id", "Show user with id"
8
+ option :account, aliases: :a
9
+ option :format, aliases: :f
10
+ option :html
11
+ def find( id )
12
+ EloquaApiService::User.new(account: options[:account]).find(id: id).each do |k, v|
13
+
14
+ puts "#{k}: #{format_value(k,v)}"
15
+ end
16
+ end
17
+
18
+ desc "all", "All users in current eloqua account"
19
+ option :account, aliases: :a
20
+ def all
21
+ EloquaApiService::User.new(account: options[:account]).all[:elements].each do |user|
22
+ puts '-'*90
23
+ user.each do |k, v|
24
+ puts "#{k}: #{format_value(k,v)}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -10,12 +10,24 @@ module InfunnelCli
10
10
  option :full, aliases: :f
11
11
  option :account, aliases: :a
12
12
  def find_by_guid(guid)
13
- response = EloquaApiService::Visitor.new(account: options[:account]).find_by_guid(guid: guid)
13
+
14
+ response = EloquaApiService::Visitor.new(account: options[:account]).find_by_guid(guid: format_guid(guid))
15
+ response[:elements].each do |e|
16
+ puts '-'*90
17
+ puts e
18
+ end
14
19
  puts response
15
20
  puts EloquaApiService::Contact.new(account: options[:account]).find(id: response[:elements][0][:contactId]) rescue "No contact id on this visitor."
16
21
  end
17
22
 
23
+ private
18
24
 
25
+ def format_guid(guid)
26
+ unless guid.include? "-"
27
+ return guid.dup.insert(8, '-').insert(13,'-').insert(18,'-').insert(23,'-').downcase
28
+ end
29
+ guid
30
+ end
19
31
  end
20
32
  end
21
33
  end
@@ -4,25 +4,54 @@ require 'infunnel_cli/cli/eloqua'
4
4
  require 'infunnel_cli/cli/form'
5
5
  require 'infunnel_cli/cli/contact'
6
6
  require 'infunnel_cli/cli/visitor'
7
+ require 'infunnel_cli/cli/option_list'
8
+ require 'infunnel_cli/cli/program'
9
+ require 'infunnel_cli/cli/campaign'
10
+ require 'infunnel_cli/cli/user'
11
+ require 'infunnel_cli/cli/custom_object'
12
+ require 'infunnel_cli/cli/contact_segment'
13
+ require 'infunnel_cli/cli/contact_list'
7
14
  require 'keychain'
8
15
  #require 'ruby-keychain'
9
16
 
10
17
  module InfunnelCli
11
18
  class Tools < Thor
12
19
 
13
- desc "email COMMANDS", ""
20
+ desc "email", ""
14
21
  subcommand "email", InfunnelCli::CLI::Email
15
22
 
16
- desc "login COMMANDS", ""
23
+ desc "eloqua", ""
17
24
  subcommand "eloqua", InfunnelCli::CLI::Eloqua
18
25
 
19
- desc "form COMMANDS", ""
26
+ desc "form", ""
20
27
  subcommand "form", InfunnelCli::CLI::Form
21
28
 
22
- desc "contact COMMANDS", ""
29
+ desc "contact", ""
23
30
  subcommand "contact", InfunnelCli::CLI::Contact
24
31
 
25
- desc "visitor COMMANDS", ""
32
+ desc "visitor", ""
26
33
  subcommand "visitor", InfunnelCli::CLI::Visitor
34
+
35
+ desc "option_list", ""
36
+ subcommand "option_list", InfunnelCli::CLI::OptionList
37
+
38
+ desc "program", ""
39
+ subcommand "program", InfunnelCli::CLI::Program
40
+
41
+ desc "campaign", ""
42
+ subcommand "campaign", InfunnelCli::CLI::Campaign
43
+
44
+ desc "user", ""
45
+ subcommand "user", InfunnelCli::CLI::User
46
+
47
+ desc "custom_object", ""
48
+ subcommand "custom_object", InfunnelCli::CLI::CustomObject
49
+
50
+ desc "contact_segment", ""
51
+ subcommand "contact_segment", InfunnelCli::CLI::ContactSegment
52
+
53
+ desc "contact_list", ""
54
+ subcommand "contact_list", InfunnelCli::CLI::ContactList
55
+
27
56
  end
28
57
  end
@@ -1,3 +1,3 @@
1
1
  module InfunnelCli
2
- VERSION = "0.0.162"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infunnel_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.162
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lundevallan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -130,20 +130,34 @@ files:
130
130
  - Rakefile
131
131
  - bin/infunnel_cli
132
132
  - infunnel_cli.gemspec
133
+ - lib/eloqua_api_service/campaign.rb
133
134
  - lib/eloqua_api_service/contact.rb
135
+ - lib/eloqua_api_service/contact_list.rb
136
+ - lib/eloqua_api_service/contact_segment.rb
134
137
  - lib/eloqua_api_service/credential.rb
138
+ - lib/eloqua_api_service/custom_object.rb
135
139
  - lib/eloqua_api_service/email.rb
136
140
  - lib/eloqua_api_service/form.rb
137
141
  - lib/eloqua_api_service/login.rb
142
+ - lib/eloqua_api_service/option_list.rb
143
+ - lib/eloqua_api_service/program.rb
138
144
  - lib/eloqua_api_service/service.rb
145
+ - lib/eloqua_api_service/user.rb
139
146
  - lib/eloqua_api_service/visitor.rb
140
147
  - lib/infunnel_cli.rb
141
148
  - lib/infunnel_cli/cli.rb
142
149
  - lib/infunnel_cli/cli/base.rb
150
+ - lib/infunnel_cli/cli/campaign.rb
143
151
  - lib/infunnel_cli/cli/contact.rb
152
+ - lib/infunnel_cli/cli/contact_list.rb
153
+ - lib/infunnel_cli/cli/contact_segment.rb
154
+ - lib/infunnel_cli/cli/custom_object.rb
144
155
  - lib/infunnel_cli/cli/eloqua.rb
145
156
  - lib/infunnel_cli/cli/email.rb
146
157
  - lib/infunnel_cli/cli/form.rb
158
+ - lib/infunnel_cli/cli/option_list.rb
159
+ - lib/infunnel_cli/cli/program.rb
160
+ - lib/infunnel_cli/cli/user.rb
147
161
  - lib/infunnel_cli/cli/visitor.rb
148
162
  - lib/infunnel_cli/version.rb
149
163
  homepage: http://infunnel.se