gooddata_marketo 0.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +131 -0
  4. data/README.md +207 -0
  5. data/bin/Gemfile +10 -0
  6. data/bin/auth.json +16 -0
  7. data/bin/main.rb +24 -0
  8. data/bin/process.rbx +541 -0
  9. data/examples/all_lead_changes.rb +119 -0
  10. data/examples/all_leads.rb +249 -0
  11. data/examples/lead_changes_to_ads.rb +63 -0
  12. data/gooddata_marketo.gemspec +25 -0
  13. data/lib/gooddata_marketo/adapters/rest.rb +287 -0
  14. data/lib/gooddata_marketo/client.rb +373 -0
  15. data/lib/gooddata_marketo/data/activity_types.rb +104 -0
  16. data/lib/gooddata_marketo/data/reserved_sql_keywords.rb +205 -0
  17. data/lib/gooddata_marketo/helpers/s3.rb +141 -0
  18. data/lib/gooddata_marketo/helpers/stringwizard.rb +32 -0
  19. data/lib/gooddata_marketo/helpers/table.rb +323 -0
  20. data/lib/gooddata_marketo/helpers/webdav.rb +118 -0
  21. data/lib/gooddata_marketo/loads.rb +235 -0
  22. data/lib/gooddata_marketo/models/campaigns.rb +57 -0
  23. data/lib/gooddata_marketo/models/channels.rb +30 -0
  24. data/lib/gooddata_marketo/models/child/activity.rb +104 -0
  25. data/lib/gooddata_marketo/models/child/criteria.rb +17 -0
  26. data/lib/gooddata_marketo/models/child/lead.rb +118 -0
  27. data/lib/gooddata_marketo/models/child/mobj.rb +68 -0
  28. data/lib/gooddata_marketo/models/etl.rb +75 -0
  29. data/lib/gooddata_marketo/models/leads.rb +493 -0
  30. data/lib/gooddata_marketo/models/load.rb +17 -0
  31. data/lib/gooddata_marketo/models/mobjects.rb +121 -0
  32. data/lib/gooddata_marketo/models/streams.rb +137 -0
  33. data/lib/gooddata_marketo/models/tags.rb +35 -0
  34. data/lib/gooddata_marketo/models/validate.rb +46 -0
  35. data/lib/gooddata_marketo.rb +24 -0
  36. data/process.rb +517 -0
  37. metadata +177 -0
@@ -0,0 +1,137 @@
1
+ # encoding: UTF-8
2
+
3
+
4
+ # http://developers.marketo.com/documentation/soap/stream-position/
5
+ require 'timeout'
6
+ require 'date'
7
+
8
+ class GoodDataMarketo::Stream
9
+
10
+ attr_reader :client
11
+
12
+ def initialize(web_method, request, config = {})
13
+
14
+ def start_stream(web_method, request, config)
15
+
16
+ @timer_start = Time.now
17
+ puts "#{@timer_start} => Start Streaming:#{web_method}" if GoodDataMarketo.logging
18
+
19
+ @client = config[:client]
20
+ @storage = []
21
+
22
+ # Make an initial call to determine what type of stream Marketo will respond with. This is based on the configurations in the initial request.
23
+ initialized_stream = @client.call(web_method, request)
24
+ raise "ERROR: No response from Marketo based on query: #{request}" unless initialized_stream
25
+
26
+ begin
27
+
28
+ # Timeout.timeout(config[:timeout] || 100){
29
+ @storage << initialized_stream.to_json
30
+ # }
31
+
32
+ if initialized_stream[:new_stream_position].is_a? String
33
+ @stream_id = initialized_stream[:new_stream_position]
34
+ @stream_id_monitor = true
35
+ @offset_monitor = false
36
+ else
37
+ initialized_stream.delete(:start_position)
38
+ @offset_monitor = true
39
+ @stream_id_monitor = false
40
+ @offset = initialized_stream[:new_start_position][:offset]
41
+ end
42
+
43
+ @count = initialized_stream[:remaining_count].to_i
44
+
45
+ puts "#{Time.now} => Stream:#{web_method}:#{@count} remain." if GoodDataMarketo.logging
46
+
47
+ rescue Timeout::Error => e
48
+ client.load.log('TIMEOUT') if client.load
49
+ puts e if GoodDataMarketo.logging
50
+ end
51
+
52
+ end
53
+
54
+ start_stream(web_method, request, config)
55
+
56
+ @timeouts = 0
57
+ # Begin a loop to iterate by offset or stream id depending on the stream response from Marketo.
58
+ def next_stream_request web_method, request
59
+
60
+ begin
61
+
62
+ new_request = {}
63
+ request = new_request.merge(request)
64
+
65
+ if @stream_id
66
+ request[:stream_position] = @stream_id
67
+ end
68
+
69
+ if @count < 1000
70
+ request[:batch_size] = @count.to_s
71
+ end
72
+
73
+ chunk_from_stream = @client.call(web_method, request)
74
+
75
+ @storage << chunk_from_stream.to_json
76
+
77
+ # FOR GET LEAD ACTIVITIES. The return count and remaining count are not stacked. Request 100 and it says 8 remaining, request a batch of 8 and it says 100 remaining. No stream id.
78
+ if chunk_from_stream[:return_count]
79
+ @count = @count - chunk_from_stream[:return_count].to_i
80
+ else
81
+ @count = chunk_from_stream[:remaining_count].to_i
82
+ end
83
+
84
+ puts "#{Time.now} => Stream:#{web_method}:#{@count} remain." if GoodDataMarketo.logging
85
+
86
+ if chunk_from_stream[:new_stream_position].is_a? String
87
+ @stream_id = chunk_from_stream[:new_stream_position]
88
+ @stream_id_monitor = true
89
+ @offset_monitor = false
90
+ else
91
+ @offset_monitor = true
92
+ @stream_id_monitor = false
93
+ @offset = chunk_from_stream[:new_start_position][:offset]
94
+
95
+ # Update Request
96
+ request[:start_position] = {
97
+ :offset => @offset
98
+ }
99
+
100
+ end
101
+
102
+ rescue Error => e
103
+ puts e if GoodDataMarketo.logging
104
+ retry if @timeouts < 3
105
+
106
+ end
107
+
108
+ end
109
+
110
+ while @count > 0
111
+ next_stream_request web_method, request
112
+ end
113
+
114
+ @timer_end = Time.now
115
+ puts "#{@timer_end} => End Streaming: #{web_method}" if GoodDataMarketo.logging
116
+ puts "#{Time.now} => Stream duration: #{((@timer_end - @timer_start)/60).round} minutes." if GoodDataMarketo.logging
117
+
118
+ storage_index = 0
119
+ @storage.map! { |m|
120
+ storage_index += 1
121
+ puts "#{Time.now} => Hashing streams in storage: #{storage_index}" if GoodDataMarketo.logging
122
+ JSON.parse(m, :symbolize_names => true)
123
+ }
124
+
125
+ end
126
+
127
+ def storage
128
+ @storage
129
+ end
130
+
131
+ end
132
+
133
+ class GoodDataMarketo::SafeStream
134
+ def initialize stream
135
+ @stream = stream
136
+ end
137
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: UTF-8
2
+
3
+ # http://developers.marketo.com/documentation/soap/gettags/
4
+
5
+ class GoodDataMarketo::Client
6
+
7
+ attr_reader :client
8
+
9
+ def tags config = {} # http://developers.marketo.com/documentation/soap/gettags/
10
+
11
+ values = config[:values] || config[:value] || config[:lead]
12
+ values = [values] if values.is_a? String
13
+
14
+ if config[:type]
15
+ request = {
16
+ :tag_list => {
17
+ :tag => {
18
+ :type => config[:type],
19
+ :values => {
20
+ :string_item => values
21
+ }
22
+ }
23
+ }
24
+ }
25
+ else
26
+ request = {}
27
+ end
28
+
29
+ response = self.call(:get_tags, request)
30
+
31
+ end
32
+
33
+ end
34
+
35
+
@@ -0,0 +1,46 @@
1
+ # encoding: UTF-8
2
+
3
+ class GoodDataMarketo::Validate
4
+ def initialize config
5
+
6
+ default = {
7
+ :backend => 'ads'
8
+ }
9
+ config = default.merge(config)
10
+
11
+ end
12
+
13
+ end
14
+
15
+ # require 'rubygems'
16
+ # require 'sequel'
17
+ # require 'jdbc/dss'
18
+ #
19
+ # results = []
20
+ # tables = []
21
+ # final = []
22
+ #
23
+ # Jdbc::DSS.load_driver
24
+ # Java.com.gooddata.dss.jdbc.driver.DssDriver
25
+ #
26
+ # url1 = "jdbc:dss://secure.gooddata.com/gdc/dss/instances/df963b44d7b8a90494ad29e978039a52"
27
+ # username = ''
28
+ # password = ''
29
+ #
30
+ # Sequel.connect url1, :username => username, :password => password do |conn|
31
+ # results = conn.fetch "select t.table_name, c.column_name, c.data_type
32
+ # from tables t
33
+ # join columns c on c.table_name = t.table_name
34
+ # order by t.table_name"
35
+ # end
36
+ #
37
+ # binding.pry
38
+ # #put results in array, not table thing that I don't understand
39
+ # results.each do |row|
40
+ # tables.push([row[:table_name],row[:column_name],row[:data_type]])
41
+ # end
42
+ # puts "Printing tables having columns with numeric datatypes"
43
+ # tables.each do |table|
44
+ # final << table[0] if table[2].include?('numeric')
45
+ # end
46
+ # puts final.uniq
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+
3
+ module GoodDataMarketo
4
+ VERSION = "0.0.1"
5
+
6
+ class << self
7
+
8
+ attr_accessor :logging
9
+
10
+ def client(config = {})
11
+ GoodDataMarketo.logging = false
12
+ GoodDataMarketo::Client.new(config)
13
+ end
14
+
15
+ def freeze(*args) # Bloc freeze args.
16
+ args.each(&:freeze).freeze
17
+ end
18
+
19
+ alias :connect :client
20
+
21
+ end
22
+ end
23
+
24
+ require 'gooddata_marketo/client'