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
@@ -1,26 +1,26 @@
1
1
  #
2
- # fee.rb
2
+ # event_fee.rb
3
3
  # ConstantContact
4
4
  #
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
8
  module Components
9
- class Fee < Component
10
- attr_accessor :id, :fee, :late_fee, :early_fee, :fee_scope, :label
9
+ class EventFee < Component
10
+ attr_accessor :early_fee, :fee, :fee_scope, :id, :label, :late_fee
11
11
 
12
12
  # Factory method to create an event Fee object from a hash
13
13
  # @param [Hash] props - hash of properties to create object from
14
- # @return [Campaign]
14
+ # @return [EventFee]
15
15
  def self.create(props)
16
- fee = Fee.new
16
+ obj = EventFee.new
17
17
  if props
18
18
  props.each do |key, value|
19
19
  key = key.to_s
20
- fee.send("#{key}=", value) if fee.respond_to? key
20
+ obj.send("#{key}=", value) if obj.respond_to? key
21
21
  end
22
22
  end
23
- fee
23
+ obj
24
24
  end
25
25
  end
26
26
  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
@@ -8,11 +8,14 @@ module ConstantContact
8
8
  module Components
9
9
  module EventSpot
10
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
11
+ attr_accessor :early_fee_date, :guest_display_label, :guest_limit, :information_sections,
12
+ :is_guest_anonymous_enabled, :is_guest_name_required, :is_registration_closed_manually,
13
+ :is_ticketing_link_displayed, :late_fee_date, :registration_limit_count,
14
+ :registration_limit_date
12
15
 
13
- # Factory method to create an event RegistrantTracking object from a hash
16
+ # Factory method to create an event EventTrack object from a hash
14
17
  # @param [Hash] props - hash of properties to create object from
15
- # @return [Campaign]
18
+ # @return [EventTrack]
16
19
  def self.create(props)
17
20
  obj = EventTrack.new
18
21
  props.each do |key, value|
@@ -10,20 +10,20 @@ module ConstantContact
10
10
  class Guest < Component
11
11
  attr_accessor :guest_id, :guest_section
12
12
 
13
- # Factory method to create an event Registrant object from a hash
13
+ # Factory method to create a Guest object from a hash
14
14
  # @param [Hash] props - hash of properties to create object from
15
- # @return [Campaign]
15
+ # @return [Guest]
16
16
  def self.create(props)
17
- guest = Guest.new
17
+ obj = Guest.new
18
18
  props.each do |key, value|
19
19
  key = key.to_s
20
20
  if key == 'guest_section'
21
- guest.send("#{key}=", Components::EventSpot::RegistrantSection.create(value))
21
+ obj.send("#{key}=", Components::EventSpot::GuestSection.create(value))
22
22
  else
23
- guest.send("#{key}=", value) if guest.respond_to?("#{key}=")
23
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
24
24
  end
25
25
  end
26
- guest
26
+ obj
27
27
  end
28
28
  end
29
29
  end
@@ -0,0 +1,34 @@
1
+ #
2
+ # guest_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 GuestSection < Component
11
+ attr_accessor :label, :fields
12
+
13
+ # Factory method to create a GuestSection object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [GuestSection]
16
+ def self.create(props)
17
+ obj = GuestSection.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ if key == 'fields'
21
+ value ||= []
22
+ obj.fields = value.collect do |field|
23
+ Components::EventSpot::RegistrantField.create(field)
24
+ end
25
+ else
26
+ obj.send("#{key}=", value) if obj.respond_to? key
27
+ end
28
+ end if props
29
+ obj
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -8,11 +8,11 @@ module ConstantContact
8
8
  module Components
9
9
  module EventSpot
10
10
  class NotificationOption < Component
11
- attr_accessor :notification_type, :is_opted_in
11
+ attr_accessor :is_opted_in, :notification_type
12
12
 
13
13
  # Factory method to create an event NotificationOption object from a hash
14
14
  # @param [Hash] props - hash of properties to create object from
15
- # @return [Campaign]
15
+ # @return [NotificationOption]
16
16
  def self.create(props)
17
17
  obj = NotificationOption.new
18
18
  props.each do |key, value|
@@ -0,0 +1,28 @@
1
+ #
2
+ # online_meeting.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 OnlineMeeting < Component
11
+ attr_accessor :instructions, :provider_meeting_id, :provider_type, :url
12
+
13
+ # Factory method to create an OnlineMeeting object from a json string
14
+ # @param [Hash] props - properties to create object from
15
+ # @return [OnlineMeeting]
16
+ def self.create(props)
17
+ obj = OnlineMeeting.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
28
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # payment_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 PaymentAddress < 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 a PaymentAddress object from a json string
15
+ # @param [Hash] props - properties to create object from
16
+ # @return [PaymentAddress]
17
+ def self.create(props)
18
+ obj = PaymentAddress.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,33 @@
1
+ #
2
+ # payment_summary.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 PaymentSummary < Component
11
+ attr_accessor :order, :payment_status, :payment_type, :promo_code
12
+
13
+ # Factory method to create an event PaymentSummary object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [PaymentSummary]
16
+ def self.create(props)
17
+ obj = PaymentSummary.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ if key == 'order'
21
+ obj.order = Components::EventSpot::RegistrantOrder.create(value)
22
+ elsif key == 'promo_code'
23
+ obj.promo_code = Components::EventSpot::RegistrantPromoCode.create(value)
24
+ else
25
+ obj.send("#{key}=", value) if obj.respond_to? key
26
+ end
27
+ end if props
28
+ obj
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # promocode.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 :code_name, :code_type, :discount_amount, :discount_percent, :discount_scope, :discount_type,
11
+ :fee_ids, :id, :is_paused, :quantity_available, :quantity_total, :quantity_used, :status
12
+
13
+ # Factory method to create an event Promocode object from a hash
14
+ # @param [Hash] props - properties to create object from
15
+ # @return [Promocode]
16
+ def self.create(props)
17
+ obj = Promocode.new
18
+ props.each do |key, value|
19
+ obj.send("#{key}=", value) if obj.respond_to? key
20
+ end
21
+ obj
22
+ end
23
+ end
24
+ end
25
+ end
@@ -7,47 +7,45 @@
7
7
  module ConstantContact
8
8
  module Components
9
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
10
+ attr_accessor :attendance_status, :email, :first_name, :guest_count, :id, :last_name, :payment_status,
11
+ :registration_date, :registration_status, :ticket_id, :updated_date,
12
+ :payment_summary, :promo_code, :sections, :guests
13
13
 
14
14
  # Factory method to create an event Registrant object from a hash
15
15
  # @param [Hash] props - hash of properties to create object from
16
- # @return [Campaign]
16
+ # @return [Registrant]
17
17
  def self.create(props)
18
- registrant = Registrant.new
18
+ obj = Registrant.new
19
19
  if props
20
20
  props.each do |key, value|
21
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 }
22
+ if key == 'payment_summary'
23
+ obj.payment_summary = Components::EventSpot::PaymentSummary.create(value)
24
+ elsif key == 'sections'
25
+ obj.sections = value.collect{|section| Components::EventSpot::RegistrantSection.create(section) }
26
+ elsif key == 'promo_code'
27
+ obj.promo_code = Components::EventSpot::RegistrantPromoCode.create(value)
30
28
  elsif key == 'guests'
31
29
  value = value["guest_info"] || []
32
- registrant.guests = value.collect{|guest| Components::EventSpot::Guest.create guest }
30
+ obj.guests = value.collect{|guest| Components::EventSpot::Guest.create(guest) }
33
31
  else
34
- registrant.send("#{key}=", value) if registrant.respond_to?("#{key}=")
32
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
35
33
  end
36
34
  end
37
35
  end
38
- registrant
36
+ obj
39
37
  end
40
-
38
+
41
39
  # Factory method to create an event Registrant summary object from a hash
42
40
  # @param [Hash] props - hash of properties to create object from
43
- # @return [Campaign]
41
+ # @return [Registrant]
44
42
  def self.create_summary(props)
45
- registrant = Registrant.new
43
+ obj = Registrant.new
46
44
  props.each do |key, value|
47
45
  key = key.to_s
48
- registrant.send("#{key}=", value) if registrant.respond_to?("#{key}=")
46
+ obj.send("#{key}=", value) if obj.respond_to?("#{key}=")
49
47
  end if props
50
- registrant
48
+ obj
51
49
  end
52
50
  end
53
51
  end
@@ -0,0 +1,29 @@
1
+ #
2
+ # registrant_fee.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 RegistrantFee < Component
11
+ attr_accessor :id, :amount, :promo_type, :fee_period_type, :type, :name, :quantity
12
+
13
+ # Factory method to create a RegistrantFee object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [RegistrantFee]
16
+ def self.create(props)
17
+ obj = RegistrantFee.new
18
+ if props
19
+ props.each do |key, value|
20
+ key = key.to_s
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,39 @@
1
+ #
2
+ # registrant_order.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 RegistrantOrder < Component
11
+ attr_accessor :currency_type, :fees, :items, :order_id, :order_date, :total
12
+
13
+ # Factory method to create a RegistrantOrder object from a hash
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [RegistrantOrder]
16
+ def self.create(props)
17
+ obj = RegistrantOrder.new
18
+ props.each do |key, value|
19
+ key = key.to_s
20
+ if key == 'fees'
21
+ value ||= []
22
+ obj.fees = value.collect do |fee|
23
+ Components::EventSpot::RegistrantFee.create(fee)
24
+ end
25
+ elsif key == 'items'
26
+ value ||= []
27
+ obj.items = value.collect do |item|
28
+ Components::EventSpot::SaleItem.create(item)
29
+ end
30
+ else
31
+ obj.send("#{key}=", value) if obj.respond_to? key
32
+ end
33
+ end if props
34
+ obj
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end