constantcontact-ruby 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/README.md +136 -0
  4. data/constantcontact-ruby.gemspec +31 -0
  5. data/lib/constantcontact/api.rb +1012 -0
  6. data/lib/constantcontact/auth/oauth2.rb +105 -0
  7. data/lib/constantcontact/auth/session_data_store.rb +69 -0
  8. data/lib/constantcontact/components/account/account_address.rb +26 -0
  9. data/lib/constantcontact/components/account/account_info.rb +38 -0
  10. data/lib/constantcontact/components/account/verified_email_address.rb +26 -0
  11. data/lib/constantcontact/components/activities/activity.rb +43 -0
  12. data/lib/constantcontact/components/activities/activity_error.rb +26 -0
  13. data/lib/constantcontact/components/activities/add_contacts.rb +127 -0
  14. data/lib/constantcontact/components/activities/add_contacts_import_data.rb +46 -0
  15. data/lib/constantcontact/components/activities/export_contacts.rb +30 -0
  16. data/lib/constantcontact/components/component.rb +48 -0
  17. data/lib/constantcontact/components/contacts/address.rb +27 -0
  18. data/lib/constantcontact/components/contacts/contact.rb +92 -0
  19. data/lib/constantcontact/components/contacts/contact_list.rb +26 -0
  20. data/lib/constantcontact/components/contacts/custom_field.rb +26 -0
  21. data/lib/constantcontact/components/contacts/email_address.rb +33 -0
  22. data/lib/constantcontact/components/contacts/note.rb +26 -0
  23. data/lib/constantcontact/components/email_marketing/campaign.rb +83 -0
  24. data/lib/constantcontact/components/email_marketing/campaign_preview.rb +29 -0
  25. data/lib/constantcontact/components/email_marketing/click_through_details.rb +27 -0
  26. data/lib/constantcontact/components/email_marketing/message_footer.rb +29 -0
  27. data/lib/constantcontact/components/email_marketing/schedule.rb +27 -0
  28. data/lib/constantcontact/components/email_marketing/test_send.rb +45 -0
  29. data/lib/constantcontact/components/event_spot/contact.rb +27 -0
  30. data/lib/constantcontact/components/event_spot/event.rb +69 -0
  31. data/lib/constantcontact/components/event_spot/event_address.rb +29 -0
  32. data/lib/constantcontact/components/event_spot/event_fee.rb +27 -0
  33. data/lib/constantcontact/components/event_spot/event_item.rb +36 -0
  34. data/lib/constantcontact/components/event_spot/event_item_attribute.rb +26 -0
  35. data/lib/constantcontact/components/event_spot/event_track.rb +31 -0
  36. data/lib/constantcontact/components/event_spot/guest.rb +31 -0
  37. data/lib/constantcontact/components/event_spot/guest_section.rb +34 -0
  38. data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
  39. data/lib/constantcontact/components/event_spot/online_meeting.rb +28 -0
  40. data/lib/constantcontact/components/event_spot/payment_address.rb +29 -0
  41. data/lib/constantcontact/components/event_spot/payment_summary.rb +33 -0
  42. data/lib/constantcontact/components/event_spot/promocode.rb +25 -0
  43. data/lib/constantcontact/components/event_spot/registrant.rb +52 -0
  44. data/lib/constantcontact/components/event_spot/registrant_fee.rb +29 -0
  45. data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
  46. data/lib/constantcontact/components/event_spot/registrant_order.rb +39 -0
  47. data/lib/constantcontact/components/event_spot/registrant_promo_code.rb +31 -0
  48. data/lib/constantcontact/components/event_spot/registrant_promo_code_info.rb +27 -0
  49. data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
  50. data/lib/constantcontact/components/event_spot/sale_item.rb +29 -0
  51. data/lib/constantcontact/components/library/file/library_file.rb +27 -0
  52. data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
  53. data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
  54. data/lib/constantcontact/components/library/info/move_results.rb +26 -0
  55. data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
  56. data/lib/constantcontact/components/result_set.rb +50 -0
  57. data/lib/constantcontact/components/tracking/bounce_activity.rb +28 -0
  58. data/lib/constantcontact/components/tracking/click_activity.rb +26 -0
  59. data/lib/constantcontact/components/tracking/forward_activity.rb +26 -0
  60. data/lib/constantcontact/components/tracking/open_activity.rb +26 -0
  61. data/lib/constantcontact/components/tracking/send_activity.rb +27 -0
  62. data/lib/constantcontact/components/tracking/tracking_activity.rb +26 -0
  63. data/lib/constantcontact/components/tracking/tracking_summary.rb +27 -0
  64. data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +27 -0
  65. data/lib/constantcontact/exceptions/ctct_exception.rb +25 -0
  66. data/lib/constantcontact/exceptions/illegal_argument_exception.rb +11 -0
  67. data/lib/constantcontact/exceptions/oauth2_exception.rb +11 -0
  68. data/lib/constantcontact/exceptions/webhooks_exception.rb +11 -0
  69. data/lib/constantcontact/services/account_service.rb +39 -0
  70. data/lib/constantcontact/services/activity_service.rb +136 -0
  71. data/lib/constantcontact/services/base_service.rb +68 -0
  72. data/lib/constantcontact/services/campaign_schedule_service.rb +101 -0
  73. data/lib/constantcontact/services/campaign_tracking_service.rb +152 -0
  74. data/lib/constantcontact/services/contact_service.rb +105 -0
  75. data/lib/constantcontact/services/contact_tracking_service.rb +152 -0
  76. data/lib/constantcontact/services/email_marketing_service.rb +94 -0
  77. data/lib/constantcontact/services/event_spot_service.rb +448 -0
  78. data/lib/constantcontact/services/library_service.rb +281 -0
  79. data/lib/constantcontact/services/list_service.rb +81 -0
  80. data/lib/constantcontact/util/config.rb +180 -0
  81. data/lib/constantcontact/util/helpers.rb +27 -0
  82. data/lib/constantcontact/version.rb +12 -0
  83. data/lib/constantcontact/webhooks/helpers/validator.rb +30 -0
  84. data/lib/constantcontact/webhooks/models/billing_change_notification.rb +27 -0
  85. data/lib/constantcontact/webhooks/webhooks_util.rb +45 -0
  86. data/lib/constantcontact.rb +124 -0
  87. data/spec/constantcontact/api_spec.rb +1560 -0
  88. data/spec/constantcontact/auth/oauth2_spec.rb +125 -0
  89. data/spec/constantcontact/components/contacts/address_spec.rb +18 -0
  90. data/spec/constantcontact/components/contacts/contact_list_spec.rb +18 -0
  91. data/spec/constantcontact/components/contacts/contact_spec.rb +18 -0
  92. data/spec/constantcontact/components/contacts/custom_field_spec.rb +18 -0
  93. data/spec/constantcontact/components/contacts/email_address_spec.rb +18 -0
  94. data/spec/constantcontact/sdk_spec.rb +24 -0
  95. data/spec/constantcontact/services/account_service_spec.rb +46 -0
  96. data/spec/constantcontact/services/activity_service_spec.rb +244 -0
  97. data/spec/constantcontact/services/base_service_spec.rb +50 -0
  98. data/spec/constantcontact/services/campaign_schedule_service_spec.rb +115 -0
  99. data/spec/constantcontact/services/campaign_tracking_service_spec.rb +131 -0
  100. data/spec/constantcontact/services/contact_service_spec.rb +111 -0
  101. data/spec/constantcontact/services/contact_tracking_service_spec.rb +131 -0
  102. data/spec/constantcontact/services/email_marketing_spec.rb +100 -0
  103. data/spec/constantcontact/services/event_spot_spec.rb +423 -0
  104. data/spec/constantcontact/services/library_service_spec.rb +252 -0
  105. data/spec/constantcontact/services/list_service_spec.rb +89 -0
  106. data/spec/constantcontact/webhooks/webhooks_spec.rb +26 -0
  107. metadata +243 -0
@@ -0,0 +1,92 @@
1
+ #
2
+ # contact.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class Contact < Component
10
+
11
+ attr_accessor :id, :status, :first_name, :middle_name, :last_name, :confirmed, :email_addresses,
12
+ :prefix_name, :job_title, :addresses, :company_name, :home_phone,
13
+ :work_phone, :cell_phone, :fax, :custom_fields, :lists,
14
+ :source_details, :notes, :source
15
+
16
+
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
66
+
67
+ # Setter
68
+ # @param [ContactList] contact_list
69
+ def add_list(contact_list)
70
+ @lists = [] if @lists.nil?
71
+ @lists << contact_list
72
+ end
73
+
74
+
75
+ # Setter
76
+ # @param [EmailAddress] email_address
77
+ def add_email(email_address)
78
+ @email_addresses = [] if @email_addresses.nil?
79
+ @email_addresses << email_address
80
+ end
81
+
82
+
83
+ # Setter
84
+ # @param [Address] address
85
+ def add_address(address)
86
+ @addresses = [] if @addresses.nil?
87
+ @addresses << address
88
+ end
89
+
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # contact_list.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class ContactList < Component
10
+ attr_accessor :id, :name, :status, :contact_count
11
+
12
+ # Factory method to create a ContactList object from a json string
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
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # custom_field.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class CustomField < Component
10
+ attr_accessor :name, :value
11
+
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
+ end
@@ -0,0 +1,33 @@
1
+ #
2
+ # email_address.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class EmailAddress < Component
10
+ attr_accessor :id, :status, :confirm_status, :opt_in_source, :opt_in_date, :opt_out_date, :email_address
11
+
12
+ # Class constructor
13
+ # @param [String] email_address
14
+ # @return [EmailAddress]
15
+ def initialize(email_address = nil)
16
+ @email_address = email_address if email_address
17
+ end
18
+
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
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # note.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class Note < Component
10
+ attr_accessor :id, :note, :created_date, :modified_date
11
+
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
+ end
25
+ end
26
+ end
@@ -0,0 +1,83 @@
1
+ #
2
+ # campaign.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
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, :permalink_url
17
+
18
+
19
+ # Factory method to create a Campaign 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
+ else
45
+ campaign.send("#{key}=", value) if campaign.respond_to? key
46
+ end
47
+ end
48
+ end
49
+ campaign
50
+ end
51
+
52
+
53
+ # Factory method to create a Campaign object from an array
54
+ # @param [Hash] props - hash of initial properties to set
55
+ # @return [Campaign]
56
+ def self.create_summary(props)
57
+ campaign = Campaign.new
58
+ if props
59
+ props.each do |key, value|
60
+ campaign.send("#{key}=", value) if campaign.respond_to? key
61
+ end
62
+ end
63
+ campaign
64
+ end
65
+
66
+
67
+ # Add a contact list to set of lists associated with this email
68
+ # @param [Mixed] contact_list - Contact list id, or ContactList object
69
+ def add_list(contact_list)
70
+ if contact_list.instance_of?(ContactList)
71
+ list = contact_list
72
+ elsif contact_list.to_i.to_s == contact_list
73
+ list = ContactList.new(contact_list)
74
+ else
75
+ raise Exceptions::IllegalArgumentException, sprintf(Util::Config.get('errors.id_or_object'), 'ContactList')
76
+ end
77
+
78
+ @sent_to_contact_lists << list
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # campaign_preview.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class CampaignPreview < Component
10
+ attr_accessor :from_email, :preview_email_content, :preview_text_content,
11
+ :reply_to_email, :subject
12
+
13
+
14
+ # Factory method to create a CampaignPreview object from an array
15
+ # @param [Hash] props - properties to create object from
16
+ # @return [CampaignPreview]
17
+ def self.create(props)
18
+ obj = CampaignPreview.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
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # click_through_details.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class ClickThroughDetails < Component
10
+ attr_accessor :url, :url_uid, :click_count
11
+
12
+
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
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # message_footer.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class MessageFooter < Component
10
+ attr_accessor :city, :state, :country, :organization_name, :address_line_1,
11
+ :address_line_2, :address_line_3, :international_state,
12
+ :postal_code, :include_forward_email, :forward_email_link_text,
13
+ :include_subscribe_link, :subscribe_link_text
14
+
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
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # schedule.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class Schedule < Component
10
+ attr_accessor :id, :scheduled_date
11
+
12
+
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
27
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # test_send.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class TestSend < Component
10
+ attr_accessor :format, :personal_message, :email_addresses
11
+
12
+
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
+
35
+
36
+ # Add an email address to the set of addresses to send the test send too
37
+ # @param [String] email_address
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
@@ -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 :email_address, :name, :organization_name, :phone_number
12
+
13
+ # Factory method to create an event host Contact 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 = Contact.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,69 @@
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 :active_date, :address, :are_registrants_public, :cancelled_date, :contact, :created_date,
11
+ :currency_type, :deleted_date, :description, :end_date, :google_analytics_key, :google_merchant_id,
12
+ :id, :is_calendar_displayed, :is_checkin_available, :is_home_page_displayed,
13
+ :is_listed_in_external_directory, :is_map_displayed, :is_virtual_event, :location, :meta_data_tags,
14
+ :name, :notification_options, :online_meeting, :payable_to, :payment_address, :payment_options,
15
+ :paypal_account_email, :registration_url, :start_date, :status, :theme_name, :time_zone_description,
16
+ :time_zone_id, :title, :total_registered_count, :track_information, :twitter_hash_tag, :type,
17
+ :updated_date
18
+
19
+ # Factory method to create an Event object from a hash
20
+ # @param [Hash] props - hash of properties to create object from
21
+ # @return [Event]
22
+ def self.create(props)
23
+ obj = Event.new
24
+ if props
25
+ props.each do |key, value|
26
+ key = key.to_s
27
+ if key == 'address'
28
+ obj.address = Components::EventSpot::EventAddress.create(value)
29
+ elsif key == 'contact'
30
+ obj.contact = Components::EventSpot::Contact.create(value)
31
+ elsif key == 'notification_options'
32
+ value ||= []
33
+ obj.notification_options = value.collect{|option| Components::EventSpot::NotificationOption.create(option) }
34
+ elsif key == 'online_meeting'
35
+ obj.online_meeting = Components::EventSpot::OnlineMeeting.create(value)
36
+ elsif key == 'payment_adress'
37
+ obj.payment_adress = Components::EventSpot::PaymentAddress.create(value)
38
+ elsif key == 'track_information'
39
+ value ||= []
40
+ obj.track_information = Components::EventSpot::EventTrack.create(value)
41
+ else
42
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
43
+ end
44
+ end
45
+ end
46
+ obj
47
+ end
48
+
49
+ # Factory method to create a summary Event object from a hash
50
+ # @param [Hash] props - hash of properties to create object from
51
+ # @return [Event]
52
+ def self.create_summary(props)
53
+ obj = Event.new
54
+ if props
55
+ props.each do |key, value|
56
+ key = key.to_s
57
+ if key == 'address'
58
+ obj.address = Components::EventSpot::EventAddress.create(value)
59
+ else
60
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
61
+ end
62
+ end
63
+ end
64
+ obj
65
+ end
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # event_address.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 EventAddress < Component
11
+ attr_accessor :city, :country, :country_code, :latitude, :line1, :line2, :line3, :longitude, :postal_code,
12
+ :state, :state_code
13
+
14
+ # Factory method to create an EventAddress object from a json string
15
+ # @param [Hash] props - properties to create object from
16
+ # @return [EventAddress]
17
+ def self.create(props)
18
+ obj = EventAddress.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
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # event_fee.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class EventFee < Component
10
+ attr_accessor :early_fee, :fee, :fee_scope, :id, :label, :late_fee
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 [EventFee]
15
+ def self.create(props)
16
+ obj = EventFee.new
17
+ if props
18
+ props.each do |key, value|
19
+ key = key.to_s
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,36 @@
1
+ #
2
+ # event_item.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class EventItem < Component
10
+ attr_accessor :attributes, :default_quantity_available, :default_quantity_total, :description,
11
+ :id, :name, :per_registrant_limit, :price, :show_quantity_available
12
+
13
+ # Factory method to create an EventItem object from a hash
14
+ # @param [Hash] props - properties to create object from
15
+ # @return [EventItem]
16
+ def self.create(props)
17
+ obj = EventItem.new
18
+ if props
19
+ props.each do |key, value|
20
+ if key == 'attributes'
21
+ if value
22
+ obj.attributes = []
23
+ value.each do |attribute|
24
+ obj.attributes << Components::EventItemAttribute.create(attribute)
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
+ end
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # event_item_attribute.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Components
9
+ class EventItemAttribute < Component
10
+ attr_accessor :id, :name, :quantity_available, :quantity_total
11
+
12
+ # Factory method to create an EventItemAttribute object from a hash
13
+ # @param [Hash] props - properties to create object from
14
+ # @return [EventItemAttribute]
15
+ def self.create(props)
16
+ obj = EventItemAttribute.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