constantcontact 1.0.2 → 1.1.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +127 -136
  3. data/constantcontact.gemspec +4 -3
  4. data/lib/constantcontact.rb +63 -44
  5. data/lib/constantcontact/api.rb +932 -535
  6. data/lib/constantcontact/auth/oauth2.rb +86 -66
  7. data/lib/constantcontact/components/account/verified_email_address.rb +14 -14
  8. data/lib/constantcontact/components/activities/activity.rb +30 -30
  9. data/lib/constantcontact/components/activities/activity_error.rb +14 -14
  10. data/lib/constantcontact/components/activities/add_contacts.rb +1 -1
  11. data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -36
  12. data/lib/constantcontact/components/component.rb +25 -0
  13. data/lib/constantcontact/components/contacts/address.rb +12 -12
  14. data/lib/constantcontact/components/contacts/contact.rb +50 -44
  15. data/lib/constantcontact/components/contacts/contact_list.rb +12 -12
  16. data/lib/constantcontact/components/contacts/custom_field.rb +14 -14
  17. data/lib/constantcontact/components/contacts/email_address.rb +14 -14
  18. data/lib/constantcontact/components/contacts/note.rb +13 -13
  19. data/lib/constantcontact/components/email_marketing/campaign.rb +41 -41
  20. data/lib/constantcontact/components/email_marketing/click_through_details.rb +14 -14
  21. data/lib/constantcontact/components/email_marketing/message_footer.rb +14 -14
  22. data/lib/constantcontact/components/email_marketing/schedule.rb +14 -15
  23. data/lib/constantcontact/components/email_marketing/test_send.rb +21 -21
  24. data/lib/constantcontact/components/event_spot/contact.rb +27 -0
  25. data/lib/constantcontact/components/event_spot/event.rb +63 -0
  26. data/lib/constantcontact/components/event_spot/event_track.rb +28 -0
  27. data/lib/constantcontact/components/event_spot/fee.rb +27 -0
  28. data/lib/constantcontact/components/event_spot/guest.rb +31 -0
  29. data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
  30. data/lib/constantcontact/components/event_spot/promo_code.rb +26 -0
  31. data/lib/constantcontact/components/event_spot/registrant.rb +54 -0
  32. data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
  33. data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
  34. data/lib/constantcontact/components/event_spot/sale_item.rb +27 -0
  35. data/lib/constantcontact/components/library/file/library_file.rb +27 -0
  36. data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
  37. data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
  38. data/lib/constantcontact/components/library/info/move_results.rb +26 -0
  39. data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
  40. data/lib/constantcontact/components/tracking/bounce_activity.rb +14 -14
  41. data/lib/constantcontact/components/tracking/click_activity.rb +14 -14
  42. data/lib/constantcontact/components/tracking/forward_activity.rb +14 -14
  43. data/lib/constantcontact/components/tracking/open_activity.rb +14 -14
  44. data/lib/constantcontact/components/tracking/send_activity.rb +14 -14
  45. data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
  46. data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +14 -14
  47. data/lib/constantcontact/services/account_service.rb +4 -3
  48. data/lib/constantcontact/services/activity_service.rb +40 -3
  49. data/lib/constantcontact/services/base_service.rb +34 -6
  50. data/lib/constantcontact/services/campaign_tracking_service.rb +20 -20
  51. data/lib/constantcontact/services/contact_service.rb +10 -12
  52. data/lib/constantcontact/services/contact_tracking_service.rb +20 -20
  53. data/lib/constantcontact/services/email_marketing_service.rb +8 -10
  54. data/lib/constantcontact/services/event_spot_service.rb +254 -0
  55. data/lib/constantcontact/services/library_service.rb +297 -0
  56. data/lib/constantcontact/services/list_service.rb +6 -5
  57. data/lib/constantcontact/util/config.rb +135 -117
  58. data/lib/constantcontact/version.rb +1 -1
  59. data/spec/constantcontact/api_spec.rb +1223 -173
  60. data/spec/constantcontact/auth/oauth2_spec.rb +60 -47
  61. data/spec/constantcontact/components/contacts/address_spec.rb +1 -1
  62. data/spec/constantcontact/components/contacts/contact_list_spec.rb +1 -1
  63. data/spec/constantcontact/components/contacts/contact_spec.rb +1 -1
  64. data/spec/constantcontact/components/contacts/email_address_spec.rb +1 -1
  65. data/spec/constantcontact/services/activity_service_spec.rb +201 -0
  66. data/spec/constantcontact/services/base_service_spec.rb +27 -0
  67. data/spec/constantcontact/services/campaign_schedule_service_spec.rb +111 -0
  68. data/spec/constantcontact/services/campaign_tracking_service_spec.rb +127 -0
  69. data/spec/constantcontact/services/contact_service_spec.rb +24 -22
  70. data/spec/constantcontact/services/contact_tracking_service_spec.rb +127 -0
  71. data/spec/constantcontact/services/email_marketing_spec.rb +72 -66
  72. data/spec/constantcontact/services/event_spot_spec.rb +217 -0
  73. data/spec/constantcontact/services/library_service_spec.rb +248 -0
  74. data/spec/constantcontact/services/list_service_spec.rb +33 -17
  75. data/spec/spec_helper.rb +3 -1
  76. metadata +63 -7
@@ -11,52 +11,58 @@ module ConstantContact
11
11
  attr_accessor :id, :status, :first_name, :middle_name, :last_name, :confirmed, :email_addresses,
12
12
  :prefix_name, :job_title, :addresses, :company_name, :home_phone,
13
13
  :work_phone, :cell_phone, :fax, :custom_fields, :lists,
14
- :source_details, :source_is_url, :web_url, :modified_date,
15
- :created_date, :notes, :source
14
+ :source_details, :notes, :source
16
15
 
17
16
 
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
17
+ # Factory method to create a Contact object from a json string
18
+ # @param [Hash] props - properties to create object from
19
+ # @return [Contact]
20
+ def self.create(props)
21
+ obj = Contact.new
22
+ if props
23
+ props.each do |key, value|
24
+ if key == 'email_addresses'
25
+ if value
26
+ obj.email_addresses = []
27
+ value.each do |email_address|
28
+ obj.email_addresses << Components::EmailAddress.create(email_address)
29
+ end
30
+ end
31
+ elsif key == 'addresses'
32
+ if value
33
+ obj.addresses = []
34
+ value.each do |address|
35
+ obj.addresses << Components::Address.create(address)
36
+ end
37
+ end
38
+ elsif key == 'notes'
39
+ if value
40
+ obj.notes = []
41
+ value.each do |note|
42
+ obj.notes << Components::Note.create(note)
43
+ end
44
+ end
45
+ elsif key == 'custom_fields'
46
+ if value
47
+ obj.custom_fields = []
48
+ value.each do |custom_field|
49
+ obj.custom_fields << Components::CustomField.create(custom_field)
50
+ end
51
+ end
52
+ elsif key == 'lists'
53
+ if value
54
+ obj.lists = []
55
+ value.each do |contact_list|
56
+ obj.lists << Components::ContactList.create(contact_list)
57
+ end
58
+ end
59
+ else
60
+ obj.send("#{key}=", value) if obj.respond_to? key
61
+ end
62
+ end
63
+ end
64
+ obj
65
+ end
60
66
 
61
67
  # Setter
62
68
  # @param [ContactList] contact_list
@@ -7,20 +7,20 @@
7
7
  module ConstantContact
8
8
  module Components
9
9
  class ContactList < Component
10
- attr_accessor :id, :name, :status, :created_date, :modified_date, :contact_count
10
+ attr_accessor :id, :name, :status, :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
- 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
13
+ # @param [Hash] props - 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
24
24
  end
25
25
  end
26
26
  end
@@ -9,18 +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
- 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
12
+ # Factory method to create a CustomField object from a json string
13
+ # @param [Hash] props - 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
26
26
  end
@@ -16,18 +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
- 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
19
+ # Factory method to create an EmailAddress object from a json string
20
+ # @param [Hash] props - 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
33
33
  end
@@ -9,18 +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 [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
12
+ # Factory method to create a Note object from a json string
13
+ # @param [String] props - properties to create object from
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
24
24
  end
25
- end
25
+ end
26
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, :permalink_url
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, :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 - 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) if campaign.respond_to? key
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
@@ -57,7 +57,7 @@ module ConstantContact
57
57
  campaign = Campaign.new
58
58
  if props
59
59
  props.each do |key, value|
60
- campaign.send("#{key}=", value)
60
+ campaign.send("#{key}=", value) if campaign.respond_to? key
61
61
  end
62
62
  end
63
63
  campaign
@@ -10,18 +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
- 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
13
+ # Factory method to create an ClickThroughDetails object from an array
14
+ # @param [Hash] props - 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
27
27
  end
@@ -12,18 +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
- 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
15
+ # Factory method to create a MessageFooter object from an array
16
+ # @param [Hash] props - 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
29
29
  end
@@ -10,19 +10,18 @@ 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
- 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
13
+ # Factory method to create a Schedule object from an array
14
+ # @param [Hash] props - properties to create object from
15
+ # @return [Schedule]
16
+ def self.create(props)
17
+ obj = Schedule.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,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
- 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
13
+ # Factory method to create a TestSend object from an array
14
+ # @param [Hash] props - 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