constantcontact 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/README.md +2 -2
  2. data/constantcontact.gemspec +1 -1
  3. data/lib/constantcontact.rb +15 -2
  4. data/lib/constantcontact/api.rb +164 -21
  5. data/lib/constantcontact/components/event_spot/contact.rb +5 -5
  6. data/lib/constantcontact/components/event_spot/event.rb +28 -22
  7. data/lib/constantcontact/components/event_spot/event_address.rb +29 -0
  8. data/lib/constantcontact/components/event_spot/{fee.rb → event_fee.rb} +7 -7
  9. data/lib/constantcontact/components/event_spot/event_item.rb +36 -0
  10. data/lib/constantcontact/components/event_spot/event_item_attribute.rb +26 -0
  11. data/lib/constantcontact/components/event_spot/event_track.rb +6 -3
  12. data/lib/constantcontact/components/event_spot/guest.rb +6 -6
  13. data/lib/constantcontact/components/event_spot/guest_section.rb +34 -0
  14. data/lib/constantcontact/components/event_spot/notification_option.rb +2 -2
  15. data/lib/constantcontact/components/event_spot/online_meeting.rb +28 -0
  16. data/lib/constantcontact/components/event_spot/payment_address.rb +29 -0
  17. data/lib/constantcontact/components/event_spot/payment_summary.rb +33 -0
  18. data/lib/constantcontact/components/event_spot/promocode.rb +25 -0
  19. data/lib/constantcontact/components/event_spot/registrant.rb +19 -21
  20. data/lib/constantcontact/components/event_spot/registrant_fee.rb +29 -0
  21. data/lib/constantcontact/components/event_spot/registrant_order.rb +39 -0
  22. data/lib/constantcontact/components/event_spot/registrant_promo_code.rb +31 -0
  23. data/lib/constantcontact/components/event_spot/registrant_promo_code_info.rb +27 -0
  24. data/lib/constantcontact/components/event_spot/registrant_section.rb +6 -6
  25. data/lib/constantcontact/components/event_spot/sale_item.rb +15 -13
  26. data/lib/constantcontact/services/event_spot_service.rb +252 -29
  27. data/lib/constantcontact/util/config.rb +12 -6
  28. data/lib/constantcontact/version.rb +1 -1
  29. data/spec/constantcontact/api_spec.rb +221 -21
  30. data/spec/constantcontact/services/event_spot_spec.rb +223 -21
  31. metadata +118 -76
  32. checksums.yaml +0 -7
  33. data/lib/constantcontact/components/event_spot/promo_code.rb +0 -26
data/README.md CHANGED
@@ -9,7 +9,7 @@ Installation
9
9
  ====
10
10
  Via bundler:
11
11
  ```ruby
12
- gem 'constantcontact', '~> 1.1.0'
12
+ gem 'constantcontact', '~> 1.2.0'
13
13
  ```
14
14
  Otherwise:
15
15
  ```bash
@@ -127,4 +127,4 @@ Create a my_view.erb with the following code:
127
127
 
128
128
  The first time you access the action in browser you should see the "Click to authorize" link.
129
129
  Follow the link, go through all the Constant Contact steps required
130
- and then you will be redirected back to your action and you should see the list of contacts.
130
+ and then you will be redirected back to your action and you should see the list of contacts.
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "constantcontact"
8
- s.version = '1.1.2'
8
+ s.version = '1.2.0'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["ConstantContact"]
11
11
  s.homepage = "http://www.constantcontact.com"
@@ -49,8 +49,11 @@ module ConstantContact
49
49
  autoload :TrackingSummary, 'constantcontact/components/tracking/tracking_summary'
50
50
  autoload :VerifiedEmailAddress, 'constantcontact/components/account/verified_email_address'
51
51
  autoload :Event, 'constantcontact/components/event_spot/event'
52
- autoload :Fee, 'constantcontact/components/event_spot/fee'
52
+ autoload :EventFee, 'constantcontact/components/event_spot/event_fee'
53
53
  autoload :Registrant, 'constantcontact/components/event_spot/registrant'
54
+ autoload :EventItem, 'constantcontact/components/event_spot/event_item'
55
+ autoload :EventItemAttribute, 'constantcontact/components/event_spot/event_item_attribute'
56
+ autoload :Promocode, 'constantcontact/components/event_spot/promocode'
54
57
  autoload :LibrarySummary, 'constantcontact/components/library/info/library_summary'
55
58
  autoload :UploadStatus, 'constantcontact/components/library/info/upload_status'
56
59
  autoload :MoveResults, 'constantcontact/components/library/info/move_results'
@@ -58,12 +61,22 @@ module ConstantContact
58
61
  autoload :LibraryFile, 'constantcontact/components/library/file/library_file'
59
62
 
60
63
  module EventSpot
64
+ autoload :EventAddress, 'constantcontact/components/event_spot/event_address'
61
65
  autoload :Contact, 'constantcontact/components/event_spot/contact'
62
66
  autoload :NotificationOption, 'constantcontact/components/event_spot/notification_option'
67
+ autoload :OnlineMeeting, 'constantcontact/components/event_spot/online_meeting'
68
+ autoload :PaymentAddress, 'constantcontact/components/event_spot/payment_address'
69
+ autoload :PaymentSummary, 'constantcontact/components/event_spot/payment_summary'
63
70
  autoload :Guest, 'constantcontact/components/event_spot/guest'
71
+ autoload :GuestSection, 'constantcontact/components/event_spot/guest_section'
64
72
  autoload :EventTrack, 'constantcontact/components/event_spot/event_track'
65
- autoload :RegistrantSection, 'constantcontact/components/event_spot/registrant_section'
73
+ autoload :RegistrantFee, 'constantcontact/components/event_spot/registrant_fee'
66
74
  autoload :RegistrantField, 'constantcontact/components/event_spot/registrant_field'
75
+ autoload :RegistrantOrder, 'constantcontact/components/event_spot/registrant_order'
76
+ autoload :RegistrantPromoCode, 'constantcontact/components/event_spot/registrant_promo_code'
77
+ autoload :RegistrantPromoCodeInfo, 'constantcontact/components/event_spot/registrant_promo_code_info'
78
+ autoload :RegistrantSection, 'constantcontact/components/event_spot/registrant_section'
79
+ autoload :SaleItem, 'constantcontact/components/event_spot/sale_item'
67
80
  end
68
81
  end
69
82
 
@@ -621,25 +621,16 @@ module ConstantContact
621
621
  # Cancel an event
622
622
  # @param [String] access_token - Constant Contact OAuth2 access token
623
623
  # @param [Event] event - Event to cancel
624
- # @return [Activity]
624
+ # @return [Event]
625
625
  def cancel_event(access_token, event)
626
626
  Services::EventSpotService.cancel_event(access_token, event)
627
627
  end
628
628
 
629
629
 
630
- # Delete an event
631
- # @param [String] access_token - Constant Contact OAuth2 access token
632
- # @param [Event] event - Event fee corresponds to
633
- # @return [Activity]
634
- def delete_event(access_token, event)
635
- Services::EventSpotService.delete_event(access_token, event)
636
- end
637
-
638
-
639
630
  # Get a list of event fees
640
631
  # @param [String] access_token - Constant Contact OAuth2 access token
641
632
  # @param [Event] event - Event to get fees of
642
- # @return [Activity]
633
+ # @return [<Array>EventFee]
643
634
  def get_event_fees(access_token, event)
644
635
  Services::EventSpotService.get_fees(access_token, event)
645
636
  end
@@ -648,8 +639,8 @@ module ConstantContact
648
639
  # Get an event fee
649
640
  # @param [String] access_token - Constant Contact OAuth2 access token
650
641
  # @param [Event] event - Event fee corresponds to
651
- # @param [Fee] fee - Fee to retrieve
652
- # @return [Activity]
642
+ # @param [EventFee] fee - Fee to retrieve
643
+ # @return [EventFee]
653
644
  def get_event_fee(access_token, event, fee)
654
645
  Services::EventSpotService.get_fee(access_token, event, fee)
655
646
  end
@@ -659,7 +650,7 @@ module ConstantContact
659
650
  # @param [String] access_token - Constant Contact OAuth2 access token
660
651
  # @param [Event] event - Event fee corresponds to
661
652
  # @param [Hash] fee - Fee details
662
- # @return [Activity]
653
+ # @return [EventFee]
663
654
  def add_event_fee(access_token, event, fee)
664
655
  Services::EventSpotService.add_fee(access_token, event, fee)
665
656
  end
@@ -668,8 +659,8 @@ module ConstantContact
668
659
  # Update an event fee
669
660
  # @param [String] access_token - Constant Contact OAuth2 access token
670
661
  # @param [Event] event - Event fee corresponds to
671
- # @param [Fee] fee - Fee details
672
- # @return [Activity]
662
+ # @param [EventFee] fee - Fee details
663
+ # @return [EventFee]
673
664
  def update_event_fee(access_token, event, fee)
674
665
  Services::EventSpotService.update_fee(access_token, event, fee)
675
666
  end
@@ -678,17 +669,17 @@ module ConstantContact
678
669
  # Delete an event fee
679
670
  # @param [String] access_token - Constant Contact OAuth2 access token
680
671
  # @param [Event] event - Event fee corresponds to
681
- # @param [Fee] fee - Fee details
682
- # @return [Activity]
672
+ # @param [EventFee] fee - Fee details
673
+ # @return [Boolean]
683
674
  def delete_event_fee(access_token, event, fee)
684
675
  Services::EventSpotService.delete_fee(access_token, event, fee)
685
676
  end
686
677
 
687
678
 
688
- # Get a list of event registrants
679
+ # Get a set of event registrants
689
680
  # @param [String] access_token - Constant Contact OAuth2 access token
690
681
  # @param [Event] event - Event fee corresponds to
691
- # @return [Activity]
682
+ # @return [ResultSet<Registrant>]
692
683
  def get_event_registrants(access_token, event)
693
684
  Services::EventSpotService.get_registrants(access_token, event)
694
685
  end
@@ -698,12 +689,164 @@ module ConstantContact
698
689
  # @param [String] access_token - Constant Contact OAuth2 access token
699
690
  # @param [Event] event - Event registrant corresponds to
700
691
  # @param [Registrant] registrant - registrant details
701
- # @return [Activity]
692
+ # @return [Registrant]
702
693
  def get_event_registrant(access_token, event, registrant)
703
694
  Services::EventSpotService.get_registrant(access_token, event, registrant)
704
695
  end
705
696
 
706
697
 
698
+ # Get an array of event items for an individual event
699
+ # @param [String] access_token - Constant Contact OAuth2 access token
700
+ # @param [Integer] event_id - event id to retrieve items for
701
+ # @return [Array<EventItem>]
702
+ def get_event_items(access_token, event_id)
703
+ Services::EventSpotService.get_event_items(access_token, event_id)
704
+ end
705
+
706
+
707
+ # Get an individual event item
708
+ # @param [String] access_token - Constant Contact OAuth2 access token
709
+ # @param [Integer] event_id - id of event to retrieve item for
710
+ # @param [Integer] item_id - id of item to be retrieved
711
+ # @return [EventItem]
712
+ def get_event_item(access_token, event_id, item_id)
713
+ Services::EventSpotService.get_event_item(access_token, event_id, item_id)
714
+ end
715
+
716
+
717
+ # Create a new event item for an event
718
+ # @param [String] access_token - Constant Contact OAuth2 access token
719
+ # @param [Integer] event_id - id of event to be associated with the event item
720
+ # @param [EventItem] event_item - event item to be created
721
+ # @return [EventItem]
722
+ def add_event_item(access_token, event_id, event_item)
723
+ Services::EventSpotService.add_event_item(access_token, event_id, event_item)
724
+ end
725
+
726
+
727
+ # Delete a specific event item for an event
728
+ # @param [String] access_token - Constant Contact OAuth2 access token
729
+ # @param [Integer] event_id - id of event to delete an event item for
730
+ # @param [Integer] item_id - id of event item to be deleted
731
+ # @return [Boolean]
732
+ def delete_event_item(access_token, event_id, item_id)
733
+ Services::EventSpotService.delete_event_item(access_token, event_id, item_id)
734
+ end
735
+
736
+
737
+ # Update a specific event item for an event
738
+ # @param [String] access_token - Constant Contact OAuth2 access token
739
+ # @param [Integer] event_id - id of event associated with the event item
740
+ # @param [EventItem] event_item - event item to be updated
741
+ # @return [EventItem]
742
+ def update_event_item(access_token, event_id, event_item)
743
+ Services::EventSpotService.update_event_item(access_token, event_id, event_item)
744
+ end
745
+
746
+
747
+ # Get an array of attributes for an individual event item
748
+ # @param [String] access_token - Constant Contact OAuth2 access token
749
+ # @param [Integer] event_id - event id to retrieve item for
750
+ # @param [Integer] item_id - event item id to retrieve attributes for
751
+ # @return [Array<EventItemAttribute>]
752
+ def get_event_item_attributes(access_token, event_id, item_id)
753
+ Services::EventSpotService.get_event_item_attributes(access_token, event_id, item_id)
754
+ end
755
+
756
+
757
+ # Get an individual event item attribute
758
+ # @param [String] access_token - Constant Contact OAuth2 access token
759
+ # @param [Integer] event_id - id of event to retrieve item for
760
+ # @param [Integer] item_id - id of item to retrieve attribute for
761
+ # @param [Integer] attribute_id - id of attribute to be retrieved
762
+ # @return [EventItemAttribute]
763
+ def get_event_item_attribute(access_token, event_id, item_id, attribute_id)
764
+ Services::EventSpotService.get_event_item_attribute(access_token, event_id, item_id, attribute_id)
765
+ end
766
+
767
+
768
+ # Create a new event item attribute for an event item
769
+ # @param [String] access_token - Constant Contact OAuth2 access token
770
+ # @param [Integer] event_id - id of event to be associated with the event item attribute
771
+ # @param [Integer] item_id - id of event item to be associated with the event item attribute
772
+ # @param [EventItemAttribute] event_item_attribute - event item attribute to be created
773
+ # @return [EventItemAttribute]
774
+ def add_event_item_attribute(access_token, event_id, item_id, event_item_attribute)
775
+ Services::EventSpotService.add_event_item_attribute(access_token, event_id, item_id, event_item_attribute)
776
+ end
777
+
778
+
779
+ # Delete a specific event item for an event
780
+ # @param [String] access_token - Constant Contact OAuth2 access token
781
+ # @param [Integer] event_id - id of event to delete an event item attribute for
782
+ # @param [Integer] item_id - id of event item to delete an event item attribute for
783
+ # @param [Integer] attribute_id - id of attribute to be deleted
784
+ # @return [Boolean]
785
+ def delete_event_item_attribute(access_token, event_id, item_id, attribute_id)
786
+ Services::EventSpotService.delete_event_item_attribute(access_token, event_id, item_id, attribute_id)
787
+ end
788
+
789
+
790
+ # Update a specific event item attribute for an event item
791
+ # @param [String] access_token - Constant Contact OAuth2 access token
792
+ # @param [Integer] event_id - id of event associated with the event item
793
+ # @param [Integer] item_id - id of event item associated with the event item attribute
794
+ # @param [EventItemAttribute] event_item_attribute - event item to be updated
795
+ # @return [EventItemAttribute]
796
+ def update_event_item_attribute(access_token, event_id, item_id, event_item_attribute)
797
+ Services::EventSpotService.update_event_item_attribute(access_token, event_id, item_id, event_item_attribute)
798
+ end
799
+
800
+
801
+ # Get an array of promocodes for an individual event
802
+ # @param [String] access_token - Constant Contact OAuth2 access token
803
+ # @param [Integer] event_id - event id to retrieve promocodes for
804
+ # @return [Array<Promocode>]
805
+ def get_promocodes(access_token, event_id)
806
+ Services::EventSpotService.get_promocodes(access_token, event_id)
807
+ end
808
+
809
+
810
+ # Get an individual promocode
811
+ # @param [String] access_token - Constant Contact OAuth2 access token
812
+ # @param [Integer] event_id - id of event to retrieve item for
813
+ # @param [Integer] promocode_id - id of item to be retrieved
814
+ # @return [Promocode]
815
+ def get_promocode(access_token, event_id, promocode_id)
816
+ Services::EventSpotService.get_promocode(access_token, event_id, promocode_id)
817
+ end
818
+
819
+
820
+ # Create a new promocode for an event
821
+ # @param [String] access_token - Constant Contact OAuth2 access token
822
+ # @param [Integer] event_id - id of event to be associated with the promocode
823
+ # @param [Promocode] promocode - promocode to be created
824
+ # @return [Promocode]
825
+ def add_promocode(access_token, event_id, promocode)
826
+ Services::EventSpotService.add_promocode(access_token, event_id, promocode)
827
+ end
828
+
829
+
830
+ # Delete a specific promocode for an event
831
+ # @param [String] access_token - Constant Contact OAuth2 access token
832
+ # @param [Integer] event_id - id of event to delete a promocode for
833
+ # @param [Integer] promocode_id - id of promocode to be deleted
834
+ # @return [Boolean]
835
+ def delete_promocode(access_token, event_id, promocode_id)
836
+ Services::EventSpotService.delete_promocode(access_token, event_id, promocode_id)
837
+ end
838
+
839
+
840
+ # Update a specific promocode for an event
841
+ # @param [String] access_token - Constant Contact OAuth2 access token
842
+ # @param [Integer] event_id - id of event associated with the promocode
843
+ # @param [Promocode] promocode - promocode to be updated
844
+ # @return [Promocode]
845
+ def update_promocode(access_token, event_id, promocode)
846
+ Services::EventSpotService.update_promocode(access_token, event_id, promocode)
847
+ end
848
+
849
+
707
850
  # Retrieve MyLibrary usage information
708
851
  # @param [String] access_token - Constant Contact OAuth2 access token
709
852
  # @return [LibrarySummary]
@@ -8,18 +8,18 @@ module ConstantContact
8
8
  module Components
9
9
  module EventSpot
10
10
  class Contact < Component
11
- attr_accessor :id, :name, :email_address, :phone_number, :organization_name
11
+ attr_accessor :email_address, :name, :organization_name, :phone_number
12
12
 
13
- # Factory method to create an event Fee object from a hash
13
+ # Factory method to create an event host Contact object from a hash
14
14
  # @param [Hash] props - hash of properties to create object from
15
15
  # @return [Campaign]
16
16
  def self.create(props)
17
- contact = Contact.new
17
+ obj = Contact.new
18
18
  props.each do |key, value|
19
19
  key = key.to_s
20
- contact.send("#{key}=", value) if contact.respond_to? key
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
21
  end if props
22
- contact
22
+ obj
23
23
  end
24
24
  end
25
25
  end
@@ -7,57 +7,63 @@
7
7
  module ConstantContact
8
8
  module Components
9
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
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
17
18
 
18
19
  # Factory method to create an Event object from a hash
19
20
  # @param [Hash] props - hash of properties to create object from
20
- # @return [Campaign]
21
+ # @return [Event]
21
22
  def self.create(props)
22
- event = Event.new
23
+ obj = Event.new
23
24
  if props
24
25
  props.each do |key, value|
25
26
  key = key.to_s
26
27
  if key == 'address'
27
- event.address = Components::Address.create(value)
28
+ obj.address = Components::EventSpot::EventAddress.create(value)
28
29
  elsif key == 'contact'
29
- event.contact = Components::EventSpot::Contact.create(value)
30
+ obj.contact = Components::EventSpot::Contact.create(value)
30
31
  elsif key == 'notification_options'
31
32
  value ||= []
32
- event.notification_options = value.collect{|notification| Components::EventSpot::NotificationOption.create notification }
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)
33
38
  elsif key == 'track_information'
34
39
  value ||= []
35
- event.track_information = Components::EventSpot::EventTrack.create value
40
+ obj.track_information = Components::EventSpot::EventTrack.create(value)
36
41
  else
37
- event.send("#{key}=", value) if event.respond_to?("#{key}=")
42
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
38
43
  end
39
44
  end
40
45
  end
41
- event
46
+ obj
42
47
  end
43
-
44
- # Factory method to create an summary Event object from a hash
48
+
49
+ # Factory method to create a summary Event object from a hash
45
50
  # @param [Hash] props - hash of properties to create object from
46
- # @return [Campaign]
51
+ # @return [Event]
47
52
  def self.create_summary(props)
48
- event = Event.new
53
+ obj = Event.new
49
54
  if props
50
55
  props.each do |key, value|
51
56
  key = key.to_s
52
57
  if key == 'address'
53
- event.address = Components::Address.create(value)
58
+ obj.address = Components::EventSpot::EventAddress.create(value)
54
59
  else
55
- event.send("#{key}=", value) if event.respond_to?("#{key}=")
60
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
56
61
  end
57
62
  end
58
63
  end
59
- event
64
+ obj
60
65
  end
61
66
  end
67
+
62
68
  end
63
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