eloqua_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ module Eloqua
2
+ class BulkClient < Client
3
+ BULK_API_PATH = "/API/Bulk/1.0"
4
+
5
+ def bulk_path(path)
6
+ BULK_API_PATH + '/' + path
7
+ end
8
+
9
+ # convenience methods
10
+ def define_export(export_definition)
11
+ post(bulk_path("contact/export"), export_definition)
12
+ end
13
+
14
+ def sync(export_uri)
15
+ post(bulk_path("sync"), {"syncedInstanceUri" => export_uri}.to_json)
16
+ end
17
+
18
+ def sync_status(sync_uri)
19
+ get(bulk_path(sync_uri))
20
+ end
21
+
22
+ def retrieve_export(export_uri, options={})
23
+ options[:page] ||= 1
24
+ options[:page_size] ||= 50000
25
+
26
+ get(bulk_path("#{export_uri}/data?page=#{options[:page]}&pageSize=#{options[:page_size]}"))
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,53 @@
1
+ require 'net/https'
2
+
3
+ module Eloqua
4
+ class Client
5
+ attr_reader :site, :user
6
+
7
+ def initialize(site=nil, user=nil, password=nil)
8
+ @site = site
9
+ @user = user
10
+ @password = password
11
+
12
+ @https = Net::HTTP.new('secure.eloqua.com', 443)
13
+ @https.use_ssl = true
14
+ @https.verify_mode = OpenSSL::SSL::VERIFY_PEER
15
+ end
16
+
17
+ METHODS = {
18
+ :get => ::Net::HTTP::Get,
19
+ :post => ::Net::HTTP::Post,
20
+ :put => ::Net::HTTP::Put,
21
+ :delete => ::Net::HTTP::Delete
22
+ }
23
+
24
+ def delete(path)
25
+ request(:delete, path)
26
+ end
27
+
28
+ def get(path)
29
+ request(:get, path)
30
+ end
31
+
32
+ def post(path, body={})
33
+ request(:post, path, body)
34
+ end
35
+
36
+ def put(path, body={})
37
+ request(:put, path, body)
38
+ end
39
+
40
+ def request(method, path, body={})
41
+ request = METHODS[method].new(path, {'Content-Type' =>'application/json'})
42
+ request.basic_auth @site + '\\' + @user, @password
43
+
44
+ case method
45
+ when :post, :put
46
+ request.body = body
47
+ end
48
+
49
+ response = @https.request(request)
50
+ return response
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,28 @@
1
+ module Eloqua
2
+ class RESTClient < Client
3
+ REST_API_PATH = "/API/REST/1.0"
4
+
5
+ def rest_path(path)
6
+ REST_API_PATH + '/' + path
7
+ end
8
+
9
+ # convenience methods
10
+ def create_segment(segment_definition)
11
+ # debugger
12
+ post(rest_path("assets/contact/segment"), segment_definition)
13
+ end
14
+
15
+ def get_segment(segment_id)
16
+ get(rest_path("assets/contact/segment/#{segment_id}"))
17
+ end
18
+
19
+ def contact_activity(contact_id, options={})
20
+ options["start_date"] ||= 1.year.ago.to_i
21
+ options["end_date"] ||= Time.now.to_i
22
+ options["type"] ||= "webVisit"
23
+ options["count"] ||= 1000
24
+
25
+ get(rest_path("data/activities/contact/#{contact_id}?startDate=#{options["start_date"]}&endDate=#{options["end_date"]}&type=#{options["type"]}&count=#{options["count"]}"))
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eloqua_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nader Akhnoukh
@@ -27,15 +27,18 @@ extensions: []
27
27
  extra_rdoc_files: []
28
28
 
29
29
  files:
30
+ - lib/eloqua/bulk_client.rb
31
+ - lib/eloqua/client.rb
32
+ - lib/eloqua/rest_client.rb
30
33
  - lib/eloqua.rb
31
- homepage: http://rubygems.org/gems/eloqua
34
+ homepage: http://rubygems.org/gems/eloqua_api
32
35
  licenses: []
33
36
 
34
37
  post_install_message:
35
38
  rdoc_options: []
36
39
 
37
40
  require_paths:
38
- - lib
41
+ - - lib
39
42
  required_ruby_version: !ruby/object:Gem::Requirement
40
43
  none: false
41
44
  requirements: