constantcontact 1.0.0 → 1.0.1

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 (60) hide show
  1. checksums.yaml +7 -7
  2. data/README.md +7 -0
  3. data/constantcontact.gemspec +1 -1
  4. data/lib/constantcontact.rb +54 -54
  5. data/lib/constantcontact/api.rb +5 -3
  6. data/lib/constantcontact/auth/oauth2.rb +7 -4
  7. data/lib/constantcontact/auth/session_data_store.rb +52 -52
  8. data/lib/constantcontact/components/account/verified_email_address.rb +17 -17
  9. data/lib/constantcontact/components/activities/activity.rb +34 -34
  10. data/lib/constantcontact/components/activities/activity_error.rb +17 -17
  11. data/lib/constantcontact/components/activities/add_contacts.rb +109 -109
  12. data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -37
  13. data/lib/constantcontact/components/activities/export_contacts.rb +19 -19
  14. data/lib/constantcontact/components/component.rb +13 -13
  15. data/lib/constantcontact/components/contacts/address.rb +18 -18
  16. data/lib/constantcontact/components/contacts/contact.rb +69 -69
  17. data/lib/constantcontact/components/contacts/contact_list.rb +17 -17
  18. data/lib/constantcontact/components/contacts/custom_field.rb +17 -17
  19. data/lib/constantcontact/components/contacts/email_address.rb +23 -23
  20. data/lib/constantcontact/components/contacts/note.rb +16 -16
  21. data/lib/constantcontact/components/email_marketing/campaign.rb +67 -67
  22. data/lib/constantcontact/components/email_marketing/click_through_details.rb +17 -17
  23. data/lib/constantcontact/components/email_marketing/message_footer.rb +20 -20
  24. data/lib/constantcontact/components/email_marketing/schedule.rb +18 -18
  25. data/lib/constantcontact/components/email_marketing/test_send.rb +32 -32
  26. data/lib/constantcontact/components/result_set.rb +15 -15
  27. data/lib/constantcontact/components/tracking/bounce_activity.rb +18 -18
  28. data/lib/constantcontact/components/tracking/click_activity.rb +17 -17
  29. data/lib/constantcontact/components/tracking/forward_activity.rb +17 -17
  30. data/lib/constantcontact/components/tracking/open_activity.rb +17 -17
  31. data/lib/constantcontact/components/tracking/send_activity.rb +17 -17
  32. data/lib/constantcontact/components/tracking/tracking_activity.rb +15 -15
  33. data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
  34. data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +18 -18
  35. data/lib/constantcontact/exceptions/ctct_exception.rb +15 -15
  36. data/lib/constantcontact/exceptions/illegal_argument_exception.rb +3 -3
  37. data/lib/constantcontact/exceptions/oauth2_exception.rb +3 -3
  38. data/lib/constantcontact/services/account_service.rb +19 -19
  39. data/lib/constantcontact/services/activity_service.rb +99 -99
  40. data/lib/constantcontact/services/base_service.rb +24 -24
  41. data/lib/constantcontact/services/campaign_schedule_service.rb +85 -85
  42. data/lib/constantcontact/services/campaign_tracking_service.rb +151 -151
  43. data/lib/constantcontact/services/contact_service.rb +106 -106
  44. data/lib/constantcontact/services/contact_tracking_service.rb +151 -151
  45. data/lib/constantcontact/services/email_marketing_service.rb +66 -66
  46. data/lib/constantcontact/services/list_service.rb +67 -67
  47. data/lib/constantcontact/util/config.rb +102 -96
  48. data/lib/constantcontact/util/helpers.rb +18 -18
  49. data/lib/constantcontact/version.rb +4 -4
  50. data/spec/constantcontact/api_spec.rb +223 -173
  51. data/spec/constantcontact/auth/oauth2_spec.rb +68 -4
  52. data/spec/constantcontact/components/contacts/address_spec.rb +7 -7
  53. data/spec/constantcontact/components/contacts/contact_list_spec.rb +7 -7
  54. data/spec/constantcontact/components/contacts/contact_spec.rb +7 -7
  55. data/spec/constantcontact/components/contacts/custom_field_spec.rb +7 -7
  56. data/spec/constantcontact/components/contacts/email_address_spec.rb +7 -7
  57. data/spec/constantcontact/services/contact_service_spec.rb +95 -95
  58. data/spec/constantcontact/services/list_service_spec.rb +48 -48
  59. data/spec/spec_helper.rb +1 -1
  60. metadata +55 -44
@@ -5,41 +5,41 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class TestSend < Component
10
- attr_accessor :format, :personal_message, :email_addresses
8
+ module Components
9
+ class TestSend < Component
10
+ attr_accessor :format, :personal_message, :email_addresses
11
11
 
12
12
 
13
- # Factory method to create a TestSend object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [TestSend]
16
- def self.create(props)
17
- test_send = TestSend.new
18
- if props
19
- props.each do |key, value|
20
- if key == 'email_addresses'
21
- if value
22
- test_send.email_addresses = []
23
- value.each do |email_address|
24
- test_send.email_addresses << email_address
25
- end
26
- end
27
- else
28
- test_send.send("#{key}=", value)
29
- end
30
- end
31
- end
32
- test_send
33
- end
13
+ # Factory method to create a TestSend object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [TestSend]
16
+ def self.create(props)
17
+ test_send = TestSend.new
18
+ if props
19
+ props.each do |key, value|
20
+ if key == 'email_addresses'
21
+ if value
22
+ test_send.email_addresses = []
23
+ value.each do |email_address|
24
+ test_send.email_addresses << email_address
25
+ end
26
+ end
27
+ else
28
+ test_send.send("#{key}=", value)
29
+ end
30
+ end
31
+ end
32
+ test_send
33
+ end
34
34
 
35
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
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
42
 
43
- end
44
- end
43
+ end
44
+ end
45
45
  end
@@ -5,23 +5,23 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class ResultSet
10
- attr_accessor :results, :next
8
+ module Components
9
+ class ResultSet
10
+ attr_accessor :results, :next
11
11
 
12
12
 
13
- # Constructor to create a ResultSet from the results/meta response when performing a get on a collection
14
- # @param [Array<Hash>] results - results array from request
15
- # @param [Hash] meta - meta hash from request
16
- def initialize(results, meta)
17
- @results = results
13
+ # Constructor to create a ResultSet from the results/meta response when performing a get on a collection
14
+ # @param [Array<Hash>] results - results array from request
15
+ # @param [Hash] meta - meta hash from request
16
+ def initialize(results, meta)
17
+ @results = results
18
18
 
19
- if meta.has_key?('pagination') and meta['pagination'].has_key?('next_link')
20
- next_link = meta['pagination']['next_link']
21
- @next = next_link[next_link.index('?'), next_link.length]
22
- end
23
- end
19
+ if meta.has_key?('pagination') and meta['pagination'].has_key?('next_link')
20
+ next_link = meta['pagination']['next_link']
21
+ @next = next_link[next_link.index('?'), next_link.length]
22
+ end
23
+ end
24
24
 
25
- end
26
- end
25
+ end
26
+ end
27
27
  end
@@ -5,25 +5,25 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class BounceActivity < Component
10
- attr_accessor :activity_type, :bounce_code, :bounce_description, :bounce_message, :bounce_date,
11
- :contact_id, :email_address, :campaign_id
8
+ module Components
9
+ class BounceActivity < Component
10
+ attr_accessor :activity_type, :bounce_code, :bounce_description, :bounce_message, :bounce_date,
11
+ :contact_id, :email_address, :campaign_id
12
12
 
13
13
 
14
- # Factory method to create a BounceActivity object from an array
15
- # @param [Hash] props - hash of properties to create object from
16
- # @return [BounceActivity]
17
- def self.create(props)
18
- bounce_activity = BounceActivity.new
19
- if props
20
- props.each do |key, value|
21
- bounce_activity.send("#{key}=", value)
22
- end
23
- end
24
- bounce_activity
25
- end
14
+ # Factory method to create a BounceActivity object from an array
15
+ # @param [Hash] props - hash of properties to create object from
16
+ # @return [BounceActivity]
17
+ def self.create(props)
18
+ bounce_activity = BounceActivity.new
19
+ if props
20
+ props.each do |key, value|
21
+ bounce_activity.send("#{key}=", value)
22
+ end
23
+ end
24
+ bounce_activity
25
+ end
26
26
 
27
- end
28
- end
27
+ end
28
+ end
29
29
  end
@@ -5,24 +5,24 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class ClickActivity < Component
10
- attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :link_id, :click_date
8
+ module Components
9
+ class ClickActivity < Component
10
+ attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :link_id, :click_date
11
11
 
12
12
 
13
- # Factory method to create a ClickActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [ClickActivity]
16
- def self.create(props)
17
- click_activity = ClickActivity.new
18
- if props
19
- props.each do |key, value|
20
- click_activity.send("#{key}=", value)
21
- end
22
- end
23
- click_activity
24
- end
13
+ # Factory method to create a ClickActivity object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [ClickActivity]
16
+ def self.create(props)
17
+ click_activity = ClickActivity.new
18
+ if props
19
+ props.each do |key, value|
20
+ click_activity.send("#{key}=", value)
21
+ end
22
+ end
23
+ click_activity
24
+ end
25
25
 
26
- end
27
- end
26
+ end
27
+ end
28
28
  end
@@ -5,24 +5,24 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class ForwardActivity < Component
10
- attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :forward_date
8
+ module Components
9
+ class ForwardActivity < Component
10
+ attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :forward_date
11
11
 
12
12
 
13
- # Factory method to create a ForwardActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [ForwardActivity]
16
- def self.create(props)
17
- forward_activity = ForwardActivity.new
18
- if props
19
- props.each do |key, value|
20
- forward_activity.send("#{key}=", value)
21
- end
22
- end
23
- forward_activity
24
- end
13
+ # Factory method to create a ForwardActivity object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [ForwardActivity]
16
+ def self.create(props)
17
+ forward_activity = ForwardActivity.new
18
+ if props
19
+ props.each do |key, value|
20
+ forward_activity.send("#{key}=", value)
21
+ end
22
+ end
23
+ forward_activity
24
+ end
25
25
 
26
- end
27
- end
26
+ end
27
+ end
28
28
  end
@@ -5,24 +5,24 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class OpenActivity < Component
10
- attr_accessor :activity_type, :campaign_id, :email_address, :open_date, :contact_id
8
+ module Components
9
+ class OpenActivity < Component
10
+ attr_accessor :activity_type, :campaign_id, :email_address, :open_date, :contact_id
11
11
 
12
12
 
13
- # Factory method to create an OpenActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [OpenActivity]
16
- def self.create(props)
17
- open_activity = OpenActivity.new
18
- if props
19
- props.each do |key, value|
20
- open_activity.send("#{key}=", value)
21
- end
22
- end
23
- open_activity
24
- end
13
+ # Factory method to create an OpenActivity object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [OpenActivity]
16
+ def self.create(props)
17
+ open_activity = OpenActivity.new
18
+ if props
19
+ props.each do |key, value|
20
+ open_activity.send("#{key}=", value)
21
+ end
22
+ end
23
+ open_activity
24
+ end
25
25
 
26
- end
27
- end
26
+ end
27
+ end
28
28
  end
@@ -5,24 +5,24 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class SendActivity < Component
10
- attr_accessor :activity_type, :campaign_id, :email_address, :contact_id, :send_date
8
+ module Components
9
+ class SendActivity < Component
10
+ attr_accessor :activity_type, :campaign_id, :email_address, :contact_id, :send_date
11
11
 
12
12
 
13
- # Factory method to create a SendActivity object from an array
14
- # @param [Hash] props - hash of properties to create object from
15
- # @return [SendActivity]
16
- def self.create(props)
17
- send_activity = SendActivity.new
18
- if props
19
- props.each do |key, value|
20
- send_activity.send("#{key}=", value)
21
- end
22
- end
23
- send_activity
24
- end
13
+ # Factory method to create a SendActivity object from an array
14
+ # @param [Hash] props - hash of properties to create object from
15
+ # @return [SendActivity]
16
+ def self.create(props)
17
+ send_activity = SendActivity.new
18
+ if props
19
+ props.each do |key, value|
20
+ send_activity.send("#{key}=", value)
21
+ end
22
+ end
23
+ send_activity
24
+ end
25
25
 
26
- end
27
- end
26
+ end
27
+ end
28
28
  end
@@ -5,23 +5,23 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class TrackingActivity < Component
10
- attr_accessor :results, :next
8
+ module Components
9
+ class TrackingActivity < Component
10
+ attr_accessor :results, :next
11
11
 
12
12
 
13
- # Constructor to create a TrackingActivity from the results/pagination response from getting a set of activities
14
- # @param [Array] results - results array from a tracking endpoint
15
- # @param [Hash] pagination - pagination hash returned from a tracking endpoint
16
- # @return [TrackingActivity]
17
- def initialize(results, pagination)
18
- @results = results
13
+ # Constructor to create a TrackingActivity from the results/pagination response from getting a set of activities
14
+ # @param [Array] results - results array from a tracking endpoint
15
+ # @param [Hash] pagination - pagination hash returned from a tracking endpoint
16
+ # @return [TrackingActivity]
17
+ def initialize(results, pagination)
18
+ @results = results
19
19
 
20
- if (pagination.has_key?('next'))
21
- @next = pagination['next'][pagination['next'].index('&next=') + 6, pagination['next'].length]
22
- end
23
- end
20
+ if (pagination.has_key?('next'))
21
+ @next = pagination['next'][pagination['next'].index('&next=') + 6, pagination['next'].length]
22
+ end
23
+ end
24
24
 
25
- end
26
- end
25
+ end
26
+ end
27
27
  end
@@ -5,24 +5,24 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class TrackingSummary < Component
10
- attr_accessor :sends, :opens, :clicks, :forwards, :unsubscribes, :bounces, :contact_id
8
+ module Components
9
+ class TrackingSummary < Component
10
+ attr_accessor :sends, :opens, :clicks, :forwards, :unsubscribes, :bounces, :contact_id
11
11
 
12
12
 
13
- # Factory method to create a TrackingSummary object from an array
14
- # @param [Hash] props - array of properties to create object from
15
- # @return [TrackingSummary]
16
- def self.create(props)
17
- tracking_summary = TrackingSummary.new
18
- if props
19
- props.each do |key, value|
20
- tracking_summary.send("#{key}=", value)
21
- end
22
- end
23
- tracking_summary
24
- end
13
+ # Factory method to create a TrackingSummary object from an array
14
+ # @param [Hash] props - array of properties to create object from
15
+ # @return [TrackingSummary]
16
+ def self.create(props)
17
+ tracking_summary = TrackingSummary.new
18
+ if props
19
+ props.each do |key, value|
20
+ tracking_summary.send("#{key}=", value)
21
+ end
22
+ end
23
+ tracking_summary
24
+ end
25
25
 
26
- end
27
- end
26
+ end
27
+ end
28
28
  end
@@ -5,25 +5,25 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Components
9
- class UnsubscribeActivity < Component
10
- attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :unsubscribe_date,
11
- :unsubscribe_source, :unsubscribe_reason
8
+ module Components
9
+ class UnsubscribeActivity < Component
10
+ attr_accessor :activity_type, :campaign_id, :contact_id, :email_address, :unsubscribe_date,
11
+ :unsubscribe_source, :unsubscribe_reason
12
12
 
13
13
 
14
- # Factory method to create an UnsubscribeActivity object from an array
15
- # @param [Hash] props - hash of properties to create object from
16
- # @return [UnsubscribeActivity]
17
- def self.create(props)
18
- unsubscribe_activity = UnsubscribeActivity.new
19
- if props
20
- props.each do |key, value|
21
- unsubscribe_activity.send("#{key}=", value)
22
- end
23
- end
24
- unsubscribe_activity
25
- end
14
+ # Factory method to create an UnsubscribeActivity object from an array
15
+ # @param [Hash] props - hash of properties to create object from
16
+ # @return [UnsubscribeActivity]
17
+ def self.create(props)
18
+ unsubscribe_activity = UnsubscribeActivity.new
19
+ if props
20
+ props.each do |key, value|
21
+ unsubscribe_activity.send("#{key}=", value)
22
+ end
23
+ end
24
+ unsubscribe_activity
25
+ end
26
26
 
27
- end
28
- end
27
+ end
28
+ end
29
29
  end