constantcontact 1.1.2 → 1.2.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 (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
@@ -46,12 +46,18 @@ module ConstantContact
46
46
  :campaign_tracking_unsubscribes => 'emailmarketing/campaigns/%s/tracking/unsubscribes',
47
47
  :campaign_tracking_link => 'emailmarketing/campaigns/%s/tracking/clicks/%s',
48
48
 
49
- :events => 'eventspot/events',
50
- :event => 'eventspot/events/%s',
51
- :event_fees => 'eventspot/events/%s/fees',
52
- :event_fee => 'eventspot/events/%s/fees/%s',
53
- :event_registrants => 'eventspot/events/%s/registrants',
54
- :event_registrant => 'eventspot/events/%s/registrants/%s',
49
+ :events => 'eventspot/events',
50
+ :event => 'eventspot/events/%s',
51
+ :event_fees => 'eventspot/events/%s/fees',
52
+ :event_fee => 'eventspot/events/%s/fees/%s',
53
+ :event_registrants => 'eventspot/events/%s/registrants',
54
+ :event_registrant => 'eventspot/events/%s/registrants/%s',
55
+ :event_items => 'eventspot/events/%s/items',
56
+ :event_item => 'eventspot/events/%s/items/%s',
57
+ :event_item_attributes => 'eventspot/events/%s/items/%s/attributes',
58
+ :event_item_attribute => 'eventspot/events/%s/items/%s/attributes/%s',
59
+ :event_promocodes => 'eventspot/events/%s/promocodes',
60
+ :event_promocode => 'eventspot/events/%s/promocodes/%s',
55
61
 
56
62
  :contact_tracking_summary => 'contacts/%s/tracking/reports/summary',
57
63
  :contact_tracking_bounces => 'contacts/%s/tracking/bounces',
@@ -7,6 +7,6 @@
7
7
  module ConstantContact
8
8
  module SDK
9
9
  # Gem version
10
- VERSION = "1.1.2"
10
+ VERSION = "1.2.0"
11
11
  end
12
12
  end
@@ -311,19 +311,6 @@ describe ConstantContact::Api do
311
311
  end
312
312
  end
313
313
 
314
- describe "#delete_event" do
315
- it "deletes an event" do
316
- json = load_file('event.json')
317
-
318
- net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
319
- response = RestClient::Response.create('', net_http_resp, {})
320
- RestClient.stub(:delete).and_return(response)
321
-
322
- event = ConstantContact::Components::Event.create(JSON.parse(json))
323
- @api.delete_event('token', event).should be_true
324
- end
325
- end
326
-
327
314
  describe "#publish_event" do
328
315
  it "updates an event with status of ACTIVE" do
329
316
  json = load_file('event.json')
@@ -374,7 +361,7 @@ describe ConstantContact::Api do
374
361
  #fees.results.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
375
362
 
376
363
  fees.should be_kind_of(Array) # inconsistent with oether APIs.
377
- fees.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
364
+ fees.collect{|f| f.should be_kind_of(ConstantContact::Components::EventFee) }
378
365
  end
379
366
  end
380
367
 
@@ -388,9 +375,9 @@ describe ConstantContact::Api do
388
375
  RestClient.stub(:get).and_return(response)
389
376
 
390
377
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
391
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
378
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
392
379
  retrieved = @api.get_event_fee('token', event, fee)
393
- retrieved.should be_kind_of(ConstantContact::Components::Fee)
380
+ retrieved.should be_kind_of(ConstantContact::Components::EventFee)
394
381
  end
395
382
  end
396
383
 
@@ -404,9 +391,9 @@ describe ConstantContact::Api do
404
391
  RestClient.stub(:post).and_return(response)
405
392
 
406
393
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
407
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
394
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
408
395
  added = @api.add_event_fee('token', event, fee)
409
- added.should be_kind_of(ConstantContact::Components::Fee)
396
+ added.should be_kind_of(ConstantContact::Components::EventFee)
410
397
  added.id.should_not be_empty
411
398
  end
412
399
  end
@@ -423,9 +410,9 @@ describe ConstantContact::Api do
423
410
  RestClient.stub(:put).and_return(response)
424
411
 
425
412
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
426
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
413
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
427
414
  updated = @api.update_event_fee('token', event, fee)
428
- updated.should be_kind_of(ConstantContact::Components::Fee)
415
+ updated.should be_kind_of(ConstantContact::Components::EventFee)
429
416
  updated.fee.should_not eq(fee.fee)
430
417
  updated.fee.should eq(fee.fee + 1)
431
418
  end
@@ -441,7 +428,7 @@ describe ConstantContact::Api do
441
428
  RestClient.stub(:delete).and_return(response)
442
429
 
443
430
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
444
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
431
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
445
432
  @api.delete_event_fee('token', event, fee).should be_true
446
433
  end
447
434
  end
@@ -479,6 +466,219 @@ describe ConstantContact::Api do
479
466
  end
480
467
  end
481
468
 
469
+ describe "#get_event_items" do
470
+ it "returns an array of event items" do
471
+ json_response = load_file('event_items_response.json')
472
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
473
+
474
+ response = RestClient::Response.create(json_response, net_http_resp, {})
475
+ RestClient.stub(:get).and_return(response)
476
+
477
+ results = @api.get_event_items('token', 1)
478
+ results.should be_kind_of(Array)
479
+ results.first.should be_kind_of(ConstantContact::Components::EventItem)
480
+ results.first.name.should eq('Running Belt')
481
+ end
482
+ end
483
+
484
+ describe "#get_event_item" do
485
+ it "returns an event item" do
486
+ json = load_file('event_item_response.json')
487
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
488
+
489
+ response = RestClient::Response.create(json, net_http_resp, {})
490
+ RestClient.stub(:get).and_return(response)
491
+
492
+ result = @api.get_event_item('token', 1, 1)
493
+ result.should be_kind_of(ConstantContact::Components::EventItem)
494
+ result.name.should eq('Running Belt')
495
+ end
496
+ end
497
+
498
+ describe "#add_event_item" do
499
+ it "adds an event item" do
500
+ json = load_file('event_item_response.json')
501
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
502
+
503
+ response = RestClient::Response.create(json, net_http_resp, {})
504
+ RestClient.stub(:post).and_return(response)
505
+ event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
506
+
507
+ result = @api.add_event_item('token', 1, event_item)
508
+ result.should be_kind_of(ConstantContact::Components::EventItem)
509
+ result.name.should eq('Running Belt')
510
+ end
511
+ end
512
+
513
+ describe "#delete_event_item" do
514
+ it "deletes an event item" do
515
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
516
+
517
+ response = RestClient::Response.create('', net_http_resp, {})
518
+ RestClient.stub(:delete).and_return(response)
519
+
520
+ result = @api.delete_event_item('token', 1, 1)
521
+ result.should be_true
522
+ end
523
+ end
524
+
525
+ describe "#update_event_item" do
526
+ it "updates an event item" do
527
+ json = load_file('event_item_response.json')
528
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
529
+
530
+ response = RestClient::Response.create(json, net_http_resp, {})
531
+ RestClient.stub(:put).and_return(response)
532
+ event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
533
+
534
+ result = @api.update_event_item('token', 1, event_item)
535
+ result.should be_kind_of(ConstantContact::Components::EventItem)
536
+ result.name.should eq('Running Belt')
537
+ end
538
+ end
539
+
540
+ describe "#get_event_item_attributes" do
541
+ it "returns an array of event item attributes" do
542
+ json_response = load_file('event_item_attributes_response.json')
543
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
544
+
545
+ response = RestClient::Response.create(json_response, net_http_resp, {})
546
+ RestClient.stub(:get).and_return(response)
547
+
548
+ results = @api.get_event_item_attributes('token', 1, 1)
549
+ results.should be_kind_of(Array)
550
+ results.first.should be_kind_of(ConstantContact::Components::EventItemAttribute)
551
+ results.first.name.should eq('Royal Blue')
552
+ end
553
+ end
554
+
555
+ describe "#get_event_item_attribute" do
556
+ it "returns an event item attribute" do
557
+ json = load_file('event_item_attribute_response.json')
558
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
559
+
560
+ response = RestClient::Response.create(json, net_http_resp, {})
561
+ RestClient.stub(:get).and_return(response)
562
+
563
+ result = @api.get_event_item_attribute('token', 1, 1, 1)
564
+ result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
565
+ result.name.should eq('Hi-Vis Green')
566
+ end
567
+ end
568
+
569
+ describe "#add_event_item_attribute" do
570
+ it "adds an event item attribute" do
571
+ json = load_file('event_item_attribute_response.json')
572
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
573
+
574
+ response = RestClient::Response.create(json, net_http_resp, {})
575
+ RestClient.stub(:post).and_return(response)
576
+ event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
577
+
578
+ result = @api.add_event_item_attribute('token', 1, 1, event_item_attribute)
579
+ result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
580
+ result.name.should eq('Hi-Vis Green')
581
+ end
582
+ end
583
+
584
+ describe "#delete_event_item_attribute" do
585
+ it "deletes an event item attribute" do
586
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
587
+
588
+ response = RestClient::Response.create('', net_http_resp, {})
589
+ RestClient.stub(:delete).and_return(response)
590
+
591
+ result = @api.delete_event_item_attribute('token', 1, 1, 1)
592
+ result.should be_true
593
+ end
594
+ end
595
+
596
+ describe "#update_event_item_attribute" do
597
+ it "updates an event item attribute" do
598
+ json = load_file('event_item_attribute_response.json')
599
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
600
+
601
+ response = RestClient::Response.create(json, net_http_resp, {})
602
+ RestClient.stub(:put).and_return(response)
603
+ event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
604
+
605
+ result = @api.update_event_item_attribute('token', 1, 1, event_item_attribute)
606
+ result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
607
+ result.name.should eq('Hi-Vis Green')
608
+ end
609
+ end
610
+
611
+ describe "#get_promocodes" do
612
+ it "returns an array of promocodes" do
613
+ json_response = load_file('promocodes_response.json')
614
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
615
+
616
+ response = RestClient::Response.create(json_response, net_http_resp, {})
617
+ RestClient.stub(:get).and_return(response)
618
+
619
+ results = @api.get_promocodes('token', 1)
620
+ results.should be_kind_of(Array)
621
+ results.first.should be_kind_of(ConstantContact::Components::Promocode)
622
+ results.first.code_name.should eq('REDUCED_FEE')
623
+ end
624
+ end
625
+
626
+ describe "#get_promocode" do
627
+ it "returns a promocode" do
628
+ json = load_file('promocode_response.json')
629
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
630
+
631
+ response = RestClient::Response.create(json, net_http_resp, {})
632
+ RestClient.stub(:get).and_return(response)
633
+
634
+ result = @api.get_promocode('token', 1, 1)
635
+ result.should be_kind_of(ConstantContact::Components::Promocode)
636
+ result.code_name.should eq('TOTAL_FEE')
637
+ end
638
+ end
639
+
640
+ describe "#add_promocode" do
641
+ it "adds a promocode" do
642
+ json = load_file('promocode_response.json')
643
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
644
+
645
+ response = RestClient::Response.create(json, net_http_resp, {})
646
+ RestClient.stub(:post).and_return(response)
647
+ promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
648
+
649
+ result = @api.add_promocode('token', 1, promocode)
650
+ result.should be_kind_of(ConstantContact::Components::Promocode)
651
+ result.code_name.should eq('TOTAL_FEE')
652
+ end
653
+ end
654
+
655
+ describe "#delete_promocode" do
656
+ it "deletes a promocode" do
657
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
658
+
659
+ response = RestClient::Response.create('', net_http_resp, {})
660
+ RestClient.stub(:delete).and_return(response)
661
+
662
+ result = @api.delete_promocode('token', 1, 1)
663
+ result.should be_true
664
+ end
665
+ end
666
+
667
+ describe "#update_promocode" do
668
+ it "updates an event item" do
669
+ json = load_file('promocode_response.json')
670
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
671
+
672
+ response = RestClient::Response.create(json, net_http_resp, {})
673
+ RestClient.stub(:put).and_return(response)
674
+ promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
675
+
676
+ result = @api.update_promocode('token', 1, promocode)
677
+ result.should be_kind_of(ConstantContact::Components::Promocode)
678
+ result.code_name.should eq('TOTAL_FEE')
679
+ end
680
+ end
681
+
482
682
  describe "#get_email_campaigns" do
483
683
  it "gets a set of campaigns" do
484
684
  json_response = load_file('email_campaigns_response.json')
@@ -8,7 +8,7 @@ require 'spec_helper'
8
8
 
9
9
  describe ConstantContact::Services::EventSpotService do
10
10
  describe "#get_events" do
11
- it "returns an array of events" do
11
+ it "returns a set of events" do
12
12
  json = load_file('events.json')
13
13
  net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
14
14
 
@@ -48,18 +48,6 @@ describe ConstantContact::Services::EventSpotService do
48
48
  end
49
49
  end
50
50
 
51
- describe "#delete_event" do
52
- it "deletes an event" do
53
- json = load_file('event.json')
54
- net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
55
-
56
- response = RestClient::Response.create('', net_http_resp, {})
57
- RestClient.stub(:delete).and_return(response)
58
- event = ConstantContact::Components::Event.create(JSON.parse(json))
59
- ConstantContact::Services::EventSpotService.delete_event('token', event).should be_true
60
- end
61
- end
62
-
63
51
  describe "#publish_event" do
64
52
  it "updates an event with status of ACTIVE" do
65
53
  json = load_file('event.json')
@@ -110,7 +98,7 @@ describe ConstantContact::Services::EventSpotService do
110
98
  #fees.results.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
111
99
 
112
100
  fees.should be_kind_of(Array) # inconsistent with oether APIs.
113
- fees.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
101
+ fees.collect{|f| f.should be_kind_of(ConstantContact::Components::EventFee) }
114
102
  end
115
103
  end
116
104
 
@@ -124,9 +112,9 @@ describe ConstantContact::Services::EventSpotService do
124
112
  RestClient.stub(:get).and_return(response)
125
113
 
126
114
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
127
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
115
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
128
116
  retrieved = ConstantContact::Services::EventSpotService.get_fee('token', event, fee)
129
- retrieved.should be_kind_of(ConstantContact::Components::Fee)
117
+ retrieved.should be_kind_of(ConstantContact::Components::EventFee)
130
118
  end
131
119
  end
132
120
 
@@ -140,9 +128,9 @@ describe ConstantContact::Services::EventSpotService do
140
128
  RestClient.stub(:post).and_return(response)
141
129
 
142
130
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
143
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
131
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
144
132
  added = ConstantContact::Services::EventSpotService.add_fee('token', event, fee)
145
- added.should be_kind_of(ConstantContact::Components::Fee)
133
+ added.should be_kind_of(ConstantContact::Components::EventFee)
146
134
  added.id.should_not be_empty
147
135
  end
148
136
  end
@@ -159,9 +147,9 @@ describe ConstantContact::Services::EventSpotService do
159
147
  RestClient.stub(:put).and_return(response)
160
148
 
161
149
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
162
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
150
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
163
151
  updated = ConstantContact::Services::EventSpotService.update_fee('token', event, fee)
164
- updated.should be_kind_of(ConstantContact::Components::Fee)
152
+ updated.should be_kind_of(ConstantContact::Components::EventFee)
165
153
  updated.fee.should_not eq(fee.fee)
166
154
  updated.fee.should eq(fee.fee + 1)
167
155
  end
@@ -177,7 +165,7 @@ describe ConstantContact::Services::EventSpotService do
177
165
  RestClient.stub(:delete).and_return(response)
178
166
 
179
167
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
180
- fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
168
+ fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
181
169
  ConstantContact::Services::EventSpotService.delete_fee('token', event, fee).should be_true
182
170
  end
183
171
  end
@@ -214,4 +202,218 @@ describe ConstantContact::Services::EventSpotService do
214
202
  retrieved.id.should_not be_empty
215
203
  end
216
204
  end
205
+
206
+ describe "#get_event_items" do
207
+ it "returns an array of event items" do
208
+ json_response = load_file('event_items_response.json')
209
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
210
+
211
+ response = RestClient::Response.create(json_response, net_http_resp, {})
212
+ RestClient.stub(:get).and_return(response)
213
+
214
+ results = ConstantContact::Services::EventSpotService.get_event_items('token', 1)
215
+ results.should be_kind_of(Array)
216
+ results.first.should be_kind_of(ConstantContact::Components::EventItem)
217
+ results.first.name.should eq('Running Belt')
218
+ end
219
+ end
220
+
221
+ describe "#get_event_item" do
222
+ it "returns an event item" do
223
+ json = load_file('event_item_response.json')
224
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
225
+
226
+ response = RestClient::Response.create(json, net_http_resp, {})
227
+ RestClient.stub(:get).and_return(response)
228
+
229
+ result = ConstantContact::Services::EventSpotService.get_event_item('token', 1, 1)
230
+ result.should be_kind_of(ConstantContact::Components::EventItem)
231
+ result.name.should eq('Running Belt')
232
+ end
233
+ end
234
+
235
+ describe "#add_event_item" do
236
+ it "adds an event item" do
237
+ json = load_file('event_item_response.json')
238
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
239
+
240
+ response = RestClient::Response.create(json, net_http_resp, {})
241
+ RestClient.stub(:post).and_return(response)
242
+ event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
243
+
244
+ result = ConstantContact::Services::EventSpotService.add_event_item('token', 1, event_item)
245
+ result.should be_kind_of(ConstantContact::Components::EventItem)
246
+ result.name.should eq('Running Belt')
247
+ end
248
+ end
249
+
250
+ describe "#delete_event_item" do
251
+ it "deletes an event item" do
252
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
253
+
254
+ response = RestClient::Response.create('', net_http_resp, {})
255
+ RestClient.stub(:delete).and_return(response)
256
+
257
+ result = ConstantContact::Services::EventSpotService.delete_event_item('token', 1, 1)
258
+ result.should be_true
259
+ end
260
+ end
261
+
262
+ describe "#update_event_item" do
263
+ it "updates an event item" do
264
+ json = load_file('event_item_response.json')
265
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
266
+
267
+ response = RestClient::Response.create(json, net_http_resp, {})
268
+ RestClient.stub(:put).and_return(response)
269
+ event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
270
+
271
+ result = ConstantContact::Services::EventSpotService.update_event_item('token', 1, event_item)
272
+ result.should be_kind_of(ConstantContact::Components::EventItem)
273
+ result.name.should eq('Running Belt')
274
+ end
275
+ end
276
+
277
+ describe "#get_event_item_attributes" do
278
+ it "returns an array of event item attributes" do
279
+ json_response = load_file('event_item_attributes_response.json')
280
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
281
+
282
+ response = RestClient::Response.create(json_response, net_http_resp, {})
283
+ RestClient.stub(:get).and_return(response)
284
+
285
+ results = ConstantContact::Services::EventSpotService.get_event_item_attributes('token', 1, 1)
286
+ results.should be_kind_of(Array)
287
+ results.first.should be_kind_of(ConstantContact::Components::EventItemAttribute)
288
+ results.first.name.should eq('Royal Blue')
289
+ end
290
+ end
291
+
292
+ describe "#get_event_item_attribute" do
293
+ it "returns an event item attribute" do
294
+ json = load_file('event_item_attribute_response.json')
295
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
296
+
297
+ response = RestClient::Response.create(json, net_http_resp, {})
298
+ RestClient.stub(:get).and_return(response)
299
+
300
+ result = ConstantContact::Services::EventSpotService.get_event_item_attribute('token', 1, 1, 1)
301
+ result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
302
+ result.name.should eq('Hi-Vis Green')
303
+ end
304
+ end
305
+
306
+ describe "#add_event_item_attribute" do
307
+ it "adds an event item attribute" do
308
+ json = load_file('event_item_attribute_response.json')
309
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
310
+
311
+ response = RestClient::Response.create(json, net_http_resp, {})
312
+ RestClient.stub(:post).and_return(response)
313
+ event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
314
+
315
+ result = ConstantContact::Services::EventSpotService.add_event_item_attribute('token', 1, 1, event_item_attribute)
316
+ result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
317
+ result.name.should eq('Hi-Vis Green')
318
+ end
319
+ end
320
+
321
+ describe "#delete_event_item_attribute" do
322
+ it "deletes an event item attribute" do
323
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
324
+
325
+ response = RestClient::Response.create('', net_http_resp, {})
326
+ RestClient.stub(:delete).and_return(response)
327
+
328
+ result = ConstantContact::Services::EventSpotService.delete_event_item_attribute('token', 1, 1, 1)
329
+ result.should be_true
330
+ end
331
+ end
332
+
333
+ describe "#update_event_item_attribute" do
334
+ it "updates an event item attribute" do
335
+ json = load_file('event_item_attribute_response.json')
336
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
337
+
338
+ response = RestClient::Response.create(json, net_http_resp, {})
339
+ RestClient.stub(:put).and_return(response)
340
+ event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
341
+
342
+ result = ConstantContact::Services::EventSpotService.update_event_item_attribute('token', 1, 1, event_item_attribute)
343
+ result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
344
+ result.name.should eq('Hi-Vis Green')
345
+ end
346
+ end
347
+
348
+ describe "#get_promocodes" do
349
+ it "returns an array of promocodes" do
350
+ json_response = load_file('promocodes_response.json')
351
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
352
+
353
+ response = RestClient::Response.create(json_response, net_http_resp, {})
354
+ RestClient.stub(:get).and_return(response)
355
+
356
+ results = ConstantContact::Services::EventSpotService.get_promocodes('token', 1)
357
+ results.should be_kind_of(Array)
358
+ results.first.should be_kind_of(ConstantContact::Components::Promocode)
359
+ results.first.code_name.should eq('REDUCED_FEE')
360
+ end
361
+ end
362
+
363
+ describe "#get_promocode" do
364
+ it "returns a promocode" do
365
+ json = load_file('promocode_response.json')
366
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
367
+
368
+ response = RestClient::Response.create(json, net_http_resp, {})
369
+ RestClient.stub(:get).and_return(response)
370
+
371
+ result = ConstantContact::Services::EventSpotService.get_promocode('token', 1, 1)
372
+ result.should be_kind_of(ConstantContact::Components::Promocode)
373
+ result.code_name.should eq('TOTAL_FEE')
374
+ end
375
+ end
376
+
377
+ describe "#add_promocode" do
378
+ it "adds a promocode" do
379
+ json = load_file('promocode_response.json')
380
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
381
+
382
+ response = RestClient::Response.create(json, net_http_resp, {})
383
+ RestClient.stub(:post).and_return(response)
384
+ promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
385
+
386
+ result = ConstantContact::Services::EventSpotService.add_promocode('token', 1, promocode)
387
+ result.should be_kind_of(ConstantContact::Components::Promocode)
388
+ result.code_name.should eq('TOTAL_FEE')
389
+ end
390
+ end
391
+
392
+ describe "#delete_promocode" do
393
+ it "deletes a promocode" do
394
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
395
+
396
+ response = RestClient::Response.create('', net_http_resp, {})
397
+ RestClient.stub(:delete).and_return(response)
398
+
399
+ result = ConstantContact::Services::EventSpotService.delete_promocode('token', 1, 1)
400
+ result.should be_true
401
+ end
402
+ end
403
+
404
+ describe "#update_promocode" do
405
+ it "updates an event item" do
406
+ json = load_file('promocode_response.json')
407
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
408
+
409
+ response = RestClient::Response.create(json, net_http_resp, {})
410
+ RestClient.stub(:put).and_return(response)
411
+ promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
412
+
413
+ result = ConstantContact::Services::EventSpotService.update_promocode('token', 1, promocode)
414
+ result.should be_kind_of(ConstantContact::Components::Promocode)
415
+ result.code_name.should eq('TOTAL_FEE')
416
+ end
417
+ end
418
+
217
419
  end