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
@@ -0,0 +1,27 @@
1
+ #
2
+ # contact.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ module EventSpot
10
+ class Contact < Component
11
+ attr_accessor :id, :name, :email_address, :phone_number, :organization_name
12
+
13
+ # Factory method to create an event Fee object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ contact = Contact.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ contact.send("#{key}=", value) if contact.respond_to? key
21
+ end if props
22
+ contact
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,63 @@
1
+ #
2
+ # event.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class Event < Component
10
+ attr_accessor :id, :type, :name, :title, :status, :description, :active_date, :start_date, :end_date,
11
+ :deleted_date, :created_date, :modified_date, :time_zone_id, :location, :currency_type,
12
+ :is_checkin_available, :total_registered_count, :registration_url, :theme_name,
13
+ :is_virtual_event, :notification_options, :is_home_page_displayed, :is_map_displayed,
14
+ :is_calendar_displayed, :is_listed_in_external_directory, :are_registrants_public,
15
+ :track_information,
16
+ :contact, :address
17
+
18
+ # Factory method to create an Event object from a hash
19
+ # @param [Hash] props - hash of properties to create object from
20
+ # @return [Campaign]
21
+ def self.create(props)
22
+ event = Event.new
23
+ if props
24
+ props.each do |key, value|
25
+ key = key.to_s
26
+ if key == 'address'
27
+ event.address = Components::Address.create(value)
28
+ elsif key == 'contact'
29
+ event.contact = Components::EventSpot::Contact.create(value)
30
+ elsif key == 'notification_options'
31
+ value ||= []
32
+ event.notification_options = value.collect{|notification| Components::EventSpot::NotificationOption.create notification }
33
+ elsif key == 'track_information'
34
+ value ||= []
35
+ event.track_information = Components::EventSpot::EventTrack.create value
36
+ else
37
+ event.send("#{key}=", value) if event.respond_to?("#{key}=")
38
+ end
39
+ end
40
+ end
41
+ event
42
+ end
43
+
44
+ # Factory method to create an summary Event object from a hash
45
+ # @param [Hash] props - hash of properties to create object from
46
+ # @return [Campaign]
47
+ def self.create_summary(props)
48
+ event = Event.new
49
+ if props
50
+ props.each do |key, value|
51
+ key = key.to_s
52
+ if key == 'address'
53
+ event.address = Components::Address.create(value)
54
+ else
55
+ event.send("#{key}=", value) if event.respond_to?("#{key}=")
56
+ end
57
+ end
58
+ end
59
+ event
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,28 @@
1
+ #
2
+ # event_track.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ module EventSpot
10
+ class EventTrack < Component
11
+ attr_accessor :information_sections, :is_registration_closed_manually, :is_ticketing_link_displayed, :guest_limit, :registration_limit_count, :guest_display_label, :is_guest_name_required, :is_guest_anonymous_enabled
12
+
13
+ # Factory method to create an event RegistrantTracking object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ obj = EventTrack.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
+ end if props
22
+ obj
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,27 @@
1
+ #
2
+ # fee.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class Fee < Component
10
+ attr_accessor :id, :fee, :late_fee, :early_fee, :fee_scope, :label
11
+
12
+ # Factory method to create an event Fee object from a hash
13
+ # @param [Hash] props - hash of properties to create object from
14
+ # @return [Campaign]
15
+ def self.create(props)
16
+ fee = Fee.new
17
+ if props
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ fee.send("#{key}=", value) if fee.respond_to? key
21
+ end
22
+ end
23
+ fee
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ #
2
+ # guest.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ module EventSpot
10
+ class Guest < Component
11
+ attr_accessor :guest_id, :guest_section
12
+
13
+ # Factory method to create an event Registrant object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ guest = Guest.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ if key == 'guest_section'
21
+ guest.send("#{key}=", Components::EventSpot::RegistrantSection.create(value))
22
+ else
23
+ guest.send("#{key}=", value) if guest.respond_to?("#{key}=")
24
+ end
25
+ end
26
+ guest
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # notification_option.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ module EventSpot
10
+ class NotificationOption < Component
11
+ attr_accessor :notification_type, :is_opted_in
12
+
13
+ # Factory method to create an event NotificationOption object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ obj = NotificationOption.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
+ end if props
22
+ obj
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # promo_code.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class PromoCode < Component
10
+ attr_accessor :discount_type, :code_type, :code_name, :redemption_count,
11
+ :discount_scope, :discount_amount, :discount_percent
12
+
13
+ # Factory method to create an event PromoCode object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ code = PromoCode.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ code.send("#{key}=", value) if code.respond_to? key
21
+ end
22
+ code
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # registrant.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class Registrant < Component
10
+ attr_accessor :id, :ticket_id, :registration_status, :registration_date, :attendance_status,
11
+ :email, :first_name, :last_name, :guest_count, :payment_status, :updated_date,
12
+ :sale_items, :fees, :promo_code_info, :sections, :guests
13
+
14
+ # Factory method to create an event Registrant object from a hash
15
+ # @param [Hash] props - hash of properties to create object from
16
+ # @return [Campaign]
17
+ def self.create(props)
18
+ registrant = Registrant.new
19
+ if props
20
+ props.each do |key, value|
21
+ key = key.to_s
22
+ if key == 'sale_items' or key == 'fees'
23
+ value ||= []
24
+ registrant.send("#{key}=", value.collect{|item| Components::EventSpot::SaleItem.create item })
25
+ elsif key == 'sections' or key == 'guest_sections'
26
+ registrant.send("#{key}=", value.collect{|section| Components::EventSpot::RegistrantSection.create(section) })
27
+ elsif key == 'promo_code_info'
28
+ value ||= []
29
+ registration.promo_code_info = value.collect{|code| Components::EventSpot::PromoCode.create code }
30
+ elsif key == 'guests'
31
+ value = value["guest_info"] || []
32
+ registrant.guests = value.collect{|guest| Components::EventSpot::Guest.create guest }
33
+ else
34
+ registrant.send("#{key}=", value) if registrant.respond_to?("#{key}=")
35
+ end
36
+ end
37
+ end
38
+ registrant
39
+ end
40
+
41
+ # Factory method to create an event Registrant summary object from a hash
42
+ # @param [Hash] props - hash of properties to create object from
43
+ # @return [Campaign]
44
+ def self.create_summary(props)
45
+ registrant = Registrant.new
46
+ props.each do |key, value|
47
+ key = key.to_s
48
+ registrant.send("#{key}=", value) if registrant.respond_to?("#{key}=")
49
+ end if props
50
+ registrant
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # registrant_field.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ module EventSpot
10
+ class RegistrantField < Component
11
+ attr_accessor :type, :name, :label, :value, :values
12
+
13
+ # Factory method to create an event Fee object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ field = RegistrantField.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ field.send("#{key}=", value) if field.respond_to? key
21
+ end if props
22
+ field
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # registrant_section.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ module EventSpot
10
+ class RegistrantSection < Component
11
+ attr_accessor :label, :fields
12
+
13
+ # Factory method to create an event RegistrantSection object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [Campaign]
16
+ def self.create(props)
17
+ section = RegistrantSection.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ if key == 'fields'
21
+ value ||= []
22
+ section.fields = value.collect do |field|
23
+ Components::EventSpot::RegistrantField.create(field)
24
+ end
25
+ else
26
+ section.send("#{key}=", value) if section.respond_to? key
27
+ end
28
+ end if props
29
+ section
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # fee.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class SaleItem < Component
10
+ attr_accessor :id, :amount, :promo_type, :fee_period_type, :type, :name, :quantity
11
+
12
+ # Factory method to create an event Fee object from a hash
13
+ # @param [Hash] props - hash of properties to create object from
14
+ # @return [Campaign]
15
+ def self.create(props)
16
+ item = SaleItem.new
17
+ if props
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ item.send("#{key}=", value) if item.respond_to? key
21
+ end
22
+ end
23
+ item
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # library_file.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class LibraryFile < Component
10
+ attr_accessor :created_date, :description, :file_type, :folder, :folder_id, :height, :id, :is_image,
11
+ :modified_date, :name, :size, :source, :status, :thumbnail, :url, :width, :type
12
+
13
+ # Factory method to create a LibraryFile object from a json string
14
+ # @param [Hash] props - properties to create object from
15
+ # @return [LibraryFile]
16
+ def self.create(props)
17
+ obj = LibraryFile.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
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # library_folder.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class LibraryFolder < Component
10
+ attr_accessor :created_date, :id, :item_count, :level, :modified_date, :name, :parent_id, :children
11
+
12
+ # Factory method to create a LibraryFolder object from a json string
13
+ # @param [Hash] props - properties to create object from
14
+ # @return [LibraryFolder]
15
+ def self.create(props)
16
+ obj = LibraryFolder.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
+ end