constantcontact 1.0.0 → 1.0.1
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 +7 -7
- data/README.md +7 -0
- data/constantcontact.gemspec +1 -1
- data/lib/constantcontact.rb +54 -54
- data/lib/constantcontact/api.rb +5 -3
- data/lib/constantcontact/auth/oauth2.rb +7 -4
- data/lib/constantcontact/auth/session_data_store.rb +52 -52
- data/lib/constantcontact/components/account/verified_email_address.rb +17 -17
- data/lib/constantcontact/components/activities/activity.rb +34 -34
- data/lib/constantcontact/components/activities/activity_error.rb +17 -17
- data/lib/constantcontact/components/activities/add_contacts.rb +109 -109
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -37
- data/lib/constantcontact/components/activities/export_contacts.rb +19 -19
- data/lib/constantcontact/components/component.rb +13 -13
- data/lib/constantcontact/components/contacts/address.rb +18 -18
- data/lib/constantcontact/components/contacts/contact.rb +69 -69
- data/lib/constantcontact/components/contacts/contact_list.rb +17 -17
- data/lib/constantcontact/components/contacts/custom_field.rb +17 -17
- data/lib/constantcontact/components/contacts/email_address.rb +23 -23
- data/lib/constantcontact/components/contacts/note.rb +16 -16
- data/lib/constantcontact/components/email_marketing/campaign.rb +67 -67
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +17 -17
- data/lib/constantcontact/components/email_marketing/message_footer.rb +20 -20
- data/lib/constantcontact/components/email_marketing/schedule.rb +18 -18
- data/lib/constantcontact/components/email_marketing/test_send.rb +32 -32
- data/lib/constantcontact/components/result_set.rb +15 -15
- data/lib/constantcontact/components/tracking/bounce_activity.rb +18 -18
- data/lib/constantcontact/components/tracking/click_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/forward_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/open_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/send_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/tracking_activity.rb +15 -15
- data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +18 -18
- data/lib/constantcontact/exceptions/ctct_exception.rb +15 -15
- data/lib/constantcontact/exceptions/illegal_argument_exception.rb +3 -3
- data/lib/constantcontact/exceptions/oauth2_exception.rb +3 -3
- data/lib/constantcontact/services/account_service.rb +19 -19
- data/lib/constantcontact/services/activity_service.rb +99 -99
- data/lib/constantcontact/services/base_service.rb +24 -24
- data/lib/constantcontact/services/campaign_schedule_service.rb +85 -85
- data/lib/constantcontact/services/campaign_tracking_service.rb +151 -151
- data/lib/constantcontact/services/contact_service.rb +106 -106
- data/lib/constantcontact/services/contact_tracking_service.rb +151 -151
- data/lib/constantcontact/services/email_marketing_service.rb +66 -66
- data/lib/constantcontact/services/list_service.rb +67 -67
- data/lib/constantcontact/util/config.rb +102 -96
- data/lib/constantcontact/util/helpers.rb +18 -18
- data/lib/constantcontact/version.rb +4 -4
- data/spec/constantcontact/api_spec.rb +223 -173
- data/spec/constantcontact/auth/oauth2_spec.rb +68 -4
- data/spec/constantcontact/components/contacts/address_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/contact_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/custom_field_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/email_address_spec.rb +7 -7
- data/spec/constantcontact/services/contact_service_spec.rb +95 -95
- data/spec/constantcontact/services/list_service_spec.rb +48 -48
- data/spec/spec_helper.rb +1 -1
- metadata +55 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f4035ebff0d2fa600a1671cf3aec57955f32e57
|
4
|
+
data.tar.gz: c395ffc1e0e64498f04f49f1850b63ee7c798ecf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a6c7fb69db0876b55e1d26215d940520d0fd612dcd219bdebfb75bde753b9c32798127db1ac74012719c37068ca26fe03bdac9e8873ed8bfe44d232f0d2bd4c
|
7
|
+
data.tar.gz: 8edaaebe146ff2b94f22604a97704fdbcad79041e0460ba79cc6995aa6f34eda229b41a8233ba080c1824dcf9c4ac722f35e50b614e11d5935debb9bc12a5bc6
|
data/README.md
CHANGED
@@ -70,6 +70,13 @@ Follow the link, go through all the Constant Contact steps required
|
|
70
70
|
and then you will be redirected back to your action and you should see the list of contacts.
|
71
71
|
|
72
72
|
|
73
|
+
6. Add config initializer (optional)
|
74
|
+
````ruby
|
75
|
+
ConstantContact::Util::Config.configure do |config|
|
76
|
+
config[:auth][:api_key] = 'foobar'
|
77
|
+
config[:auth][:api_secret] = 'foobar'
|
78
|
+
end
|
79
|
+
|
73
80
|
B. Sinatra example :
|
74
81
|
|
75
82
|
|
data/constantcontact.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.summary = %q{Constant Contact SDK for Ruby}
|
14
14
|
s.email = "apisupport@constantcontact.com"
|
15
15
|
s.description = "Ruby library for interactions with Constant Contact v2 API"
|
16
|
-
s.version = "1.0.0"
|
16
|
+
#s.version = "1.0.0"
|
17
17
|
s.license = "MIT"
|
18
18
|
|
19
19
|
s.files = [
|
data/lib/constantcontact.rb
CHANGED
@@ -13,63 +13,63 @@ require 'cgi/session/pstore'
|
|
13
13
|
|
14
14
|
|
15
15
|
module ConstantContact
|
16
|
-
|
16
|
+
autoload :Api, "constantcontact/api"
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
module Auth
|
19
|
+
autoload :OAuth2, "constantcontact/auth/oauth2"
|
20
|
+
autoload :Session, "constantcontact/auth/session_data_store"
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
23
|
+
module Components
|
24
|
+
autoload :Component, "constantcontact/components/component"
|
25
|
+
autoload :ResultSet, "constantcontact/components/result_set"
|
26
|
+
autoload :Activity, "constantcontact/components/activities/activity"
|
27
|
+
autoload :ActivityError, "constantcontact/components/activities/activity_error"
|
28
|
+
autoload :AddContacts, "constantcontact/components/activities/add_contacts"
|
29
|
+
autoload :AddContactsImportData, "constantcontact/components/activities/add_contacts_import_data"
|
30
|
+
autoload :ExportContacts, "constantcontact/components/activities/export_contacts"
|
31
|
+
autoload :Address, "constantcontact/components/contacts/address"
|
32
|
+
autoload :Contact, "constantcontact/components/contacts/contact"
|
33
|
+
autoload :ContactList, "constantcontact/components/contacts/contact_list"
|
34
|
+
autoload :CustomField, "constantcontact/components/contacts/custom_field"
|
35
|
+
autoload :EmailAddress, "constantcontact/components/contacts/email_address"
|
36
|
+
autoload :Note, "constantcontact/components/contacts/note"
|
37
|
+
autoload :ClickThroughDetails, "constantcontact/components/email_marketing/click_through_details"
|
38
|
+
autoload :Campaign, "constantcontact/components/email_marketing/campaign"
|
39
|
+
autoload :MessageFooter, "constantcontact/components/email_marketing/message_footer"
|
40
|
+
autoload :Schedule, "constantcontact/components/email_marketing/schedule"
|
41
|
+
autoload :TestSend, "constantcontact/components/email_marketing/test_send"
|
42
|
+
autoload :BounceActivity, "constantcontact/components/tracking/bounce_activity"
|
43
|
+
autoload :ClickActivity, "constantcontact/components/tracking/click_activity"
|
44
|
+
autoload :ForwardActivity, "constantcontact/components/tracking/forward_activity"
|
45
|
+
autoload :OpenActivity, "constantcontact/components/tracking/open_activity"
|
46
|
+
autoload :OptOutActivity, "constantcontact/components/tracking/opt_out_activity"
|
47
|
+
autoload :SendActivity, "constantcontact/components/tracking/send_activity"
|
48
|
+
autoload :TrackingActivity, "constantcontact/components/tracking/tracking_activity"
|
49
|
+
autoload :TrackingSummary, "constantcontact/components/tracking/tracking_summary"
|
50
|
+
autoload :VerifiedEmailAddress, "constantcontact/components/account/verified_email_address"
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
module Exceptions
|
54
|
+
autoload :CtctException, "constantcontact/exceptions/ctct_exception"
|
55
|
+
autoload :IllegalArgumentException, "constantcontact/exceptions/illegal_argument_exception"
|
56
|
+
autoload :OAuth2Exception, "constantcontact/exceptions/oauth2_exception"
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
59
|
+
module Services
|
60
|
+
autoload :BaseService, "constantcontact/services/base_service"
|
61
|
+
autoload :ActivityService, "constantcontact/services/activity_service"
|
62
|
+
autoload :CampaignScheduleService, "constantcontact/services/campaign_schedule_service"
|
63
|
+
autoload :CampaignTrackingService, "constantcontact/services/campaign_tracking_service"
|
64
|
+
autoload :ContactService, "constantcontact/services/contact_service"
|
65
|
+
autoload :ContactTrackingService, "constantcontact/services/contact_tracking_service"
|
66
|
+
autoload :EmailMarketingService, "constantcontact/services/email_marketing_service"
|
67
|
+
autoload :ListService, "constantcontact/services/list_service"
|
68
|
+
autoload :AccountService, "constantcontact/services/account_service"
|
69
|
+
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
module Util
|
72
|
+
autoload :Config, "constantcontact/util/config"
|
73
|
+
autoload :Helpers, "constantcontact/util/helpers"
|
74
|
+
end
|
75
75
|
end
|
data/lib/constantcontact/api.rb
CHANGED
@@ -6,12 +6,14 @@
|
|
6
6
|
|
7
7
|
module ConstantContact
|
8
8
|
class Api
|
9
|
-
|
10
9
|
# Class constructor
|
11
10
|
# @param [String] api_key - Constant Contact API Key
|
12
11
|
# @return
|
13
|
-
def initialize(api_key)
|
14
|
-
Services::BaseService.api_key = api_key
|
12
|
+
def initialize(api_key = nil)
|
13
|
+
Services::BaseService.api_key = api_key || Util::Config.get('auth.api_key')
|
14
|
+
if Services::BaseService.api_key.nil? || Services::BaseService.api_key == ''
|
15
|
+
raise ArgumentError.new("api_key required either explicitly or in configuration.")
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
|
@@ -16,10 +16,13 @@ module ConstantContact
|
|
16
16
|
# @option opts [String] :api_secret - the Constant Contact secret key
|
17
17
|
# @option opts [String] :redirect_url - the URL where Constact Contact is returning the authorization code
|
18
18
|
# @return
|
19
|
-
def initialize(opts)
|
20
|
-
@client_id = opts[:api_key]
|
21
|
-
@client_secret = opts[:api_secret]
|
22
|
-
@redirect_uri = opts[:redirect_url]
|
19
|
+
def initialize(opts = {})
|
20
|
+
@client_id = opts[:api_key] || Util::Config.get('auth.api_key')
|
21
|
+
@client_secret = opts[:api_secret] || Util::Config.get('auth.api_secret')
|
22
|
+
@redirect_uri = opts[:redirect_url] || Util::Config.get('auth.redirect_uri')
|
23
|
+
if @client_id.nil? || @client_id == '' || @client_secret.nil? || @client_secret.nil? || @redirect_uri.nil? || @redirect_uri == ''
|
24
|
+
raise ArgumentError.new "Either api_key, api_secret or redirect_uri is missing in explicit call or configuration."
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
28
|
|
@@ -5,65 +5,65 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Auth
|
9
|
+
class Session
|
10
|
+
attr_accessor :session
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# Create and initialize the session
|
13
|
+
def initialize
|
14
|
+
cgi = CGI.new('html4')
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
# We make sure to delete an old session if one exists,
|
17
|
+
# not just to free resources, but to prevent the session
|
18
|
+
# from being maliciously hijacked later on.
|
19
|
+
begin
|
20
|
+
@session = CGI::Session.new(cgi, 'database_manager' => CGI::Session::PStore, 'new_session' => false)
|
21
|
+
@session.delete
|
22
|
+
rescue ArgumentError # if no old session
|
23
|
+
end
|
24
|
+
@session = CGI::Session.new(cgi, 'database_manager' => CGI::Session::PStore, 'new_session' => true)
|
25
|
+
@session['datastore'] = {}
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
# Add a new user to the data store
|
29
|
+
# @param [String] username - Constant Contact username
|
30
|
+
# @param [Hash] params - additional parameters
|
31
|
+
# @return
|
32
|
+
def add_user(username, params)
|
33
|
+
@session['datastore'][username] = params
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
# Get an existing user from the data store
|
37
|
+
# @param [String] username - Constant Contact username key
|
38
|
+
# @return [String] The username value
|
39
|
+
def get_user(username)
|
40
|
+
@session['datastore'].has_key?(username) ? @session['datastore'][username] : false
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
# Update an existing user in the data store
|
44
|
+
# @param [String] username - Constant Contact username
|
45
|
+
# @param [Hash] params - additional parameters
|
46
|
+
# @return
|
47
|
+
def update_user(username, params)
|
48
|
+
if @session['datastore'].has_key?(username)
|
49
|
+
@session['datastore'][username] = params
|
50
|
+
end
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
# Delete an existing user from the data store
|
54
|
+
# @param [String] username - Constant Contact username
|
55
|
+
# @return
|
56
|
+
def delete_user(username)
|
57
|
+
@session['datastore'][username] = nil
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
# Close current session
|
61
|
+
# @return
|
62
|
+
def close
|
63
|
+
@session.close
|
64
|
+
end
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
end
|
67
|
+
end
|
68
68
|
end
|
69
69
|
|
@@ -5,23 +5,23 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Components
|
9
|
+
class VerifiedEmailAddress < Component
|
10
|
+
attr_accessor :status, :email_address
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
# Factory method to create a VerifiedEmailAddress object from a json string
|
13
|
+
# @param [Hash] props - array of properties to create object from
|
14
|
+
# @return [VerifiedEmailAddress]
|
15
|
+
def self.create(props)
|
16
|
+
email_address = VerifiedEmailAddress.new
|
17
|
+
if props
|
18
|
+
props.each do |key, value|
|
19
|
+
email_address.send("#{key}=", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
email_address
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
@@ -5,40 +5,40 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
module Components
|
9
|
+
class Activity < Component
|
10
|
+
attr_accessor :id, :type, :status, :start_date, :finish_date, :file_name, :created_date,
|
11
|
+
:error_count, :errors, :warnings, :contact_count
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
13
|
+
# Factory method to create an Activity object from a json string
|
14
|
+
# @param [Hash] props - hash of properties to create object from
|
15
|
+
# @return [Activity]
|
16
|
+
def self.create(props)
|
17
|
+
activity = Activity.new
|
18
|
+
if props
|
19
|
+
props.each do |key, value|
|
20
|
+
if key == 'errors'
|
21
|
+
if value
|
22
|
+
activity.errors = []
|
23
|
+
value.each do |error|
|
24
|
+
activity.errors << Components::ActivityError.create(error)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
elsif key == 'warnings'
|
28
|
+
if value
|
29
|
+
activity.warnings = []
|
30
|
+
value.each do |error|
|
31
|
+
activity.warnings << Components::ActivityError.create(error)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
else
|
35
|
+
activity.send("#{key}=", value)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
activity
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
@@ -5,23 +5,23 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Components
|
9
|
+
class ActivityError < Component
|
10
|
+
attr_accessor :message, :line_number, :email_address
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
# Factory method to create an ActivityError object from an array
|
13
|
+
# @param [Hash] props - hash of properties to create object from
|
14
|
+
# @return [ActivityError]
|
15
|
+
def self.create(props)
|
16
|
+
activity_error = ActivityError.new
|
17
|
+
if props
|
18
|
+
props.each do |key, value|
|
19
|
+
activity_error.send("#{key}=", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
activity_error
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|