constantcontact 1.0.1 → 1.0.2

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/constantcontact.gemspec +0 -1
  3. data/lib/constantcontact/components/account/verified_email_address.rb +14 -15
  4. data/lib/constantcontact/components/activities/activity.rb +30 -31
  5. data/lib/constantcontact/components/activities/activity_error.rb +14 -15
  6. data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -38
  7. data/lib/constantcontact/components/contacts/address.rb +12 -13
  8. data/lib/constantcontact/components/contacts/contact.rb +42 -42
  9. data/lib/constantcontact/components/contacts/contact_list.rb +11 -12
  10. data/lib/constantcontact/components/contacts/custom_field.rb +14 -15
  11. data/lib/constantcontact/components/contacts/email_address.rb +14 -15
  12. data/lib/constantcontact/components/contacts/note.rb +13 -12
  13. data/lib/constantcontact/components/email_marketing/campaign.rb +40 -40
  14. data/lib/constantcontact/components/email_marketing/click_through_details.rb +14 -15
  15. data/lib/constantcontact/components/email_marketing/message_footer.rb +14 -15
  16. data/lib/constantcontact/components/email_marketing/schedule.rb +15 -16
  17. data/lib/constantcontact/components/email_marketing/test_send.rb +21 -21
  18. data/lib/constantcontact/components/tracking/bounce_activity.rb +14 -15
  19. data/lib/constantcontact/components/tracking/click_activity.rb +14 -16
  20. data/lib/constantcontact/components/tracking/forward_activity.rb +14 -16
  21. data/lib/constantcontact/components/tracking/open_activity.rb +14 -16
  22. data/lib/constantcontact/components/tracking/send_activity.rb +14 -15
  23. data/lib/constantcontact/components/tracking/tracking_activity.rb +0 -1
  24. data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -18
  25. data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +14 -16
  26. data/lib/constantcontact/services/email_marketing_service.rb +10 -8
  27. data/lib/constantcontact/version.rb +1 -1
  28. data/spec/constantcontact/services/email_marketing_spec.rb +76 -0
  29. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f4035ebff0d2fa600a1671cf3aec57955f32e57
4
- data.tar.gz: c395ffc1e0e64498f04f49f1850b63ee7c798ecf
3
+ metadata.gz: fbe3bbdd27400b7cabb1f7d057ddcf4cbce8af1f
4
+ data.tar.gz: 5e590cbd2085adbbc074f66963f244d2b9ccf29d
5
5
  SHA512:
6
- metadata.gz: 2a6c7fb69db0876b55e1d26215d940520d0fd612dcd219bdebfb75bde753b9c32798127db1ac74012719c37068ca26fe03bdac9e8873ed8bfe44d232f0d2bd4c
7
- data.tar.gz: 8edaaebe146ff2b94f22604a97704fdbcad79041e0460ba79cc6995aa6f34eda229b41a8233ba080c1824dcf9c4ac722f35e50b614e11d5935debb9bc12a5bc6
6
+ metadata.gz: 90c879d3fe95da598a0f2f4b9df5e6e8066e21a919a9fdfa029bff1e0fc9beaed0ffaade52e7a000a55a57285caf4d741a1d0209d5d9adb425f724cee3e99d3c
7
+ data.tar.gz: aa192ef3d3440c8f4bff332df802b63b290af8eedd21847d522243a5c779e3e3e6735e27f5cb36b5f8490c084535d3f3e0092f57ec6ecdb53a385d00d9205b50
@@ -13,7 +13,6 @@ 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"
17
16
  s.license = "MIT"
18
17
 
19
18
  s.files = [
@@ -9,19 +9,18 @@ module ConstantContact
9
9
  class VerifiedEmailAddress < Component
10
10
  attr_accessor :status, :email_address
11
11
 
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
-
25
- end
26
- end
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
+ obj = VerifiedEmailAddress.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
24
+ end
25
+ end
27
26
  end
@@ -10,35 +10,34 @@ module ConstantContact
10
10
  attr_accessor :id, :type, :status, :start_date, :finish_date, :file_name, :created_date,
11
11
  :error_count, :errors, :warnings, :contact_count
12
12
 
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
-
42
- end
43
- end
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
+ obj = Activity.new
18
+ if props
19
+ props.each do |key, value|
20
+ if key == 'errors'
21
+ if value
22
+ obj.errors = []
23
+ value.each do |error|
24
+ obj.errors << Components::ActivityError.create(error)
25
+ end
26
+ end
27
+ elsif key == 'warnings'
28
+ if value
29
+ obj.warnings = []
30
+ value.each do |error|
31
+ obj.warnings << Components::ActivityError.create(error)
32
+ end
33
+ end
34
+ else
35
+ obj.send("#{key}=", value) if obj.respond_to? key
36
+ end
37
+ end
38
+ end
39
+ obj
40
+ end
41
+ end
42
+ end
44
43
  end
@@ -9,19 +9,18 @@ module ConstantContact
9
9
  class ActivityError < Component
10
10
  attr_accessor :message, :line_number, :email_address
11
11
 
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
-
25
- end
26
- end
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
+ obj = ActivityError.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
24
+ end
25
+ end
27
26
  end
@@ -5,41 +5,40 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class AddContactsImportData < Component
10
- attr_accessor :first_name, :middle_name, :last_name, :job_title, :company_name,
11
- :work_phone, :home_phone, :email_addresses, :addresses, :custom_fields
12
-
13
-
14
- # Constructor to create an AddContactsImportData object from the given hash
15
- # @param [Hash] props - the hash with properties
16
- # @return [AddContactsImportData]
17
- def initialize(props = {})
18
- instance_variables.each do |property, value|
19
- send("#{property}=", get_value(props, property))
20
- end
21
- end
22
-
23
- # Setter
24
- def add_custom_field(custom_field)
25
- @custom_fields = [] if @custom_fields.nil?
26
- @custom_fields << custom_field
27
- end
28
-
29
-
30
- # Setter
31
- def add_address(address)
32
- @addresses = [] if @addresses.nil?
33
- @addresses << address
34
- end
35
-
36
-
37
- # Setter
38
- def add_email(email_address)
39
- @email_addresses = [] if @email_addresses.nil?
40
- @email_addresses << email_address
41
- end
42
-
43
- end
44
- end
45
- end
8
+ module Components
9
+ class AddContactsImportData < Component
10
+ attr_accessor :first_name, :middle_name, :last_name, :job_title, :company_name,
11
+ :work_phone, :home_phone, :email_addresses, :addresses, :custom_fields
12
+
13
+
14
+ # Constructor to create an AddContactsImportData object from the given hash
15
+ # @param [Hash] props - the hash with properties
16
+ # @return [AddContactsImportData]
17
+ def initialize(props = {})
18
+ instance_variables.each do |property, value|
19
+ send("#{property}=", get_value(props, property)) if obj.respond_to? property
20
+ end
21
+ end
22
+
23
+ # Setter
24
+ def add_custom_field(custom_field)
25
+ @custom_fields = [] if @custom_fields.nil?
26
+ @custom_fields << custom_field
27
+ end
28
+
29
+
30
+ # Setter
31
+ def add_address(address)
32
+ @addresses = [] if @addresses.nil?
33
+ @addresses << address
34
+ end
35
+
36
+
37
+ # Setter
38
+ def add_email(email_address)
39
+ @email_addresses = [] if @email_addresses.nil?
40
+ @email_addresses << email_address
41
+ end
42
+ end
43
+ end
44
+ end
@@ -10,19 +10,18 @@ module ConstantContact
10
10
  attr_accessor :id, :line1, :line2, :line3, :city, :address_type, :state_code,
11
11
  :country_code, :postal_code, :sub_postal_code
12
12
 
13
- # Factory method to create an Address object from a json string
14
- # @param [Hash] props - array of properties to create object from
15
- # @return [Address]
16
- def self.create(props)
17
- address = Address.new
18
- if props
19
- props.each do |key, value|
20
- address.send("#{key}=", value)
21
- end
22
- end
23
- address
24
- end
25
-
13
+ # Factory method to create an Address object from a json string
14
+ # @param [Hash] props - array of properties to create object from
15
+ # @return [Address]
16
+ def self.create(props)
17
+ obj = Address.new
18
+ if props
19
+ props.each do |key, value|
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
+ end
22
+ end
23
+ obj
24
+ end
26
25
  end
27
26
  end
28
27
  end
@@ -15,48 +15,48 @@ module ConstantContact
15
15
  :created_date, :notes, :source
16
16
 
17
17
 
18
- # Factory method to create a Contact object from a json string
19
- # @param [Hash] props - JSON string representing a contact
20
- # @return [Contact]
21
- def self.create(props)
22
- contact = Contact.new
23
- if props
24
- props.each do |key, value|
25
- if key == 'email_addresses'
26
- if value
27
- contact.email_addresses = []
28
- value.each do |email_address|
29
- contact.email_addresses << Components::EmailAddress.create(email_address)
30
- end
31
- end
32
- elsif key == 'addresses'
33
- if value
34
- contact.addresses = []
35
- value.each do |address|
36
- contact.addresses << Components::Address.create(address)
37
- end
38
- end
39
- elsif key == 'custom_fields'
40
- if value
41
- contact.custom_fields = []
42
- value.each do |custom_field|
43
- contact.custom_fields << Components::CustomField.create(custom_field)
44
- end
45
- end
46
- elsif key == 'lists'
47
- if value
48
- contact.lists = []
49
- value.each do |contact_list|
50
- contact.lists << Components::ContactList.create(contact_list)
51
- end
52
- end
53
- else
54
- contact.send("#{key}=", value)
55
- end
56
- end
57
- end
58
- contact
59
- end
18
+ # Factory method to create a Contact object from a json string
19
+ # @param [Hash] props - JSON string representing a contact
20
+ # @return [Contact]
21
+ def self.create(props)
22
+ obj = Contact.new
23
+ if props
24
+ props.each do |key, value|
25
+ if key == 'email_addresses'
26
+ if value
27
+ obj.email_addresses = []
28
+ value.each do |email_address|
29
+ obj.email_addresses << Components::EmailAddress.create(email_address)
30
+ end
31
+ end
32
+ elsif key == 'addresses'
33
+ if value
34
+ obj.addresses = []
35
+ value.each do |address|
36
+ obj.addresses << Components::Address.create(address)
37
+ end
38
+ end
39
+ elsif key == 'custom_fields'
40
+ if value
41
+ obj.custom_fields = []
42
+ value.each do |custom_field|
43
+ obj.custom_fields << Components::CustomField.create(custom_field)
44
+ end
45
+ end
46
+ elsif key == 'lists'
47
+ if value
48
+ obj.lists = []
49
+ value.each do |contact_list|
50
+ obj.lists << Components::ContactList.create(contact_list)
51
+ end
52
+ end
53
+ else
54
+ obj.send("#{key}=", value) if obj.respond_to? key
55
+ end
56
+ end
57
+ end
58
+ obj
59
+ end
60
60
 
61
61
  # Setter
62
62
  # @param [ContactList] contact_list
@@ -10,18 +10,17 @@ module ConstantContact
10
10
  attr_accessor :id, :name, :status, :created_date, :modified_date, :contact_count
11
11
 
12
12
  # Factory method to create a ContactList object from a json string
13
- # @param [Hash] props - array of properties to create object from
14
- # @return [ContactList]
15
- def self.create(props)
16
- contact_list = ContactList.new
17
- if props
18
- props.each do |key, value|
19
- contact_list.send("#{key}=", value)
20
- end
21
- end
22
- contact_list
23
- end
24
-
13
+ # @param [Hash] props - array of properties to create object from
14
+ # @return [ContactList]
15
+ def self.create(props)
16
+ obj = ContactList.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
25
24
  end
26
25
  end
27
26
  end
@@ -9,19 +9,18 @@ module ConstantContact
9
9
  class CustomField < Component
10
10
  attr_accessor :name, :value
11
11
 
12
- # Factory method to create a CustomField object from a json string
13
- # @param [Hash] props - array of properties to create object from
14
- # @return [CustomField]
15
- def self.create(props)
16
- custom_field = CustomField.new
17
- if props
18
- props.each do |key, value|
19
- custom_field.send("#{key}=", value)
20
- end
21
- end
22
- custom_field
23
- end
24
-
25
- end
26
- end
12
+ # Factory method to create a CustomField object from a json string
13
+ # @param [Hash] props - array of properties to create object from
14
+ # @return [CustomField]
15
+ def self.create(props)
16
+ obj = CustomField.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
24
+ end
25
+ end
27
26
  end
@@ -16,19 +16,18 @@ module ConstantContact
16
16
  @email_address = email_address if email_address
17
17
  end
18
18
 
19
- # Factory method to create an EmailAddress object from a json string
20
- # @param [Hash] props - array of properties to create object from
21
- # @return [EmailAddress]
22
- def self.create(props)
23
- email_address = EmailAddress.new
24
- if props
25
- props.each do |key, value|
26
- email_address.send("#{key}=", value)
27
- end
28
- end
29
- email_address
30
- end
31
-
32
- end
33
- end
19
+ # Factory method to create an EmailAddress object from a json string
20
+ # @param [Hash] props - array of properties to create object from
21
+ # @return [EmailAddress]
22
+ def self.create(props)
23
+ obj = EmailAddress.new
24
+ if props
25
+ props.each do |key, value|
26
+ obj.send("#{key}=", value) if obj.respond_to? key
27
+ end
28
+ end
29
+ obj
30
+ end
31
+ end
32
+ end
34
33
  end
@@ -9,17 +9,18 @@ module ConstantContact
9
9
  class Note < Component
10
10
  attr_accessor :id, :note, :created_date
11
11
 
12
- # Factory method to create a Note object from a json string
13
- # @param props - JSON string representing a contact
14
- # @return Note
15
- def self.create(props)
16
- note = Note.new
17
- if props
18
- props.each do |key, value|
19
- note.send("#{key}=", value)
20
- end
21
- end
22
- note
12
+ # Factory method to create a Note object from a json string
13
+ # @param [String] props - JSON string representing a contact
14
+ # @return Note
15
+ def self.create(props)
16
+ note = Note.new
17
+ if props
18
+ props.each do |key, value|
19
+ note.send("#{key}=", value)
20
+ end
21
+ end
22
+ note
23
+ end
23
24
  end
24
- end
25
+ end
25
26
  end
@@ -5,49 +5,49 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class Campaign < Component
10
- attr_accessor :id, :name, :subject, :status, :from_name, :from_email, :reply_to_email, :template_type,
11
- :created_date, :modified_date, :last_run_date, :next_run_date,
12
- :is_permission_reminder_enabled, :permission_reminder_text,
13
- :is_view_as_webpage_enabled, :view_as_web_page_text, :view_as_web_page_link_text,
14
- :greeting_salutations, :greeting_name, :greeting_string, :email_content, :text_content,
15
- :message_footer, :tracking_summary, :email_content_format, :style_sheet, :sent_to_contact_lists,
16
- :click_through_details, :include_forward_email, :is_visible_in_ui
8
+ module Components
9
+ class Campaign < Component
10
+ attr_accessor :id, :name, :subject, :status, :from_name, :from_email, :reply_to_email, :template_type,
11
+ :created_date, :modified_date, :last_run_date, :next_run_date,
12
+ :is_permission_reminder_enabled, :permission_reminder_text,
13
+ :is_view_as_webpage_enabled, :view_as_web_page_text, :view_as_web_page_link_text,
14
+ :greeting_salutations, :greeting_name, :greeting_string, :email_content, :text_content,
15
+ :message_footer, :tracking_summary, :email_content_format, :style_sheet, :sent_to_contact_lists,
16
+ :click_through_details, :include_forward_email, :is_visible_in_ui, :permalink_url
17
17
 
18
18
 
19
- # Factory method to create an EmailCampaign object from an array
20
- # @param [Hash] props - hash of properties to create object from
21
- # @return [Campaign]
22
- def self.create(props)
23
- campaign = Campaign.new
24
- if props
25
- props.each do |key, value|
26
- if key == 'message_footer'
27
- campaign.message_footer = Components::MessageFooter.create(value)
28
- elsif key == 'tracking_summary'
29
- campaign.tracking_summary = Components::TrackingSummary.create(value)
30
- elsif key == 'sent_to_contact_lists'
31
- if value
32
- campaign.sent_to_contact_lists = []
33
- value.each do |sent_to_contact_list|
34
- campaign.sent_to_contact_lists << Components::ContactList.create(sent_to_contact_list)
35
- end
36
- end
37
- elsif key == 'click_through_details'
38
- if value
39
- campaign.click_through_details = []
40
- value.each do |click_through_details|
41
- campaign.click_through_details << Components::ClickThroughDetails.create(click_through_details)
42
- end
43
- end
19
+ # Factory method to create an EmailCampaign object from an array
20
+ # @param [Hash] props - hash of properties to create object from
21
+ # @return [Campaign]
22
+ def self.create(props)
23
+ campaign = Campaign.new
24
+ if props
25
+ props.each do |key, value|
26
+ if key == 'message_footer'
27
+ campaign.message_footer = Components::MessageFooter.create(value)
28
+ elsif key == 'tracking_summary'
29
+ campaign.tracking_summary = Components::TrackingSummary.create(value)
30
+ elsif key == 'sent_to_contact_lists'
31
+ if value
32
+ campaign.sent_to_contact_lists = []
33
+ value.each do |sent_to_contact_list|
34
+ campaign.sent_to_contact_lists << Components::ContactList.create(sent_to_contact_list)
35
+ end
36
+ end
37
+ elsif key == 'click_through_details'
38
+ if value
39
+ campaign.click_through_details = []
40
+ value.each do |click_through_details|
41
+ campaign.click_through_details << Components::ClickThroughDetails.create(click_through_details)
42
+ end
43
+ end
44
44
  else
45
- campaign.send("#{key}=", value)
46
- end
47
- end
48
- end
49
- campaign
50
- end
45
+ campaign.send("#{key}=", value) if campaign.respond_to? key
46
+ end
47
+ end
48
+ end
49
+ campaign
50
+ end
51
51
 
52
52
 
53
53
  # Factory method to create a Campaign object from an array
@@ -10,19 +10,18 @@ module ConstantContact
10
10
  attr_accessor :url, :url_uid, :click_count
11
11
 
12
12
 
13
- # Factory method to create an ClickThroughDetails object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [ClickThroughDetails]
16
- def self.create(props)
17
- click_through_details = ClickThroughDetails.new
18
- if props
19
- props.each do |key, value|
20
- click_through_details.send("#{key}=", value)
21
- end
22
- end
23
- click_through_details
24
- end
25
-
26
- end
27
- end
13
+ # Factory method to create an ClickThroughDetails object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [ClickThroughDetails]
16
+ def self.create(props)
17
+ obj = ClickThroughDetails.new
18
+ if props
19
+ props.each do |key, value|
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
+ end
22
+ end
23
+ obj
24
+ end
25
+ end
26
+ end
28
27
  end
@@ -12,19 +12,18 @@ module ConstantContact
12
12
  :postal_code, :include_forward_email, :forward_email_link_text,
13
13
  :include_subscribe_link, :subscribe_link_text
14
14
 
15
- # Factory method to create a MessageFooter object from an array
16
- # @param [Hash] props - hash of properties to create object from
17
- # @return [MessageFooter]
18
- def self.create(props)
19
- message_footer = MessageFooter.new
20
- if props
21
- props.each do |key, value|
22
- message_footer.send("#{key}=", value)
23
- end
24
- end
25
- message_footer
26
- end
27
-
28
- end
29
- end
15
+ # Factory method to create a MessageFooter object from an array
16
+ # @param [Hash] props - hash of properties to create object from
17
+ # @return [MessageFooter]
18
+ def self.create(props)
19
+ obj = MessageFooter.new
20
+ if props
21
+ props.each do |key, value|
22
+ obj.send("#{key}=", value) if obj.respond_to? key
23
+ end
24
+ end
25
+ obj
26
+ end
27
+ end
28
+ end
30
29
  end
@@ -10,20 +10,19 @@ module ConstantContact
10
10
  attr_accessor :id, :scheduled_date
11
11
 
12
12
 
13
- # Factory method to create a Schedule object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [Schedule]
16
- def self.create(props)
17
- schedule = Schedule.new
18
- if props
19
- props = props.first if props.is_a?(Array)
20
- props.each do |key, value|
21
- schedule.send("#{key}=", value)
22
- end
23
- end
24
- schedule
25
- end
26
-
27
- end
28
- end
13
+ # Factory method to create a Schedule object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Schedule]
16
+ def self.create(props)
17
+ obj = Schedule.new
18
+ if props
19
+ props = props.first if props.is_a?(Array)
20
+ props.each do |key, value|
21
+ obj.send("#{key}=", value) if obj.respond_to? key
22
+ end
23
+ end
24
+ obj
25
+ end
26
+ end
27
+ end
29
28
  end
@@ -10,27 +10,27 @@ module ConstantContact
10
10
  attr_accessor :format, :personal_message, :email_addresses
11
11
 
12
12
 
13
- # Factory method to create a TestSend object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [TestSend]
16
- def self.create(props)
17
- test_send = TestSend.new
18
- if props
19
- props.each do |key, value|
20
- if key == 'email_addresses'
21
- if value
22
- test_send.email_addresses = []
23
- value.each do |email_address|
24
- test_send.email_addresses << email_address
25
- end
26
- end
27
- else
28
- test_send.send("#{key}=", value)
29
- end
30
- end
31
- end
32
- test_send
33
- end
13
+ # Factory method to create a TestSend object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [TestSend]
16
+ def self.create(props)
17
+ obj = TestSend.new
18
+ if props
19
+ props.each do |key, value|
20
+ if key == 'email_addresses'
21
+ if value
22
+ obj.email_addresses = []
23
+ value.each do |email_address|
24
+ obj.email_addresses << email_address
25
+ end
26
+ end
27
+ else
28
+ obj.send("#{key}=", value) if obj.respond_to? key
29
+ end
30
+ end
31
+ end
32
+ obj
33
+ end
34
34
 
35
35
 
36
36
  # Add an email address to the set of addresses to send the test send too
@@ -11,19 +11,18 @@ module ConstantContact
11
11
  :contact_id, :email_address, :campaign_id
12
12
 
13
13
 
14
- # Factory method to create a BounceActivity object from an array
15
- # @param [Hash] props - hash of properties to create object from
16
- # @return [BounceActivity]
17
- def self.create(props)
18
- bounce_activity = BounceActivity.new
19
- if props
20
- props.each do |key, value|
21
- bounce_activity.send("#{key}=", value)
22
- end
23
- end
24
- bounce_activity
25
- end
26
-
27
- end
28
- end
14
+ # Factory method to create a BounceActivity object from an array
15
+ # @param [Hash] props - hash of properties to create object from
16
+ # @return [BounceActivity]
17
+ def self.create(props)
18
+ obj = BounceActivity.new
19
+ if props
20
+ props.each do |key, value|
21
+ obj.send("#{key}=", value) if obj.respond_to? key
22
+ end
23
+ end
24
+ obj
25
+ end
26
+ end
27
+ end
29
28
  end
@@ -9,20 +9,18 @@ module ConstantContact
9
9
  class ClickActivity < Component
10
10
  attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :link_id, :click_date
11
11
 
12
-
13
- # Factory method to create a ClickActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [ClickActivity]
16
- def self.create(props)
17
- click_activity = ClickActivity.new
18
- if props
19
- props.each do |key, value|
20
- click_activity.send("#{key}=", value)
21
- end
22
- end
23
- click_activity
24
- end
25
-
26
- end
27
- end
12
+ \ # Factory method to create a ClickActivity object from an array
13
+ # @param [Hash] props - hash of properties to create object from
14
+ # @return [ClickActivity]
15
+ def self.create(props)
16
+ obj = ClickActivity.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
24
+ end
25
+ end
28
26
  end
@@ -9,20 +9,18 @@ module ConstantContact
9
9
  class ForwardActivity < Component
10
10
  attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :forward_date
11
11
 
12
-
13
- # Factory method to create a ForwardActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [ForwardActivity]
16
- def self.create(props)
17
- forward_activity = ForwardActivity.new
18
- if props
19
- props.each do |key, value|
20
- forward_activity.send("#{key}=", value)
21
- end
22
- end
23
- forward_activity
24
- end
25
-
26
- end
27
- end
12
+ # Factory method to create a ForwardActivity object from an array
13
+ # @param [Hash] props - hash of properties to create object from
14
+ # @return [ForwardActivity]
15
+ def self.create(props)
16
+ obj = ForwardActivity.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
24
+ end
25
+ end
28
26
  end
@@ -9,20 +9,18 @@ module ConstantContact
9
9
  class OpenActivity < Component
10
10
  attr_accessor :activity_type, :campaign_id, :email_address, :open_date, :contact_id
11
11
 
12
-
13
- # Factory method to create an OpenActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [OpenActivity]
16
- def self.create(props)
17
- open_activity = OpenActivity.new
18
- if props
19
- props.each do |key, value|
20
- open_activity.send("#{key}=", value)
21
- end
22
- end
23
- open_activity
24
- end
25
-
26
- end
27
- end
12
+ # Factory method to create an OpenActivity object from an array
13
+ # @param [Hash] props - hash of properties to create object from
14
+ # @return [OpenActivity]
15
+ def self.create(props)
16
+ obj = OpenActivity.new
17
+ if props
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ end
22
+ obj
23
+ end
24
+ end
25
+ end
28
26
  end
@@ -10,19 +10,18 @@ module ConstantContact
10
10
  attr_accessor :activity_type, :campaign_id, :email_address, :contact_id, :send_date
11
11
 
12
12
 
13
- # Factory method to create a SendActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [SendActivity]
16
- def self.create(props)
17
- send_activity = SendActivity.new
18
- if props
19
- props.each do |key, value|
20
- send_activity.send("#{key}=", value)
21
- end
22
- end
23
- send_activity
24
- end
25
-
26
- end
27
- end
13
+ # Factory method to create a SendActivity object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [SendActivity]
16
+ def self.create(props)
17
+ obj = SendActivity.new
18
+ if props
19
+ props.each do |key, value|
20
+ obj.send("#{key}=", value)
21
+ end
22
+ end
23
+ obj
24
+ end
25
+ end
26
+ end
28
27
  end
@@ -21,7 +21,6 @@ module ConstantContact
21
21
  @next = pagination['next'][pagination['next'].index('&next=') + 6, pagination['next'].length]
22
22
  end
23
23
  end
24
-
25
24
  end
26
25
  end
27
26
  end
@@ -5,24 +5,23 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class TrackingSummary < Component
10
- attr_accessor :sends, :opens, :clicks, :forwards, :unsubscribes, :bounces, :contact_id
8
+ module Components
9
+ class TrackingSummary < Component
10
+ attr_accessor :sends, :opens, :clicks, :forwards, :unsubscribes, :bounces, :contact_id, :spam_count
11
11
 
12
12
 
13
- # Factory method to create a TrackingSummary object from an array
14
- # @param [Hash] props - array of properties to create object from
15
- # @return [TrackingSummary]
16
- def self.create(props)
17
- tracking_summary = TrackingSummary.new
18
- if props
19
- props.each do |key, value|
20
- tracking_summary.send("#{key}=", value)
21
- end
22
- end
23
- tracking_summary
24
- end
25
-
26
- end
27
- end
13
+ # Factory method to create a TrackingSummary object from an array
14
+ # @param [Hash] props - array of properties to create object from
15
+ # @return [TrackingSummary]
16
+ def self.create(props)
17
+ obj = TrackingSummary.new
18
+ if props
19
+ props.each do |key, value|
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
+ end
22
+ end
23
+ obj
24
+ end
25
+ end
26
+ end
28
27
  end
@@ -10,20 +10,18 @@ module ConstantContact
10
10
  attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :unsubscribe_date,
11
11
  :unsubscribe_source, :unsubscribe_reason
12
12
 
13
-
14
- # Factory method to create an UnsubscribeActivity object from an array
15
- # @param [Hash] props - hash of properties to create object from
16
- # @return [UnsubscribeActivity]
17
- def self.create(props)
18
- unsubscribe_activity = UnsubscribeActivity.new
19
- if props
20
- props.each do |key, value|
21
- unsubscribe_activity.send("#{key}=", value)
22
- end
23
- end
24
- unsubscribe_activity
25
- end
26
-
27
- end
28
- end
13
+ # Factory method to create an UnsubscribeActivity object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [UnsubscribeActivity]
16
+ def self.create(props)
17
+ obj = UnsubscribeActivity.new
18
+ if props
19
+ props.each do |key, value|
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
+ end
22
+ end
23
+ obj
24
+ end
25
+ end
26
+ end
29
27
  end
@@ -21,14 +21,16 @@ module ConstantContact
21
21
  Components::Campaign.create(JSON.parse(response.body))
22
22
  end
23
23
 
24
-
25
- # Get a set of campaigns
26
- # @param [String] access_token - Constant Contact OAuth2 access token
27
- # @param [Hash] param - query parameters to be appended to the request
28
- # @return [ResultSet<Campaign>]
29
- def get_campaigns(access_token, param = nil)
30
- url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
31
- url = build_url(url, param)
24
+ # Get a set of campaigns
25
+ # @param [String] access_token Constant Contact OAuth2 access token
26
+ # @param [Hash] opts query parameters to be appended to the request
27
+ # @option opts [String] status email campaigns status of DRAFT, RUNNING, SENT, SCHEDULED.
28
+ # @option opts [String] modified_since ISO-8601 date string to return campaigns modified since then.
29
+ # @option opts [Integer] limit number of campaigns to return, 1 to 50.
30
+ # @return [ResultSet<Campaign>]
31
+ def get_campaigns(access_token, opts = {})
32
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
33
+ url = build_url(url, opts)
32
34
 
33
35
  response = RestClient.get(url, get_headers(access_token))
34
36
  body = JSON.parse(response.body)
@@ -7,6 +7,6 @@
7
7
  module ConstantContact
8
8
  module SDK
9
9
  # Gem version
10
- VERSION = "1.0.1"
10
+ VERSION = "1.0.2"
11
11
  end
12
12
  end
@@ -0,0 +1,76 @@
1
+ #
2
+ # email_marketing_service_spec.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ require 'spec_helper'
8
+
9
+ describe ConstantContact::Services::EmailMarketingService do
10
+ describe "#get_campaigns" do
11
+ it "returns an array of campaigns" do
12
+ json = load_json('campaigns.json')
13
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
14
+
15
+ response = RestClient::Response.create(json, net_http_resp, {})
16
+ RestClient.stub(:get).and_return(response)
17
+ campaigns = ConstantContact::Services::EmailMarketingService.get_campaigns('token')
18
+ campaign = campaigns.results[0]
19
+
20
+ campaigns.should be_kind_of(ConstantContact::Components::ResultSet)
21
+ campaign.should be_kind_of(ConstantContact::Components::Campaign)
22
+ end
23
+ end
24
+
25
+ describe "#get_campaign" do
26
+ it "returns a campaign" do
27
+ json = load_json('campaign.json')
28
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
29
+
30
+ response = RestClient::Response.create(json, net_http_resp, {})
31
+ RestClient.stub(:get).and_return(response)
32
+ campaign = ConstantContact::Services::EmailMarketingService.get_campaign('token', 1)
33
+
34
+ campaign.should be_kind_of(ConstantContact::Components::Campaign)
35
+ end
36
+ end
37
+
38
+ describe "#add_campaign" do
39
+ it "adds a campaign" do
40
+ json = load_json('campaign.json')
41
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
42
+
43
+ response = RestClient::Response.create(json, net_http_resp, {})
44
+ RestClient.stub(:post).and_return(response)
45
+ campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
46
+ added = ConstantContact::Services::EmailMarketingService.add_campaign('token', campaign)
47
+
48
+ added.should respond_to(:id)
49
+ added.id.should_not be_empty
50
+ end
51
+ end
52
+
53
+ describe "#delete_campaign" do
54
+ it "deletes a campgin" do
55
+ json = load_json('campaign.json')
56
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
57
+
58
+ response = RestClient::Response.create('', net_http_resp, {})
59
+ RestClient.stub(:delete).and_return(response)
60
+ campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
61
+ ConstantContact::Services::EmailMarketingService.delete_campaign('token', campaign).should be_true
62
+ end
63
+ end
64
+
65
+ describe "#update_campaign" do
66
+ it "updates a campaign" do
67
+ json = load_json('campaign.json')
68
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
69
+
70
+ response = RestClient::Response.create(json, net_http_resp, {})
71
+ RestClient.stub(:put).and_return(response)
72
+ campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
73
+ added = ConstantContact::Services::EmailMarketingService.update_campaign('token', campaign)
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constantcontact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ConstantContact
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-29 00:00:00.000000000 Z
11
+ date: 2013-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -115,6 +115,7 @@ files:
115
115
  - spec/constantcontact/components/contacts/custom_field_spec.rb
116
116
  - spec/constantcontact/components/contacts/email_address_spec.rb
117
117
  - spec/constantcontact/services/contact_service_spec.rb
118
+ - spec/constantcontact/services/email_marketing_spec.rb
118
119
  - spec/constantcontact/services/list_service_spec.rb
119
120
  - spec/spec_helper.rb
120
121
  homepage: http://www.constantcontact.com