gooddata_marketo 0.0.1

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 +17 -0
  7. data/bin/main.rb +0 -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 +24 -0
  13. data/gooddata_marketo_gem.zip +0 -0
  14. data/lib/gooddata_marketo.rb +24 -0
  15. data/lib/gooddata_marketo/adapters/rest.rb +287 -0
  16. data/lib/gooddata_marketo/client.rb +373 -0
  17. data/lib/gooddata_marketo/data/activity_types.rb +104 -0
  18. data/lib/gooddata_marketo/data/reserved_sql_keywords.rb +205 -0
  19. data/lib/gooddata_marketo/helpers/s3.rb +141 -0
  20. data/lib/gooddata_marketo/helpers/stringwizard.rb +32 -0
  21. data/lib/gooddata_marketo/helpers/table.rb +323 -0
  22. data/lib/gooddata_marketo/helpers/webdav.rb +118 -0
  23. data/lib/gooddata_marketo/loads.rb +235 -0
  24. data/lib/gooddata_marketo/models/campaigns.rb +57 -0
  25. data/lib/gooddata_marketo/models/channels.rb +30 -0
  26. data/lib/gooddata_marketo/models/child/activity.rb +104 -0
  27. data/lib/gooddata_marketo/models/child/criteria.rb +17 -0
  28. data/lib/gooddata_marketo/models/child/lead.rb +118 -0
  29. data/lib/gooddata_marketo/models/child/mobj.rb +68 -0
  30. data/lib/gooddata_marketo/models/etl.rb +75 -0
  31. data/lib/gooddata_marketo/models/leads.rb +493 -0
  32. data/lib/gooddata_marketo/models/load.rb +17 -0
  33. data/lib/gooddata_marketo/models/mobjects.rb +121 -0
  34. data/lib/gooddata_marketo/models/streams.rb +137 -0
  35. data/lib/gooddata_marketo/models/tags.rb +35 -0
  36. data/lib/gooddata_marketo/models/validate.rb +46 -0
  37. metadata +177 -0
@@ -0,0 +1,17 @@
1
+ class GoodDataMarketo::LoadFile
2
+
3
+ attr_accessor :name
4
+ attr_accessor :method
5
+ attr_accessor :type
6
+ attr_accessor :arguments
7
+
8
+ def initialize config = {}
9
+ @name = config[:name]
10
+ @type = config[:type]
11
+ @method = config[:method]
12
+ @arguments = {
13
+ :ids => config[:ids] || config[:values],
14
+ :type => config[:type]
15
+ }
16
+ end
17
+ end
@@ -0,0 +1,121 @@
1
+ # encoding: UTF-8
2
+ # http://developers.marketo.com/documentation/soap/getmobjects/
3
+ require 'gooddata_marketo/models/child/criteria'
4
+ require 'gooddata_marketo/models/child/mobj'
5
+
6
+ class GoodDataMarketo::MObjects
7
+
8
+ attr_reader :client
9
+
10
+ def initialize config = {}
11
+
12
+ @obj_criteria_list = []
13
+ @client = config[:client]
14
+
15
+ end
16
+
17
+ def get config = {} # http://developers.marketo.com/documentation/soap/getcampaignsforsource/
18
+
19
+ # EXAMPLE CRITERIA
20
+ # criteria = {
21
+ # :attr_name => "Id", # See the types of content it can search above.
22
+ # :comparison => "LE",
23
+ # :attr_value => "1010"
24
+ # }
25
+
26
+ # EXAMPLE ASSOCIATED OBJECT
27
+ # # m_associated_object = {
28
+ # :m_obj_type => '',
29
+ # :id=> '',
30
+ # :external_key => '' <-- Optional
31
+ # }
32
+
33
+ # EXAMPLE CRITERIA COMPARISONS
34
+ # EQ - Equals
35
+ # NE - Not Equals
36
+ # LT - Less Than
37
+ # LE - Less Than or Equals
38
+ # GT - Greater Than
39
+ # GE - Greater Than or Equals
40
+
41
+ # ACCEPTED ATTRIBUTE VALUE ITEMS
42
+ # Name: Name of the MObject
43
+ # Role: The role associated with an OpportunityPersonRole object
44
+ # Type: The type of an Opportunity object
45
+ # Stage:- The stage of an Opportunity object
46
+ # CRM Id: the CRM Id could refer to the Id of the Salesforce campaign connected to a Marketo program. Note: The SFDC Campaign ID needs to be the 18-digit ID.
47
+ # Created At: Equals, not equals, less than, less than or equal to, greater than, greater than or equal to
48
+ # Two “created dates” can be specified to create a date range
49
+ # Updated At or Tag Type (only one can be specified): Equals, not equals, less than, less than or equal to, greater than, greater than or equal to
50
+ # Two “created dates” can be specified to create a date range
51
+ # Tag Value: (Only one can be specified)
52
+ # Workspace Name: (only one can be specified)
53
+ # Workspace Id: (only one can be specified)
54
+ # Include Archive: Applicable only with Program MObject. Set it to true if you wish to include archived programs.
55
+
56
+ # AVAILABLE TYPES
57
+ # Program
58
+ # OpportunityPersonRole
59
+ # Opportunity
60
+
61
+ type = config[:type] || "Program"
62
+ request = { :type => type }
63
+
64
+ criteria = config[:criteria] || @obj_criteria_list
65
+ request[:m_obj_criteria_list] = criteria if criteria
66
+ associate = config[:association] || config[:m_obj_association] || config[:associate]
67
+
68
+ if associate
69
+ request[:m_obj_association_list] = Hash.new
70
+ request[:m_obj_association_list][:m_obj_association] = associate
71
+ end
72
+
73
+ # This field is optional and only present during `type => 'Program'` calls.
74
+ if type == "Program"
75
+ request[:include_details] = config[:include_details].to_s || "false"
76
+ end
77
+
78
+ c = client.stream(:get_m_objects, request)
79
+
80
+ mobjects_from_call = []
81
+ c.storage.each do |request|
82
+ request[:m_object_list][:m_object].each do |mobj|
83
+ m = GoodDataMarketo::MObject.new mobj
84
+ mobjects_from_call << m
85
+ end
86
+ end
87
+
88
+ binding.pry
89
+ mobjects_from_call
90
+
91
+ end
92
+
93
+ def add_criteria name, value, comparison
94
+
95
+ obj = {}
96
+ obj[:m_obj_criteria] = {
97
+ :attr_name => name.to_s,
98
+ :comparison => comparison.to_s,
99
+ :attr_value => value.to_s
100
+ }
101
+
102
+ @obj_criteria_list << obj
103
+
104
+ end
105
+
106
+ def criteria
107
+ @obj_criteria_list
108
+ end
109
+
110
+ def remove_criteria query
111
+ match = @obj_criteria_list.find {|item| item[:m_obj_criteria][:attr_name] == query }
112
+ @obj_criteria_list.delete(match)
113
+ end
114
+
115
+ alias :remove :remove_criteria
116
+
117
+ alias :add :add_criteria
118
+
119
+ end
120
+
121
+
@@ -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
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gooddata_marketo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick McConlogue
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.61.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.61.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyntlm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.7.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.7.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: pmap
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: savon
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.8.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: gooddata
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.6.11
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.11
97
+ - !ruby/object:Gem::Dependency
98
+ name: gooddata_datawarehouse
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.0.5
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.0.5
111
+ description: A gem.
112
+ email: patrick.mcconlogue@gooddata.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - Gemfile
118
+ - Gemfile.lock
119
+ - README.md
120
+ - bin/Gemfile
121
+ - bin/auth.json
122
+ - bin/main.rb
123
+ - bin/process.rbx
124
+ - examples/all_lead_changes.rb
125
+ - examples/all_leads.rb
126
+ - examples/lead_changes_to_ads.rb
127
+ - gooddata_marketo.gemspec
128
+ - gooddata_marketo_gem.zip
129
+ - lib/gooddata_marketo.rb
130
+ - lib/gooddata_marketo/adapters/rest.rb
131
+ - lib/gooddata_marketo/client.rb
132
+ - lib/gooddata_marketo/data/activity_types.rb
133
+ - lib/gooddata_marketo/data/reserved_sql_keywords.rb
134
+ - lib/gooddata_marketo/helpers/s3.rb
135
+ - lib/gooddata_marketo/helpers/stringwizard.rb
136
+ - lib/gooddata_marketo/helpers/table.rb
137
+ - lib/gooddata_marketo/helpers/webdav.rb
138
+ - lib/gooddata_marketo/loads.rb
139
+ - lib/gooddata_marketo/models/campaigns.rb
140
+ - lib/gooddata_marketo/models/channels.rb
141
+ - lib/gooddata_marketo/models/child/activity.rb
142
+ - lib/gooddata_marketo/models/child/criteria.rb
143
+ - lib/gooddata_marketo/models/child/lead.rb
144
+ - lib/gooddata_marketo/models/child/mobj.rb
145
+ - lib/gooddata_marketo/models/etl.rb
146
+ - lib/gooddata_marketo/models/leads.rb
147
+ - lib/gooddata_marketo/models/load.rb
148
+ - lib/gooddata_marketo/models/mobjects.rb
149
+ - lib/gooddata_marketo/models/streams.rb
150
+ - lib/gooddata_marketo/models/tags.rb
151
+ - lib/gooddata_marketo/models/validate.rb
152
+ homepage: https://github.com/thnkr/connectors/tree/master/marketo
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 1.9.3
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.2.2
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Marketo SOAP/REST wrapper to CSV/GoodData ADS
176
+ test_files: []
177
+ has_rdoc: