eloquant 0.9.1 → 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: 541ee997c003eeaea219467537db71bd4b1649a7
4
- data.tar.gz: 62d262046bd0f4b36d36757154675d0c810902ed
3
+ metadata.gz: 515f8ebffb63bdf249aa9b1246569c39a901db4a
4
+ data.tar.gz: 0f169aeaa49b9862dc6d66b69e243b8ad1fcd856
5
5
  SHA512:
6
- metadata.gz: c48c5a1087d0685b280b54693c2a390ec85d59c50617632d70ed125acc04c01772d521ae7a1d0642b00c07a22199498d64d9441ddc4cbbb00807459b17aec34b
7
- data.tar.gz: 466ea4b6afcd4cc0ebc18463b32201fd68c788defb160903b636f7d74934f72b0e941a3b7982be1711ead3ba7377f5af1402751d629b6f32e6f448325b2b6707
6
+ metadata.gz: ced9b7903ef4d19a9065fdd7028ab29feda0bfe8ba2377fe15c88eb55ffb41f9debb08c58a6e25be15000310f9bb43aac537b940d8fcd08f3619f06e98a4647f
7
+ data.tar.gz: 4f8eb29d5d44eba3c1eb0f62604aac08a57321ce7b08071ec3e97f7f6ad357182fde7572e4e23836a196dfda6afdf0f3833ef448c4043c39b3bca363ad775ae9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eloquant (0.9.1)
4
+ eloquant (1.0.0)
5
5
  faraday_middleware (> 0.9.0, < 0.11.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -115,23 +115,3 @@ Everyone interacting in the Eloquant project’s codebases, issue trackers, chat
115
115
  ## Releasing to [RubyGems](https://rubygems.org/gems/eloquant)
116
116
 
117
117
  Use the `bin/release` script to build, push, and tag this gem.
118
-
119
- ### Todo
120
-
121
- - [X] See if we can do OAuth Password Credentials Grant -> Nope
122
- - [X] Notes on using Basic HTTP Authentication
123
- - [X] `env.example`?
124
- - [ ] Implement endpoints
125
- - [ ] Documentation on options in code and in readme
126
-
127
- ## Endpoints to Implement
128
-
129
- - [ ] Accounts
130
- - [ ] Activities
131
- - [ ] Campaign Responses
132
- - [ ] Campaigns
133
- - [ ] Contacts
134
- - [ ] Custom Objects - no describe
135
- - [ ] Events - no describe
136
- - [ ] External Activities - no describe
137
- - [ ] Opportunities
data/bin/release CHANGED
@@ -2,8 +2,6 @@
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
- fail "Do it manually this time!"
6
-
7
5
  VERSION=$(grep VERSION lib/eloquant/version.rb | awk '{print $3}' | sed 's/"//g')
8
6
  TAG_VERSION="v$VERSION"
9
7
 
data/lib/eloquant.rb CHANGED
@@ -47,12 +47,13 @@ module Eloquant
47
47
  @max_retries = options.fetch(:max_retries, 10)
48
48
  @connection = options.fetch(:connection, nil)
49
49
  @debug = options.fetch(:debug, true)
50
+ @logger = options.fetch(:logger, nil)
50
51
  @host = options.fetch(:host, DEFAULT_HOST_URL)
51
52
 
52
53
  @options = options
53
54
  end
54
55
 
55
- %i(get post delete).each do |http_method|
56
+ %i(get post).each do |http_method|
56
57
  define_method(http_method) do |path, payload = {}, custom_headers = {}, &block|
57
58
  set_host_url_if_default
58
59
 
@@ -1,67 +1,38 @@
1
1
  module Eloquant
2
2
  module Accounts
3
3
  def describe_accounts
4
- get("/api/bulk/2.0/accounts/fields")
4
+ describe_endpoint(accounts)
5
5
  end
6
6
 
7
- def describe_accounts_csv(params = {})
8
- get("/api/bulk/2.0/accounts/fields", params, csv_custom_headers)
7
+ def describe_accounts_csv
8
+ describe_endpoint_csv(accounts)
9
9
  end
10
10
 
11
- def create_bulk_account_export(params = {})
12
- response = create_account_export(params)
13
- export_uri = response[:uri]
14
-
15
- status_response = enqueue_export(export_uri)
16
- sync_uri = status_response[:uri]
17
-
18
- status = status_response[:status]
19
-
20
- while status != "success"
21
- sleep(10)
22
-
23
- status_response = check_export_status(sync_uri)
24
- status = status_response[:status]
25
- end
26
-
27
- sync_uri
11
+ def number_of_accounts
12
+ count_endpoint(accounts)
28
13
  end
29
14
 
30
- def get_export_data(sync_uri, offset: nil)
31
- params = {}
32
- params[:offset] = offset if offset
15
+ def get_account(eloqua_external_id, depth: :complete)
16
+ params = {
17
+ search: "CompanyIDExt='#{eloqua_external_id}'",
18
+ depth: depth,
19
+ }
33
20
 
34
- get("/api/bulk/2.0#{sync_uri}/data", params)
21
+ get("/api/rest/1.0/data/accounts", params)
35
22
  end
36
23
 
37
- def list_account_exports
38
- get("/api/bulk/2.0/accounts/exports")
24
+ def create_bulk_account_export(params = {})
25
+ create_bulk_export(accounts, params)
39
26
  end
40
27
 
41
- def delete_account_export(id:)
42
- delete("/api/bulk/2.0/accounts/exports/#{id}")
28
+ def list_account_exports
29
+ list_bulk_exports(accounts)
43
30
  end
44
31
 
45
32
  private
46
33
 
47
- # Need a `name` and a `fields` list
48
- def create_account_export(name: "Eloquant Account Export", fields: {})
49
- params = {
50
- name: name,
51
- fields: fields,
52
- }
53
-
54
- json_post("/api/bulk/2.0/accounts/exports", params)
55
- end
56
-
57
- def enqueue_export(export_uri)
58
- params = { syncedInstanceUri: export_uri }
59
-
60
- json_post("/api/bulk/2.0/syncs", params)
61
- end
62
-
63
- def check_export_status(sync_uri)
64
- get("/api/bulk/2.0#{sync_uri}")
34
+ def accounts
35
+ "accounts"
65
36
  end
66
37
  end
67
38
  end
@@ -1,11 +1,31 @@
1
1
  module Eloquant
2
2
  module Activities
3
3
  def describe_activities
4
- get("/api/bulk/2.0/activities/fields")
4
+ describe_endpoint(activities)
5
5
  end
6
6
 
7
- def describe_activities_csv(params = {})
8
- get("/api/bulk/2.0/activities/fields", params, csv_custom_headers)
7
+ def describe_activities_csv
8
+ describe_endpoint_csv(activities)
9
9
  end
10
+
11
+ # Filter is the name of the activity type
12
+ def create_bulk_activity_export(fields:, filter:)
13
+ params = {
14
+ fields: fields,
15
+ filter: filter,
16
+ }
17
+
18
+ create_bulk_export(activities, params)
19
+ end
20
+
21
+ def list_activity_exports
22
+ list_bulk_exports(activities)
23
+ end
24
+
25
+ private
26
+
27
+ def activities
28
+ "activities"
29
+ end
10
30
  end
11
31
  end
@@ -1,11 +1,17 @@
1
1
  module Eloquant
2
2
  module CampaignResponses
3
3
  def describe_campaign_responses
4
- get("/api/bulk/2.0/campaignResponses/fields")
4
+ describe_endpoint(campaign_responses)
5
5
  end
6
6
 
7
- def describe_campaign_responses_csv(params = {})
8
- get("/api/bulk/2.0/campaignResponses/fields", params, csv_custom_headers)
7
+ def describe_campaign_responses_csv
8
+ describe_endpoint_csv(campaign_responses)
9
9
  end
10
+
11
+ private
12
+
13
+ def campaign_responses
14
+ "campaignResponses"
15
+ end
10
16
  end
11
17
  end
@@ -1,11 +1,30 @@
1
1
  module Eloquant
2
2
  module Campaigns
3
3
  def describe_campaigns
4
- get("/api/bulk/2.0/campaigns/fields")
4
+ describe_endpoint(campaigns)
5
5
  end
6
6
 
7
- def describe_campaigns_csv(params = {})
8
- get("/api/bulk/2.0/campaigns/fields", params, csv_custom_headers)
7
+ def describe_campaigns_csv
8
+ describe_endpoint_csv(campaigns)
9
9
  end
10
+
11
+ def number_of_campaigns
12
+ get_campaigns(count: 1).try(:[], :total)
13
+ end
14
+
15
+ def get_campaigns(page: nil, depth: :minimal, count: nil)
16
+ params = {}
17
+ params[:page] = page if !page.nil?
18
+ params[:depth] = depth if !depth.nil?
19
+ params[:count] = count if !count.nil?
20
+
21
+ get("/api/rest/2.0/assets/campaigns", params)
22
+ end
23
+
24
+ private
25
+
26
+ def campaigns
27
+ "campaigns"
28
+ end
10
29
  end
11
30
  end
@@ -23,7 +23,7 @@ module Eloquant
23
23
  ::Faraday::Error::TimeoutError,
24
24
  ::Faraday::ConnectionFailed]
25
25
 
26
- conn.response :logger if @debug
26
+ conn.response :logger, @logger if @debug && @logger
27
27
  conn.response :eloquant, content_type: /\bjson$/
28
28
 
29
29
  conn.options.timeout = @options[:read_timeout] if @options.key?(:read_timeout)
@@ -1,11 +1,38 @@
1
1
  module Eloquant
2
2
  module Contacts
3
3
  def describe_contacts
4
- get("/api/bulk/2.0/contacts/fields")
4
+ describe_endpoint(contacts)
5
5
  end
6
6
 
7
- def describe_contacts_csv(params = {})
8
- get("/api/bulk/2.0/contacts/fields", params, csv_custom_headers)
7
+ def describe_contacts_csv
8
+ describe_endpoint_csv(contacts)
9
9
  end
10
+
11
+ def number_of_contacts
12
+ count_endpoint(contacts)
13
+ end
14
+
15
+ def get_contact(eloqua_external_id)
16
+ params = {
17
+ search: "ContactIDExt='#{eloqua_external_id}'",
18
+ depth: "complete",
19
+ }
20
+
21
+ get("/api/rest/1.0/data/contacts", params)
22
+ end
23
+
24
+ def create_bulk_contact_export(params = {})
25
+ create_bulk_export(contacts, params)
26
+ end
27
+
28
+ def list_contact_exports
29
+ list_bulk_exports(contacts)
30
+ end
31
+
32
+ private
33
+
34
+ def contacts
35
+ "contacts"
36
+ end
10
37
  end
11
38
  end
@@ -11,5 +11,72 @@ module Eloquant
11
11
  def json_post(path, params)
12
12
  post(path, JSON.generate(params), json_custom_headers)
13
13
  end
14
+
15
+ def count_endpoint(endpoint)
16
+ get("/api/rest/1.0/data/#{endpoint}", count: 1).try(:[], :total)
17
+ end
18
+
19
+ def describe_endpoint(endpoint)
20
+ get("/api/bulk/2.0/#{endpoint}/fields")
21
+ end
22
+
23
+ def describe_endpoint_csv(endpoint, params = {})
24
+ get("/api/bulk/2.0/#{endpoint}/fields", params, csv_custom_headers)
25
+ end
26
+
27
+ def create_bulk_export(endpoint, params)
28
+ response = initialize_bulk_export(endpoint, params)
29
+
30
+ if response.has_key?(:failures)
31
+ fail Eloquant::Errors::BulkExportCreationError.new(response[:failures])
32
+ end
33
+
34
+ export_uri = response[:uri]
35
+
36
+ status_response = enqueue_export(export_uri)
37
+ sync_uri = status_response[:uri]
38
+
39
+ status = status_response[:status]
40
+
41
+ while status != "success"
42
+ sleep(10)
43
+
44
+ status_response = check_export_status(sync_uri)
45
+ status = status_response[:status]
46
+ end
47
+
48
+ sync_uri
49
+ end
50
+
51
+ def initialize_bulk_export(endpoint, name: nil, fields: {}, filter: nil)
52
+ params = {
53
+ name: name || "Eloquant #{endpoint.capitalize} Bulk Export",
54
+ fields: fields,
55
+ }
56
+ params[:filter] = filter if !filter.nil?
57
+
58
+ json_post("/api/bulk/2.0/#{endpoint}/exports", params)
59
+ end
60
+
61
+ def enqueue_export(export_uri)
62
+ params = { syncedInstanceUri: export_uri }
63
+
64
+ json_post("/api/bulk/2.0/syncs", params)
65
+ end
66
+
67
+ def check_export_status(sync_uri)
68
+ get("/api/bulk/2.0#{sync_uri}")
69
+ end
70
+
71
+ def get_export_data(sync_uri, offset: nil)
72
+ params = {}
73
+ params[:offset] = offset if offset
74
+
75
+ get("/api/bulk/2.0#{sync_uri}/data", params)
76
+ end
77
+
78
+ def list_bulk_exports(endpoint)
79
+ get("/api/bulk/2.0/#{endpoint}/exports")
80
+ end
14
81
  end
15
82
  end
@@ -1,11 +1,17 @@
1
1
  module Eloquant
2
2
  module Opportunities
3
3
  def describe_opportunities
4
- get("/api/bulk/2.0/opportunities/fields")
4
+ describe_endpoint(opportunities)
5
5
  end
6
6
 
7
- def describe_opportunities_csv(params = {})
8
- get("/api/bulk/2.0/opportunities/fields", params, csv_custom_headers)
7
+ def describe_opportunities_csv
8
+ describe_endpoint_csv(opportunities)
9
9
  end
10
+
11
+ private
12
+
13
+ def opportunities
14
+ "opportunities"
15
+ end
10
16
  end
11
17
  end
@@ -1,5 +1,5 @@
1
1
  module Eloquant
2
- class Errors
2
+ module Errors
3
3
  class Error < StandardError
4
4
  end
5
5
 
@@ -10,6 +10,7 @@ module Eloquant
10
10
  Unknown = create_class
11
11
  EmptyResponse = create_class
12
12
  AuthorizationError = create_class
13
+ BulkExportCreationError = create_class
13
14
 
14
15
  RESPONSE_CODE_TO_ERROR = {}.freeze
15
16
 
@@ -1,3 +1,3 @@
1
1
  module Eloquant
2
- VERSION = "0.9.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eloquant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Stumbaugh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-26 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware