constantcontact 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +127 -136
- data/constantcontact.gemspec +4 -3
- data/lib/constantcontact.rb +63 -44
- data/lib/constantcontact/api.rb +932 -535
- data/lib/constantcontact/auth/oauth2.rb +86 -66
- data/lib/constantcontact/components/account/verified_email_address.rb +14 -14
- data/lib/constantcontact/components/activities/activity.rb +30 -30
- data/lib/constantcontact/components/activities/activity_error.rb +14 -14
- data/lib/constantcontact/components/activities/add_contacts.rb +1 -1
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -36
- data/lib/constantcontact/components/component.rb +25 -0
- data/lib/constantcontact/components/contacts/address.rb +12 -12
- data/lib/constantcontact/components/contacts/contact.rb +50 -44
- data/lib/constantcontact/components/contacts/contact_list.rb +12 -12
- data/lib/constantcontact/components/contacts/custom_field.rb +14 -14
- data/lib/constantcontact/components/contacts/email_address.rb +14 -14
- data/lib/constantcontact/components/contacts/note.rb +13 -13
- data/lib/constantcontact/components/email_marketing/campaign.rb +41 -41
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +14 -14
- data/lib/constantcontact/components/email_marketing/message_footer.rb +14 -14
- data/lib/constantcontact/components/email_marketing/schedule.rb +14 -15
- data/lib/constantcontact/components/email_marketing/test_send.rb +21 -21
- data/lib/constantcontact/components/event_spot/contact.rb +27 -0
- data/lib/constantcontact/components/event_spot/event.rb +63 -0
- data/lib/constantcontact/components/event_spot/event_track.rb +28 -0
- data/lib/constantcontact/components/event_spot/fee.rb +27 -0
- data/lib/constantcontact/components/event_spot/guest.rb +31 -0
- data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
- data/lib/constantcontact/components/event_spot/promo_code.rb +26 -0
- data/lib/constantcontact/components/event_spot/registrant.rb +54 -0
- data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/sale_item.rb +27 -0
- data/lib/constantcontact/components/library/file/library_file.rb +27 -0
- data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
- data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
- data/lib/constantcontact/components/library/info/move_results.rb +26 -0
- data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
- data/lib/constantcontact/components/tracking/bounce_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/click_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/forward_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/open_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/send_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +14 -14
- data/lib/constantcontact/services/account_service.rb +4 -3
- data/lib/constantcontact/services/activity_service.rb +40 -3
- data/lib/constantcontact/services/base_service.rb +34 -6
- data/lib/constantcontact/services/campaign_tracking_service.rb +20 -20
- data/lib/constantcontact/services/contact_service.rb +10 -12
- data/lib/constantcontact/services/contact_tracking_service.rb +20 -20
- data/lib/constantcontact/services/email_marketing_service.rb +8 -10
- data/lib/constantcontact/services/event_spot_service.rb +254 -0
- data/lib/constantcontact/services/library_service.rb +297 -0
- data/lib/constantcontact/services/list_service.rb +6 -5
- data/lib/constantcontact/util/config.rb +135 -117
- data/lib/constantcontact/version.rb +1 -1
- data/spec/constantcontact/api_spec.rb +1223 -173
- data/spec/constantcontact/auth/oauth2_spec.rb +60 -47
- data/spec/constantcontact/components/contacts/address_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/contact_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/email_address_spec.rb +1 -1
- data/spec/constantcontact/services/activity_service_spec.rb +201 -0
- data/spec/constantcontact/services/base_service_spec.rb +27 -0
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +111 -0
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +127 -0
- data/spec/constantcontact/services/contact_service_spec.rb +24 -22
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +127 -0
- data/spec/constantcontact/services/email_marketing_spec.rb +72 -66
- data/spec/constantcontact/services/event_spot_spec.rb +217 -0
- data/spec/constantcontact/services/library_service_spec.rb +248 -0
- data/spec/constantcontact/services/list_service_spec.rb +33 -17
- data/spec/spec_helper.rb +3 -1
- metadata +63 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c4cc9d1ea9b203b5ca089c9da4b644f42c8ee9f
|
4
|
+
data.tar.gz: 8f618777d2131ad9e2bd55f5a97016e6d7b25849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 048e7ffe96661bf3941f9fa76287ad9463cf93b7eb92cbfadc00bdc526b7905c4f5ccf08615b0d4d5461e78c719fdb26468706746ebf64b1e8de89c2aac7da80
|
7
|
+
data.tar.gz: c1671514b610d40ee3cec33bad16652665ccd87a4b0b4610deb370187492ffb9c39140725297af8fbed716b6ab37c9c76ba925c46d4419620007df87a8d767e7
|
data/README.md
CHANGED
@@ -1,139 +1,130 @@
|
|
1
|
-
Constant Contact Ruby SDK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
1
|
+
Constant Contact Ruby SDK for AppConnect
|
2
|
+
====
|
3
|
+
|
4
|
+
The Ruby SDK for AppConnect allows you to leverage the AppConnect v2 APIs.
|
5
|
+
|
6
|
+
[![Build Status](https://travis-ci.org/constantcontact/ruby-sdk.png)](https://travis-ci.org/constantcontact/ruby-sdk)
|
7
|
+
|
8
|
+
Installation
|
9
|
+
====
|
10
|
+
Via bundler:
|
11
|
+
```ruby
|
12
|
+
gem 'constantcontact', '~> 1.1.0'
|
13
|
+
```
|
14
|
+
Otherwise:
|
15
|
+
```bash
|
16
|
+
[sudo|rvm] gem install constantcontact
|
17
|
+
```
|
18
|
+
|
19
|
+
Configuration
|
20
|
+
====
|
21
|
+
The AppConnect SDK can be configured with some options globally or they can be specified when creating the API client:
|
22
|
+
```ruby
|
23
|
+
ConstantContact::Util::Config.configure do |config|
|
24
|
+
config[:auth][:api_key] = 'your-access-key'
|
25
|
+
config[:auth][:api_secret] = 'your-access-secret'
|
26
|
+
config[:auth][:redirect_uri] = 'https://example.com/auth/constantcontact'
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
Getting Started
|
31
|
+
====
|
32
|
+
AppConnect requires an OAuth access token which will give your app access to Constant Contact data and services for the accout that granted that access token.
|
33
|
+
|
34
|
+
Rails
|
35
|
+
=====
|
36
|
+
Create a new controller action. The redirect_url should be the same as the one given when registering the app with Mashery. Use the following code snippet to get an access token:
|
37
|
+
```ruby
|
38
|
+
@oauth = ConstantContact::Auth::OAuth2.new(
|
39
|
+
:api_key => 'your api key',
|
40
|
+
:api_secret => 'your secret key',
|
41
|
+
:redirect_url => 'your redirect url' # the URL given when registering your app with Mashery.
|
42
|
+
)
|
43
|
+
|
44
|
+
@error = params[:error]
|
45
|
+
@user = params[:username]
|
46
|
+
@code = params[:code]
|
47
|
+
|
48
|
+
if @code.present?
|
49
|
+
response = @oauth.get_access_token(@code)
|
50
|
+
if response.present?
|
51
|
+
token = response['access_token']
|
52
|
+
cc = ConstantContact::Api.new('your api key')
|
53
|
+
@contacts = cc.get_contacts(token)
|
54
|
+
end
|
55
|
+
else
|
56
|
+
# if not code param is provided redirect into the OAuth flow
|
57
|
+
redirect_to @oauth.get_authorization_url and return
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Create a view for the above mentioned action with the following code:
|
62
|
+
```erb
|
63
|
+
|
64
|
+
<% if @error %>
|
65
|
+
<p><%= @error %></p>
|
66
|
+
<% end %>
|
67
|
+
|
68
|
+
<% if @contacts.present? %>
|
69
|
+
<% @contacts.each do |contact| %>
|
70
|
+
<p>Contact name: <%= "#{contact.first_name} #{contact.last_name}" %></p>
|
71
|
+
<% end %>
|
72
|
+
<% end %>
|
73
|
+
```
|
74
|
+
|
75
|
+
The first time you access the action you will be redirected into the Constant Contact OAuth flow.
|
76
|
+
Then you will be redirected back to your action and you should see the list of contacts.
|
77
|
+
|
78
|
+
Sinatra
|
79
|
+
=====
|
80
|
+
Require AppConnect:
|
81
|
+
```ruby
|
82
|
+
require 'constantcontact'
|
83
|
+
```
|
84
|
+
|
85
|
+
Add the following route. The redirect_url should be the same given when registering the app with Mashery.
|
86
|
+
```ruby
|
87
|
+
get '/my_url' do
|
88
|
+
@oauth = ConstantContact::Auth::OAuth2.new(
|
89
|
+
:api_key => 'your api key',
|
90
|
+
:api_secret => 'your secret key',
|
91
|
+
:redirect_url => 'your redirect url'
|
92
|
+
)
|
93
|
+
|
94
|
+
@error = params[:error]
|
95
|
+
@user = params[:username]
|
96
|
+
@code = params[:code]
|
97
|
+
|
98
|
+
if @code
|
99
|
+
response = @oauth.get_access_token(@code)
|
100
|
+
if response
|
101
|
+
token = response['access_token']
|
102
|
+
cc = ConstantContact::Api.new('your api key')
|
103
|
+
@contacts = cc.get_contacts(token)
|
78
104
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
response = @oauth.get_access_token(@code)
|
104
|
-
if response
|
105
|
-
token = response['access_token']
|
106
|
-
cc = ConstantContact::Api.new('your api key')
|
107
|
-
@contacts = cc.get_contacts(token)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
erb :my_view
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
Note: 'your redirect url' is the URL of the route you just created ( get '/my_url' ).
|
116
|
-
|
117
|
-
4. Create a my_view.rhtml (or my_view.erb) with the following code:
|
118
|
-
|
119
|
-
<% if @error %>
|
120
|
-
<p>
|
121
|
-
<%=@error%>
|
122
|
-
</p>
|
123
|
-
<% end %>
|
124
|
-
|
125
|
-
<% if @code %>
|
126
|
-
<% if @contacts %>
|
127
|
-
<% for contact in @contacts %>
|
128
|
-
<p>
|
129
|
-
Contact name: <%= contact.first_name + contact.last_name %>
|
130
|
-
</p>
|
131
|
-
<% end %>
|
132
|
-
<% end %>
|
133
|
-
<% else %>
|
134
|
-
<a href="<%=@oauth.get_authorization_url%>">Click to authorize</a>
|
135
|
-
<% end %>
|
136
|
-
|
137
|
-
5. The first time you access the action in browser you should see the "Click to authorize" link.
|
105
|
+
end
|
106
|
+
|
107
|
+
erb :my_view
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
Create a my_view.erb with the following code:
|
112
|
+
```ruby
|
113
|
+
<% if @error %>
|
114
|
+
<p><%=@error%></p>
|
115
|
+
<% end %>
|
116
|
+
|
117
|
+
<% if @code %>
|
118
|
+
<% if @contacts %>
|
119
|
+
<% @contacts.each do |contact| %>
|
120
|
+
<p>\Contact name: <%= "#{contact.first_name} #{contact.last_name}" %></p>
|
121
|
+
<% end %>
|
122
|
+
<% end %>
|
123
|
+
<% else %>
|
124
|
+
<a href="<%=@oauth.get_authorization_url%>">Click to authorize</a>
|
125
|
+
<% end %>
|
126
|
+
```
|
127
|
+
|
128
|
+
The first time you access the action in browser you should see the "Click to authorize" link.
|
138
129
|
Follow the link, go through all the Constant Contact steps required
|
139
130
|
and then you will be redirected back to your action and you should see the list of contacts.
|
data/constantcontact.gemspec
CHANGED
@@ -21,11 +21,12 @@ Gem::Specification.new do |s|
|
|
21
21
|
'README.md'
|
22
22
|
]
|
23
23
|
s.files += Dir['lib/**/*.rb']
|
24
|
-
s.files += Dir['spec/**/*.rb']
|
25
24
|
s.executables = []
|
26
|
-
s.require_paths = [ "lib"
|
27
|
-
|
25
|
+
s.require_paths = [ "lib" ]
|
26
|
+
s.test_files = Dir['spec/**/*.rb']
|
27
|
+
|
28
28
|
s.add_dependency("rest-client")
|
29
29
|
s.add_dependency("json")
|
30
|
+
s.add_dependency('mime-types', ['1.25.1'])
|
30
31
|
s.add_development_dependency("rspec")
|
31
32
|
end
|
data/lib/constantcontact.rb
CHANGED
@@ -13,63 +13,82 @@ require 'cgi/session/pstore'
|
|
13
13
|
|
14
14
|
|
15
15
|
module ConstantContact
|
16
|
-
autoload :Api,
|
16
|
+
autoload :Api, 'constantcontact/api'
|
17
17
|
|
18
18
|
module Auth
|
19
|
-
autoload :OAuth2,
|
20
|
-
autoload :Session,
|
19
|
+
autoload :OAuth2, 'constantcontact/auth/oauth2'
|
20
|
+
autoload :Session, 'constantcontact/auth/session_data_store'
|
21
21
|
end
|
22
22
|
|
23
23
|
module Components
|
24
|
-
autoload :Component,
|
25
|
-
autoload :ResultSet,
|
26
|
-
autoload :Activity,
|
27
|
-
autoload :ActivityError,
|
28
|
-
autoload :AddContacts,
|
29
|
-
autoload :AddContactsImportData,
|
30
|
-
autoload :ExportContacts,
|
31
|
-
autoload :Address,
|
32
|
-
autoload :Contact,
|
33
|
-
autoload :ContactList,
|
34
|
-
autoload :CustomField,
|
35
|
-
autoload :EmailAddress,
|
36
|
-
autoload :Note,
|
37
|
-
autoload :ClickThroughDetails,
|
38
|
-
autoload :Campaign,
|
39
|
-
autoload :MessageFooter,
|
40
|
-
autoload :Schedule,
|
41
|
-
autoload :TestSend,
|
42
|
-
autoload :BounceActivity,
|
43
|
-
autoload :ClickActivity,
|
44
|
-
autoload :ForwardActivity,
|
45
|
-
autoload :OpenActivity,
|
46
|
-
autoload :
|
47
|
-
autoload :SendActivity,
|
48
|
-
autoload :TrackingActivity,
|
49
|
-
autoload :TrackingSummary,
|
50
|
-
autoload :VerifiedEmailAddress,
|
24
|
+
autoload :Component, 'constantcontact/components/component'
|
25
|
+
autoload :ResultSet, 'constantcontact/components/result_set'
|
26
|
+
autoload :Activity, 'constantcontact/components/activities/activity'
|
27
|
+
autoload :ActivityError, 'constantcontact/components/activities/activity_error'
|
28
|
+
autoload :AddContacts, 'constantcontact/components/activities/add_contacts'
|
29
|
+
autoload :AddContactsImportData, 'constantcontact/components/activities/add_contacts_import_data'
|
30
|
+
autoload :ExportContacts, 'constantcontact/components/activities/export_contacts'
|
31
|
+
autoload :Address, 'constantcontact/components/contacts/address'
|
32
|
+
autoload :Contact, 'constantcontact/components/contacts/contact'
|
33
|
+
autoload :ContactList, 'constantcontact/components/contacts/contact_list'
|
34
|
+
autoload :CustomField, 'constantcontact/components/contacts/custom_field'
|
35
|
+
autoload :EmailAddress, 'constantcontact/components/contacts/email_address'
|
36
|
+
autoload :Note, 'constantcontact/components/contacts/note'
|
37
|
+
autoload :ClickThroughDetails, 'constantcontact/components/email_marketing/click_through_details'
|
38
|
+
autoload :Campaign, 'constantcontact/components/email_marketing/campaign'
|
39
|
+
autoload :MessageFooter, 'constantcontact/components/email_marketing/message_footer'
|
40
|
+
autoload :Schedule, 'constantcontact/components/email_marketing/schedule'
|
41
|
+
autoload :TestSend, 'constantcontact/components/email_marketing/test_send'
|
42
|
+
autoload :BounceActivity, 'constantcontact/components/tracking/bounce_activity'
|
43
|
+
autoload :ClickActivity, 'constantcontact/components/tracking/click_activity'
|
44
|
+
autoload :ForwardActivity, 'constantcontact/components/tracking/forward_activity'
|
45
|
+
autoload :OpenActivity, 'constantcontact/components/tracking/open_activity'
|
46
|
+
autoload :UnsubscribeActivity, 'constantcontact/components/tracking/unsubscribe_activity'
|
47
|
+
autoload :SendActivity, 'constantcontact/components/tracking/send_activity'
|
48
|
+
autoload :TrackingActivity, 'constantcontact/components/tracking/tracking_activity'
|
49
|
+
autoload :TrackingSummary, 'constantcontact/components/tracking/tracking_summary'
|
50
|
+
autoload :VerifiedEmailAddress, 'constantcontact/components/account/verified_email_address'
|
51
|
+
autoload :Event, 'constantcontact/components/event_spot/event'
|
52
|
+
autoload :Fee, 'constantcontact/components/event_spot/fee'
|
53
|
+
autoload :Registrant, 'constantcontact/components/event_spot/registrant'
|
54
|
+
autoload :LibrarySummary, 'constantcontact/components/library/info/library_summary'
|
55
|
+
autoload :UploadStatus, 'constantcontact/components/library/info/upload_status'
|
56
|
+
autoload :MoveResults, 'constantcontact/components/library/info/move_results'
|
57
|
+
autoload :LibraryFolder, 'constantcontact/components/library/folder/library_folder'
|
58
|
+
autoload :LibraryFile, 'constantcontact/components/library/file/library_file'
|
59
|
+
|
60
|
+
module EventSpot
|
61
|
+
autoload :Contact, 'constantcontact/components/event_spot/contact'
|
62
|
+
autoload :NotificationOption, 'constantcontact/components/event_spot/notification_option'
|
63
|
+
autoload :Guest, 'constantcontact/components/event_spot/guest'
|
64
|
+
autoload :EventTrack, 'constantcontact/components/event_spot/event_track'
|
65
|
+
autoload :RegistrantSection, 'constantcontact/components/event_spot/registrant_section'
|
66
|
+
autoload :RegistrantField, 'constantcontact/components/event_spot/registrant_field'
|
67
|
+
end
|
51
68
|
end
|
52
69
|
|
53
70
|
module Exceptions
|
54
|
-
autoload :CtctException,
|
55
|
-
autoload :IllegalArgumentException,
|
56
|
-
autoload :OAuth2Exception,
|
71
|
+
autoload :CtctException, 'constantcontact/exceptions/ctct_exception'
|
72
|
+
autoload :IllegalArgumentException, 'constantcontact/exceptions/illegal_argument_exception'
|
73
|
+
autoload :OAuth2Exception, 'constantcontact/exceptions/oauth2_exception'
|
57
74
|
end
|
58
75
|
|
59
76
|
module Services
|
60
|
-
autoload :BaseService,
|
61
|
-
autoload :ActivityService,
|
62
|
-
autoload :CampaignScheduleService,
|
63
|
-
autoload :CampaignTrackingService,
|
64
|
-
autoload :ContactService,
|
65
|
-
autoload :ContactTrackingService,
|
66
|
-
autoload :EmailMarketingService,
|
67
|
-
autoload :ListService,
|
68
|
-
autoload :AccountService,
|
77
|
+
autoload :BaseService, 'constantcontact/services/base_service'
|
78
|
+
autoload :ActivityService, 'constantcontact/services/activity_service'
|
79
|
+
autoload :CampaignScheduleService, 'constantcontact/services/campaign_schedule_service'
|
80
|
+
autoload :CampaignTrackingService, 'constantcontact/services/campaign_tracking_service'
|
81
|
+
autoload :ContactService, 'constantcontact/services/contact_service'
|
82
|
+
autoload :ContactTrackingService, 'constantcontact/services/contact_tracking_service'
|
83
|
+
autoload :EmailMarketingService, 'constantcontact/services/email_marketing_service'
|
84
|
+
autoload :ListService, 'constantcontact/services/list_service'
|
85
|
+
autoload :AccountService, 'constantcontact/services/account_service'
|
86
|
+
autoload :EventSpotService, 'constantcontact/services/event_spot_service'
|
87
|
+
autoload :LibraryService, 'constantcontact/services/library_service'
|
69
88
|
end
|
70
89
|
|
71
90
|
module Util
|
72
|
-
autoload :Config,
|
73
|
-
autoload :Helpers,
|
91
|
+
autoload :Config, 'constantcontact/util/config'
|
92
|
+
autoload :Helpers, 'constantcontact/util/helpers'
|
74
93
|
end
|
75
94
|
end
|
data/lib/constantcontact/api.rb
CHANGED
@@ -5,539 +5,936 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
8
|
+
class Api
|
9
|
+
# Class constructor
|
10
|
+
# @param [String] api_key - Constant Contact API Key
|
11
|
+
# @return
|
12
|
+
def initialize(api_key = nil)
|
13
|
+
Services::BaseService.api_key = api_key || Util::Config.get('auth.api_key')
|
14
|
+
if Services::BaseService.api_key.nil? || Services::BaseService.api_key == ''
|
15
|
+
raise ArgumentError.new("api_key required either explicitly or in configuration.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# Get verified addresses for the account
|
21
|
+
# @param [String] access_token - Valid access token
|
22
|
+
# @param [String] status - status to filter query results by
|
23
|
+
# @return [Array<VerifiedEmailAddress>] an array of email addresses
|
24
|
+
def get_verified_email_addresses(access_token, status = nil)
|
25
|
+
params = {}
|
26
|
+
params['status'] = status if status
|
27
|
+
Services::AccountService.get_verified_email_addresses(access_token, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# Get a set of contacts
|
32
|
+
# @param [String] access_token - Valid access token
|
33
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
34
|
+
# Allowed parameters include:
|
35
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
36
|
+
# modified_since - ISO-8601 formatted timestamp.
|
37
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
38
|
+
# email - the contact by email address to retrieve information for.
|
39
|
+
# status - a contact status to filter results by. Must be one of ACTIVE, OPTOUT, REMOVED, UNCONFIRMED.
|
40
|
+
# @return [ResultSet<Contact>] a ResultSet of Contacts
|
41
|
+
def get_contacts(access_token, params = {})
|
42
|
+
Services::ContactService.get_contacts(access_token, params)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# Get an individual contact
|
47
|
+
# @param [String] access_token - Valid access token
|
48
|
+
# @param [Integer] contact_id - Id of the contact to retrieve
|
49
|
+
# @return [Contact]
|
50
|
+
def get_contact(access_token, contact_id)
|
51
|
+
Services::ContactService.get_contact(access_token, contact_id)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# Get contacts with a specified email eaddress
|
56
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
57
|
+
# @param [String] email - contact email address to search for
|
58
|
+
# @return [ResultSet<Contact>] a ResultSet of Contacts
|
59
|
+
def get_contact_by_email(access_token, email)
|
60
|
+
Services::ContactService.get_contacts(access_token, {'email' => email})
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# Add a new contact to an account
|
65
|
+
# @param [String] access_token - Valid access token
|
66
|
+
# @param [Contact] contact - Contact to add
|
67
|
+
# @param [Boolean] action_by_visitor - if the action is being taken by the visitor
|
68
|
+
# @return [Contact]
|
69
|
+
def add_contact(access_token, contact, action_by_visitor = false)
|
70
|
+
params = {}
|
71
|
+
params['action_by'] = 'ACTION_BY_VISITOR' if action_by_visitor
|
72
|
+
Services::ContactService.add_contact(access_token, contact, params)
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# Sets an individual contact to 'REMOVED' status
|
77
|
+
# @param [String] access_token - Valid access token
|
78
|
+
# @param [Mixed] contact - Either a Contact id or the Contact itself
|
79
|
+
# @raise [IllegalArgumentException] If contact is not an integer or a Contact object
|
80
|
+
# @return [Boolean]
|
81
|
+
def delete_contact(access_token, contact)
|
82
|
+
contact_id = get_argument_id(contact, 'Contact')
|
83
|
+
Services::ContactService.delete_contact(access_token, contact_id)
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
# Delete a contact from all contact lists
|
88
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
89
|
+
# @param [Mixed] contact - Contact id or the Contact object itself
|
90
|
+
# @raise [IllegalArgumentException] If contact is not an integer or a Contact object
|
91
|
+
# @return [Boolean]
|
92
|
+
def delete_contact_from_lists(access_token, contact)
|
93
|
+
contact_id = get_argument_id(contact, 'Contact')
|
94
|
+
Services::ContactService.delete_contact_from_lists(access_token, contact_id)
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
# Delete a contact from all contact lists
|
99
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
100
|
+
# @param [Mixed] contact - Contact id or a Contact object
|
101
|
+
# @param [Mixed] list - ContactList id or a ContactList object
|
102
|
+
# @raise [IllegalArgumentException] If contact is not an integer or a Contact object
|
103
|
+
# @return [Boolean]
|
104
|
+
def delete_contact_from_list(access_token, contact, list)
|
105
|
+
contact_id = get_argument_id(contact, 'Contact')
|
106
|
+
list_id = get_argument_id(list, 'ContactList')
|
107
|
+
Services::ContactService.delete_contact_from_list(access_token, contact_id, list_id)
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# Update an individual contact
|
112
|
+
# @param [String] access_token - Valid access token
|
113
|
+
# @param [Contact] contact - Contact to update
|
114
|
+
# @param [Boolean] action_by_visitor - if the action is being taken by the visitor
|
115
|
+
# @return [Contact]
|
116
|
+
def update_contact(access_token, contact, action_by_visitor = false)
|
117
|
+
params = {}
|
118
|
+
params['action_by'] = 'ACTION_BY_VISITOR' if action_by_visitor
|
119
|
+
Services::ContactService.update_contact(access_token, contact, params)
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
# Get lists
|
124
|
+
# @param [String] access_token - Valid access token
|
125
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
126
|
+
# Allowed parameters include:
|
127
|
+
# - modified_since - ISO-8601 formatted timestamp.
|
128
|
+
# @return [Array<ContactList>] Array of ContactList objects
|
129
|
+
def get_lists(access_token, params = {})
|
130
|
+
Services::ListService.get_lists(access_token, params)
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
# Get an individual list
|
135
|
+
# @param [String] access_token - Valid access token
|
136
|
+
# @param [Integer] list_id - Id of the list to retrieve
|
137
|
+
# @return [ContactList]
|
138
|
+
def get_list(access_token, list_id)
|
139
|
+
Services::ListService.get_list(access_token, list_id)
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
# Add a new list to an account
|
144
|
+
# @param [String] access_token - Valid access token
|
145
|
+
# @param [ContactList] list - List to add
|
146
|
+
# @return [ContactList]
|
147
|
+
def add_list(access_token, list)
|
148
|
+
Services::ListService.add_list(access_token, list)
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
# Update a contact list
|
153
|
+
# @param [String] access_token - Valid access token
|
154
|
+
# @param [ContactList] list - ContactList to update
|
155
|
+
# @return [ContactList]
|
156
|
+
def update_list(access_token, list)
|
157
|
+
Services::ListService.update_list(access_token, list)
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
# Get contact that belong to a specific list
|
162
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
163
|
+
# @param [Mixed] list - Integer id of the list or ContactList object
|
164
|
+
# @param [Mixed] param - denotes the number of results per set, limited to 50, or a next parameter provided
|
165
|
+
# from a previous getContactsFromList call
|
166
|
+
# @raise [IllegalArgumentException] If contact is not an integer or contact
|
167
|
+
# @return [Array<Contact>] An array of contacts
|
168
|
+
def get_contacts_from_list(access_token, list, param = nil)
|
169
|
+
list_id = get_argument_id(list, 'ContactList')
|
170
|
+
param = determine_param(param)
|
171
|
+
Services::ListService.get_contacts_from_list(access_token, list_id, param)
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
# Get a set of campaigns
|
176
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
177
|
+
# @param [Mixed] params - hash of query parameters and values to append to the request.
|
178
|
+
# Allowed parameters include:
|
179
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
180
|
+
# modified_since - ISO-8601 formatted timestamp.
|
181
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
182
|
+
# email - the contact by email address to retrieve information for
|
183
|
+
# @return [ResultSet<Campaign>]
|
184
|
+
def get_email_campaigns(access_token, params = {})
|
185
|
+
Services::EmailMarketingService.get_campaigns(access_token, params)
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
# Get an individual campaign
|
190
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
191
|
+
# @param [Integer] campaign_id - Valid campaign id
|
192
|
+
# @return [Campaign]
|
193
|
+
def get_email_campaign(access_token, campaign_id)
|
194
|
+
Services::EmailMarketingService.get_campaign(access_token, campaign_id)
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
# Delete an individual campaign
|
199
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
200
|
+
# @param [Mixed] campaign - Id of a campaign or a Campaign object
|
201
|
+
# @raise IllegalArgumentException - if a Campaign object or campaign id is not passed
|
202
|
+
# @return [Boolean]
|
203
|
+
def delete_email_campaign(access_token, campaign)
|
204
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
205
|
+
Services::EmailMarketingService.delete_campaign(access_token, campaign_id)
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
# Create a new campaign
|
210
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
211
|
+
# @param [Campaign] campaign - Campaign to be created
|
212
|
+
# @return [Campaign] - created campaign
|
213
|
+
def add_email_campaign(access_token, campaign)
|
214
|
+
Services::EmailMarketingService.add_campaign(access_token, campaign)
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
# Update a specific campaign
|
219
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
220
|
+
# @param [Campaign] campaign - Campaign to be updated
|
221
|
+
# @return [Campaign] - updated campaign
|
222
|
+
def update_email_campaign(access_token, campaign)
|
223
|
+
Services::EmailMarketingService.update_campaign(access_token, campaign)
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
# Schedule a campaign to be sent
|
228
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
229
|
+
# @param [Mixed] campaign - Id of a campaign or a Campaign object
|
230
|
+
# @param [Schedule] schedule - Schedule to be associated with the provided campaign
|
231
|
+
# @return [Campaign] - updated campaign
|
232
|
+
def add_email_campaign_schedule(access_token, campaign, schedule)
|
233
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
234
|
+
Services::CampaignScheduleService.add_schedule(access_token, campaign_id, schedule)
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
# Get an array of schedules associated with a given campaign
|
239
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
240
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
241
|
+
# @return [Array<Schedule>]
|
242
|
+
def get_email_campaign_schedules(access_token, campaign)
|
243
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
244
|
+
Services::CampaignScheduleService.get_schedules(access_token, campaign_id)
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
# Get a specific schedule associated with a given campaign
|
249
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
250
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
251
|
+
# @param [Mixed] schedule - Schedule id or Schedule object itself
|
252
|
+
# @raise IllegalArgumentException
|
253
|
+
# @return [Schedule]
|
254
|
+
def get_email_campaign_schedule(access_token, campaign, schedule)
|
255
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
256
|
+
schedule_id = get_argument_id(schedule, 'Schedule')
|
257
|
+
Services::CampaignScheduleService.get_schedule(access_token, campaign_id, schedule_id)
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
# Update a specific schedule associated with a given campaign
|
262
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
263
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
264
|
+
# @param [Schedule] schedule - Schedule to be updated
|
265
|
+
# @return [Schedule]
|
266
|
+
def update_email_campaign_schedule(access_token, campaign, schedule)
|
267
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
268
|
+
Services::CampaignScheduleService.update_schedule(access_token, campaign_id, schedule)
|
269
|
+
end
|
270
|
+
|
271
|
+
|
272
|
+
# Delete a specific schedule associated with a given campaign
|
273
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
274
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
275
|
+
# @param [Mixed] schedule - Schedule id or Schedule object itself
|
276
|
+
# @raise IllegalArgumentException
|
277
|
+
# @return [Boolean]
|
278
|
+
def delete_email_campaign_schedule(access_token, campaign, schedule)
|
279
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
280
|
+
schedule_id = get_argument_id(schedule, 'Schedule')
|
281
|
+
Services::CampaignScheduleService.delete_schedule(access_token, campaign_id, schedule_id)
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
# Send a test send of a campaign
|
286
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
287
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
288
|
+
# @param [TestSend] test_send - test send details
|
289
|
+
# @return [TestSend]
|
290
|
+
def send_email_campaign_test(access_token, campaign, test_send)
|
291
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
292
|
+
Services::CampaignScheduleService.send_test(access_token, campaign_id, test_send)
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
# Get sends for a campaign
|
297
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
298
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
299
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
300
|
+
# Allowed parameters include:
|
301
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
302
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
303
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
304
|
+
# @return [ResultSet<SendActivity>]
|
305
|
+
def get_email_campaign_sends(access_token, campaign, params = {})
|
306
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
307
|
+
Services::CampaignTrackingService.get_sends(access_token, campaign_id, params)
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
# Get bounces for a campaign
|
312
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
313
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
314
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
315
|
+
# Allowed parameters include:
|
316
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
317
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
318
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
319
|
+
# @return [ResultSet<BounceActivity>]
|
320
|
+
def get_email_campaign_bounces(access_token, campaign, params = {})
|
321
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
322
|
+
Services::CampaignTrackingService.get_bounces(access_token, campaign_id, params)
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
# Get clicks for a campaign
|
327
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
328
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
329
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
330
|
+
# Allowed parameters include:
|
331
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
332
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
333
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
334
|
+
# @return [ResultSet<ClickActivity>]
|
335
|
+
def get_email_campaign_clicks(access_token, campaign, params = {})
|
336
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
337
|
+
Services::CampaignTrackingService.get_clicks(access_token, campaign_id, params)
|
338
|
+
end
|
339
|
+
|
340
|
+
|
341
|
+
# Get opens for a campaign
|
342
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
343
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
344
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
345
|
+
# Allowed parameters include:
|
346
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
347
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
348
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
349
|
+
# @return [ResultSet<OpenActivity>]
|
350
|
+
def get_email_campaign_opens(access_token, campaign, params = {})
|
351
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
352
|
+
Services::CampaignTrackingService.get_opens(access_token, campaign_id, params)
|
353
|
+
end
|
354
|
+
|
355
|
+
|
356
|
+
# Get forwards for a campaign
|
357
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
358
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
359
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
360
|
+
# Allowed parameters include:
|
361
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
362
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
363
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
364
|
+
# @return [ResultSet<ForwardActivity>]
|
365
|
+
def get_email_campaign_forwards(access_token, campaign, params = {})
|
366
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
367
|
+
Services::CampaignTrackingService.get_forwards(access_token, campaign_id, params)
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
# Get unsubscribes for a campaign
|
372
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
373
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
374
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
375
|
+
# Allowed parameters include:
|
376
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
377
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
378
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
379
|
+
# @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
|
380
|
+
def get_email_campaign_unsubscribes(access_token, campaign, params = {})
|
381
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
382
|
+
Services::CampaignTrackingService.get_unsubscribes(access_token, campaign_id, params)
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
# Get a reporting summary for a campaign
|
387
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
388
|
+
# @param [Mixed] campaign - Campaign id or Campaign object itself
|
389
|
+
# @return [TrackingSummary]
|
390
|
+
def get_email_campaign_summary_report(access_token, campaign)
|
391
|
+
campaign_id = get_argument_id(campaign, 'Campaign')
|
392
|
+
Services::CampaignTrackingService.get_summary(access_token, campaign_id)
|
393
|
+
end
|
394
|
+
|
395
|
+
|
396
|
+
# Get sends for a Contact
|
397
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
398
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
399
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
400
|
+
# Allowed parameters include:
|
401
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
402
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
403
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
404
|
+
# @return [ResultSet<SendActivity>]
|
405
|
+
def get_contact_sends(access_token, contact, params = {})
|
406
|
+
contact_id = get_argument_id(contact, 'Contact')
|
407
|
+
Services::ContactTrackingService.get_sends(access_token, contact_id, params)
|
408
|
+
end
|
409
|
+
|
410
|
+
|
411
|
+
# Get bounces for a Contact
|
412
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
413
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
414
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
415
|
+
# Allowed parameters include:
|
416
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
417
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
418
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
419
|
+
# @return [ResultSet<BounceActivity>]
|
420
|
+
def get_contact_bounces(access_token, contact, params = {})
|
421
|
+
contact_id = get_argument_id(contact, 'Contact')
|
422
|
+
Services::ContactTrackingService.get_bounces(access_token, contact_id, params)
|
423
|
+
end
|
424
|
+
|
425
|
+
|
426
|
+
# Get clicks for a Contact
|
427
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
428
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
429
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
430
|
+
# Allowed parameters include:
|
431
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
432
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
433
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
434
|
+
# @return [ResultSet<ClickActivity>]
|
435
|
+
def get_contact_clicks(access_token, contact, params = {})
|
436
|
+
contact_id = get_argument_id(contact, 'Contact')
|
437
|
+
Services::ContactTrackingService.get_clicks(access_token, contact_id, params)
|
438
|
+
end
|
439
|
+
|
440
|
+
|
441
|
+
# Get opens for a Contact
|
442
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
443
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
444
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
445
|
+
# Allowed parameters include:
|
446
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
447
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
448
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
449
|
+
# @return [ResultSet<OpenActivity>]
|
450
|
+
def get_contact_opens(access_token, contact, params = {})
|
451
|
+
contact_id = get_argument_id(contact, 'Contact')
|
452
|
+
Services::ContactTrackingService.get_opens(access_token, contact_id, params)
|
453
|
+
end
|
454
|
+
|
455
|
+
|
456
|
+
# Get forwards for a Contact
|
457
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
458
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
459
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
460
|
+
# Allowed parameters include:
|
461
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
462
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
463
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
464
|
+
# @return [ResultSet<ForwardActivity>]
|
465
|
+
def get_contact_forwards(access_token, contact, params = {})
|
466
|
+
contact_id = get_argument_id(contact, 'Contact')
|
467
|
+
Services::ContactTrackingService.get_forwards(access_token, contact_id, params)
|
468
|
+
end
|
469
|
+
|
470
|
+
|
471
|
+
# Get unsubscribes for a Contact
|
472
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
473
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
474
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
475
|
+
# Allowed parameters include:
|
476
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
|
477
|
+
# created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
|
478
|
+
# next - the next link returned from a previous paginated call. May only be used by itself.
|
479
|
+
# @return [UnsubscribeActivity] - Containing a results array of UnsubscribeActivity
|
480
|
+
def get_contact_unsubscribes(access_token, contact, params = {})
|
481
|
+
contact_id = get_argument_id(contact, 'Contact')
|
482
|
+
Services::ContactTrackingService.get_unsubscribes(access_token, contact_id, params)
|
483
|
+
end
|
484
|
+
|
485
|
+
|
486
|
+
# Get a reporting summary for a Contact
|
487
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
488
|
+
# @param [Mixed] contact - Contact id or Contact object itself
|
489
|
+
# @return [TrackingSummary]
|
490
|
+
def get_contact_summary_report(access_token, contact)
|
491
|
+
contact_id = get_argument_id(contact, 'Contact')
|
492
|
+
Services::ContactTrackingService.get_summary(access_token, contact_id)
|
493
|
+
end
|
494
|
+
|
495
|
+
|
496
|
+
# Get an array of activities
|
497
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
498
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
499
|
+
# Allowed parameters include:
|
500
|
+
# status - Status of the activity, must be one of UNCONFIRMED, PENDING, QUEUED, RUNNING, COMPLETE, ERROR
|
501
|
+
# type - Type of activity, must be one of ADD_CONTACTS, REMOVE_CONTACTS_FROM_LISTS, CLEAR_CONTACTS_FROM_LISTS,
|
502
|
+
# EXPORT_CONTACTS
|
503
|
+
# @return [Array<Activity>]
|
504
|
+
def get_activities(access_token, params = {})
|
505
|
+
Services::ActivityService.get_activities(access_token, params)
|
506
|
+
end
|
507
|
+
|
508
|
+
|
509
|
+
# Get a single activity by id
|
510
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
511
|
+
# @param [String] activity_id - Activity id
|
512
|
+
# @return [Activity]
|
513
|
+
def get_activity(access_token, activity_id)
|
514
|
+
Services::ActivityService.get_activity(access_token, activity_id)
|
515
|
+
end
|
516
|
+
|
517
|
+
|
518
|
+
# Add an AddContacts activity to add contacts in bulk
|
519
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
520
|
+
# @param [AddContacts] add_contacts - Add Contacts Activity
|
521
|
+
# @return [Activity]
|
522
|
+
def add_create_contacts_activity(access_token, add_contacts)
|
523
|
+
Services::ActivityService.create_add_contacts_activity(access_token, add_contacts)
|
524
|
+
end
|
525
|
+
|
526
|
+
|
527
|
+
# Create an Add Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx
|
528
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
529
|
+
# @param [String] file_name - The name of the file (ie: contacts.csv)
|
530
|
+
# @param [String] contents - The content of the file
|
531
|
+
# @param [String] lists - Comma separated list of ContactList id's to add the contacts to
|
532
|
+
# @return [Activity]
|
533
|
+
def add_create_contacts_activity_from_file(access_token, file_name, contents, lists)
|
534
|
+
Services::ActivityService.create_add_contacts_activity_from_file(access_token, file_name, contents, lists)
|
535
|
+
end
|
536
|
+
|
537
|
+
|
538
|
+
# Add a ClearLists Activity to remove all contacts from the provided lists
|
539
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
540
|
+
# @param [Array<Lists>] lists - Add Contacts Activity
|
541
|
+
# @return [Activity]
|
542
|
+
def add_clear_lists_activity(access_token, lists)
|
543
|
+
Services::ActivityService.add_clear_lists_activity(access_token, lists)
|
544
|
+
end
|
545
|
+
|
546
|
+
|
547
|
+
# Add a Remove Contacts From Lists Activity
|
548
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
549
|
+
# @param [Array<EmailAddress>] email_addresses - email addresses to be removed
|
550
|
+
# @param [Array<Lists>] lists - lists to remove the provided email addresses from
|
551
|
+
# @return [Activity]
|
552
|
+
def add_remove_contacts_from_lists_activity(access_token, email_addresses, lists)
|
553
|
+
Services::ActivityService.add_remove_contacts_from_lists_activity(access_token, email_addresses, lists)
|
554
|
+
end
|
555
|
+
|
556
|
+
|
557
|
+
# Add a Remove Contacts From Lists Activity from a file. Valid file types are txt, csv, xls, xlsx
|
558
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
559
|
+
# @param [String] file_name - The name of the file (ie: contacts.csv)
|
560
|
+
# @param [String] contents - The content of the file
|
561
|
+
# @param [String] lists - Comma separated list of ContactList id' to add the contacts too
|
562
|
+
# @return [Activity]
|
563
|
+
def add_remove_contacts_from_lists_activity_from_file(access_token, file_name, contents, lists)
|
564
|
+
Services::ActivityService.add_remove_contacts_from_lists_activity_from_file(access_token, file_name, contents, lists)
|
565
|
+
end
|
566
|
+
|
567
|
+
|
568
|
+
# Create an Export Contacts Activity
|
569
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
570
|
+
# @param [<Array>Contacts] export_contacts - Contacts to be exported
|
571
|
+
# @return [Activity]
|
572
|
+
def add_export_contacts_activity(access_token, export_contacts)
|
573
|
+
Services::ActivityService.add_export_contacts_activity(access_token, export_contacts)
|
574
|
+
end
|
575
|
+
|
576
|
+
|
577
|
+
# Get a list of events
|
578
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
579
|
+
# @return [ResultSet<Event>]
|
580
|
+
def get_events(access_token)
|
581
|
+
Services::EventSpotService.get_events(access_token)
|
582
|
+
end
|
583
|
+
|
584
|
+
|
585
|
+
# Get an event
|
586
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
587
|
+
# @param [Event] event - event id or object to be retrieved
|
588
|
+
# @return [Event]
|
589
|
+
def get_event(access_token, event)
|
590
|
+
Services::EventSpotService.get_event(access_token, event)
|
591
|
+
end
|
592
|
+
|
593
|
+
|
594
|
+
# Create an event
|
595
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
596
|
+
# @param [Hash] event - Event data stored in an object which respods to to_json
|
597
|
+
# @return [Event]
|
598
|
+
def add_event(access_token, event)
|
599
|
+
Services::EventSpotService.add_event(access_token, event)
|
600
|
+
end
|
601
|
+
|
602
|
+
|
603
|
+
# Update an event
|
604
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
605
|
+
# @param [Event|Hash] event - Event details stored in an object that responds to to_json and has an :id attribute
|
606
|
+
# @return [Event]
|
607
|
+
def update_event(access_token, event)
|
608
|
+
Services::EventSpotService.update_event(access_token, event)
|
609
|
+
end
|
610
|
+
|
611
|
+
|
612
|
+
# Publish an event
|
613
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
614
|
+
# @param [Event] event - Event to publish
|
615
|
+
# @return [Event]
|
616
|
+
def publish_event(access_token, event)
|
617
|
+
Services::EventSpotService.publish_event(access_token, event)
|
618
|
+
end
|
619
|
+
|
620
|
+
|
621
|
+
# Cancel an event
|
622
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
623
|
+
# @param [Event] event - Event to cancel
|
624
|
+
# @return [Activity]
|
625
|
+
def cancel_event(access_token, event)
|
626
|
+
Services::EventSpotService.cancel_event(access_token, event)
|
627
|
+
end
|
628
|
+
|
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
|
+
# Get a list of event fees
|
640
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
641
|
+
# @param [Event] event - Event to get fees of
|
642
|
+
# @return [Activity]
|
643
|
+
def get_event_fees(access_token, event)
|
644
|
+
Services::EventSpotService.get_fees(access_token, event)
|
645
|
+
end
|
646
|
+
|
647
|
+
|
648
|
+
# Get an event fee
|
649
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
650
|
+
# @param [Event] event - Event fee corresponds to
|
651
|
+
# @param [Fee] fee - Fee to retrieve
|
652
|
+
# @return [Activity]
|
653
|
+
def get_event_fee(access_token, event, fee)
|
654
|
+
Services::EventSpotService.get_fee(access_token, event, fee)
|
655
|
+
end
|
656
|
+
|
657
|
+
|
658
|
+
# Create an event fee
|
659
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
660
|
+
# @param [Event] event - Event fee corresponds to
|
661
|
+
# @param [Hash] fee - Fee details
|
662
|
+
# @return [Activity]
|
663
|
+
def add_event_fee(access_token, event, fee)
|
664
|
+
Services::EventSpotService.add_fee(access_token, event, fee)
|
665
|
+
end
|
666
|
+
|
667
|
+
|
668
|
+
# Update an event fee
|
669
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
670
|
+
# @param [Event] event - Event fee corresponds to
|
671
|
+
# @param [Fee] fee - Fee details
|
672
|
+
# @return [Activity]
|
673
|
+
def update_event_fee(access_token, event, fee)
|
674
|
+
Services::EventSpotService.update_fee(access_token, event, fee)
|
675
|
+
end
|
676
|
+
|
677
|
+
|
678
|
+
# Delete an event fee
|
679
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
680
|
+
# @param [Event] event - Event fee corresponds to
|
681
|
+
# @param [Fee] fee - Fee details
|
682
|
+
# @return [Activity]
|
683
|
+
def delete_event_fee(access_token, event, fee)
|
684
|
+
Services::EventSpotService.delete_fee(access_token, event, fee)
|
685
|
+
end
|
686
|
+
|
687
|
+
|
688
|
+
# Get a list of event registrants
|
689
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
690
|
+
# @param [Event] event - Event fee corresponds to
|
691
|
+
# @return [Activity]
|
692
|
+
def get_event_registrants(access_token, event)
|
693
|
+
Services::EventSpotService.get_registrants(access_token, event)
|
694
|
+
end
|
695
|
+
|
696
|
+
|
697
|
+
# Get an event registrant
|
698
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
699
|
+
# @param [Event] event - Event registrant corresponds to
|
700
|
+
# @param [Registrant] registrant - registrant details
|
701
|
+
# @return [Activity]
|
702
|
+
def get_event_registrant(access_token, event, registrant)
|
703
|
+
Services::EventSpotService.get_registrant(access_token, event, registrant)
|
704
|
+
end
|
705
|
+
|
706
|
+
|
707
|
+
# Retrieve MyLibrary usage information
|
708
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
709
|
+
# @return [LibrarySummary]
|
710
|
+
def get_library_info(access_token)
|
711
|
+
Services::LibraryService.get_library_info(access_token)
|
712
|
+
end
|
713
|
+
|
714
|
+
|
715
|
+
# Retrieve a list of MyLibrary folders
|
716
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
717
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
718
|
+
# Allowed parameters include:
|
719
|
+
# sort_by - The method to sort by, valid values are :
|
720
|
+
# CREATED_DATE - sorts by date folder was added, ascending (earliest to latest)
|
721
|
+
# CREATED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
|
722
|
+
# MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
|
723
|
+
# MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
|
724
|
+
# NAME - sorts alphabetically by folder name, a to z
|
725
|
+
# NAME_DESC - sorts alphabetically by folder name, z to a
|
726
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
727
|
+
# @return [ResultSet<LibraryFolder>]
|
728
|
+
def get_library_folders(access_token, params = {})
|
729
|
+
Services::LibraryService.get_library_folders(access_token, params)
|
730
|
+
end
|
731
|
+
|
732
|
+
|
733
|
+
# Create a new MyLibrary folder
|
734
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
735
|
+
# @param [LibraryFolder] folder - Library Folder to be created
|
736
|
+
# @return [LibraryFolder]
|
737
|
+
def add_library_folder(access_token, folder)
|
738
|
+
Services::LibraryService.add_library_folder(access_token, folder)
|
739
|
+
end
|
740
|
+
|
741
|
+
|
742
|
+
# Retrieve a specific MyLibrary folder using the folder_id path parameter
|
743
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
744
|
+
# @param [String] folder_id - The ID for the folder to return
|
745
|
+
# @return [LibraryFolder]
|
746
|
+
def get_library_folder(access_token, folder_id)
|
747
|
+
Services::LibraryService.get_library_folder(access_token, folder_id)
|
748
|
+
end
|
749
|
+
|
750
|
+
|
751
|
+
# Update a specific MyLibrary folder
|
752
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
753
|
+
# @param [LibraryFolder] folder - MyLibrary folder to be updated
|
754
|
+
# @return [LibraryFolder]
|
755
|
+
def update_library_folder(access_token, folder)
|
756
|
+
Services::LibraryService.update_library_folder(access_token, folder)
|
757
|
+
end
|
758
|
+
|
759
|
+
|
760
|
+
# Delete a MyLibrary folder
|
761
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
762
|
+
# @param [String] folder_id - The ID for the MyLibrary folder to delete
|
763
|
+
# @return [Boolean]
|
764
|
+
def delete_library_folder(access_token, folder_id)
|
765
|
+
Services::LibraryService.delete_library_folder(access_token, folder_id)
|
766
|
+
end
|
767
|
+
|
768
|
+
|
769
|
+
# Retrieve all files in the Trash folder
|
770
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
771
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
772
|
+
# Allowed parameters include:
|
773
|
+
# type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
|
774
|
+
# sort_by - The method to sort by, valid values are :
|
775
|
+
# ADDED_DATE - sorts by date folder was added, ascending (earliest to latest)
|
776
|
+
# ADDED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
|
777
|
+
# MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
|
778
|
+
# MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
|
779
|
+
# NAME - sorts alphabetically by file name, a to z
|
780
|
+
# NAME_DESC - sorts alphabetically by file name, z to a
|
781
|
+
# SIZE - sorts by file size, smallest to largest
|
782
|
+
# SIZE_DESC - sorts by file size, largest to smallest
|
783
|
+
# DIMENSION - sorts by file dimensions (hxw), smallest to largest
|
784
|
+
# DIMENSION_DESC - sorts by file dimensions (hxw), largest to smallest
|
785
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
786
|
+
# @return [ResultSet<LibraryFile>]
|
787
|
+
def get_library_trash(access_token, params = {})
|
788
|
+
Services::LibraryService.get_library_trash(access_token, params)
|
789
|
+
end
|
790
|
+
|
791
|
+
|
792
|
+
# Permanently deletes all files in the Trash folder
|
793
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
794
|
+
# @return [Boolean]
|
795
|
+
def delete_library_trash(access_token)
|
796
|
+
Services::LibraryService.delete_library_trash(access_token)
|
797
|
+
end
|
798
|
+
|
799
|
+
|
800
|
+
# Retrieve a collection of Library files in the Constant Contact account
|
801
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
802
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
803
|
+
# Allowed parameters include:
|
804
|
+
# type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
|
805
|
+
# source - Specifies to retrieve files from a particular source, valid values are :
|
806
|
+
# ALL - (default) files from all sources
|
807
|
+
# MyComputer
|
808
|
+
# StockImage
|
809
|
+
# Facebook
|
810
|
+
# Instagram
|
811
|
+
# Shutterstock
|
812
|
+
# Mobile
|
813
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
|
814
|
+
# @return [ResultSet<LibraryFile>]
|
815
|
+
def get_library_files(access_token, params = {})
|
816
|
+
Services::LibraryService.get_library_files(access_token, params)
|
817
|
+
end
|
818
|
+
|
819
|
+
|
820
|
+
# Retrieves all files from a MyLibrary folder specified by the folder_id path parameter
|
821
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
822
|
+
# @param [String] folder_id - Specifies the folder from which to retrieve files
|
823
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
824
|
+
# Allowed parameters include:
|
825
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
826
|
+
# @return [ResultSet<LibraryFile>]
|
827
|
+
def get_library_files_by_folder(access_token, folder_id, params = {})
|
828
|
+
Services::LibraryService.get_library_files_by_folder(access_token, folder_id, params)
|
829
|
+
end
|
830
|
+
|
831
|
+
|
832
|
+
# Retrieve a MyLibrary file using the file_id path parameter
|
833
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
834
|
+
# @param [String] file_id - Specifies the MyLibrary file for which to retrieve information
|
835
|
+
# @return [LibraryFile]
|
836
|
+
def get_library_file(access_token, file_id)
|
837
|
+
Services::LibraryService.get_library_file(access_token, file_id)
|
838
|
+
end
|
839
|
+
|
840
|
+
|
841
|
+
# Adds a new MyLibrary file using the multipart content-type
|
842
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
843
|
+
# @param [String] file_name - The name of the file (ie: dinnerplate-special.jpg)
|
844
|
+
# @param [String] folder_id - Folder id to add the file to
|
845
|
+
# @param [String] description - The description of the file provided by user
|
846
|
+
# @param [String] source - indicates the source of the original file;
|
847
|
+
# image files can be uploaded from the following sources :
|
848
|
+
# MyComputer, StockImage, Facebook - MyLibrary Plus customers only,
|
849
|
+
# Instagram - MyLibrary Plus customers only, Shutterstock, Mobile
|
850
|
+
# @param [String] file_type - Specifies the file type, valid values are: JPEG, JPG, GIF, PDF, PNG
|
851
|
+
# @param [String] contents - The content of the file
|
852
|
+
# @return [LibraryFile]
|
853
|
+
def add_library_file(access_token, file_name, folder_id, description, source, file_type, contents)
|
854
|
+
Services::LibraryService.add_library_file(access_token, file_name, folder_id, description, source, file_type, contents)
|
855
|
+
end
|
856
|
+
|
857
|
+
|
858
|
+
# Update information for a specific MyLibrary file
|
859
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
860
|
+
# @param [LibraryFile] file - Library File to be updated
|
861
|
+
# @return [LibraryFile]
|
862
|
+
def update_library_file(access_token, file)
|
863
|
+
Services::LibraryService.update_library_file(access_token, file)
|
864
|
+
end
|
865
|
+
|
866
|
+
|
867
|
+
# Delete one or more MyLibrary files specified by the fileId path parameter;
|
868
|
+
# separate multiple file IDs with a comma.
|
869
|
+
# Deleted files are moved from their current folder into the system Trash folder, and its status is set to Deleted.
|
870
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
871
|
+
# @param [String] file_id - Specifies the MyLibrary file to delete
|
872
|
+
# @return [Boolean]
|
873
|
+
def delete_library_file(access_token, file_id)
|
874
|
+
Services::LibraryService.delete_library_file(access_token, file_id)
|
875
|
+
end
|
876
|
+
|
877
|
+
|
878
|
+
# Retrieve the upload status for one or more MyLibrary files using the file_id path parameter;
|
879
|
+
# separate multiple file IDs with a comma
|
880
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
881
|
+
# @param [String] file_id - Specifies the files for which to retrieve upload status information
|
882
|
+
# @return [Array<UploadStatus>]
|
883
|
+
def get_library_files_upload_status(access_token, file_id)
|
884
|
+
Services::LibraryService.get_library_files_upload_status(access_token, file_id)
|
885
|
+
end
|
886
|
+
|
887
|
+
|
888
|
+
# Move one or more MyLibrary files to a different folder in the user's account
|
889
|
+
# specify the destination folder using the folder_id path parameter.
|
890
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
891
|
+
# @param [String] folder_id - Specifies the destination MyLibrary folder to which the files will be moved
|
892
|
+
# @param [String] file_id - Specifies the files to move, in a string of comma separated file ids (e.g. 8,9)
|
893
|
+
# @return [Array<MoveResults>]
|
894
|
+
def move_library_files(access_token, folder_id, file_id)
|
895
|
+
Services::LibraryService.move_library_files(access_token, folder_id, file_id)
|
896
|
+
end
|
897
|
+
|
898
|
+
|
899
|
+
|
900
|
+
private
|
901
|
+
|
902
|
+
|
903
|
+
# Get the id of object, or attempt to convert the argument to an int
|
904
|
+
# @param [Mixed] item - object or a numeric value
|
905
|
+
# @param [String] class_name - class name to test the given object against
|
906
|
+
# @raise IllegalArgumentException - if the item is not an instance of the class name given, or cannot be
|
907
|
+
# converted to a numeric value
|
908
|
+
# @return [Integer]
|
909
|
+
def get_argument_id(item, class_name)
|
910
|
+
item_id = nil
|
911
|
+
if item.is_a?(Integer)
|
912
|
+
item_id = item
|
913
|
+
elsif item.class.to_s.split('::').last == class_name
|
914
|
+
item_id = item.id
|
915
|
+
else
|
916
|
+
raise Exceptions::IllegalArgumentException.new(sprintf(Util::Config.get('errors.id_or_object'), class_name))
|
917
|
+
end
|
918
|
+
item_id
|
919
|
+
end
|
920
|
+
|
921
|
+
|
922
|
+
# Append the limit parameter, if the value is an integer
|
923
|
+
# @param [String] param - parameter value
|
924
|
+
# @return [Hash] the parameters as a hash object
|
925
|
+
def determine_param(param)
|
926
|
+
params = {}
|
927
|
+
if param
|
928
|
+
param = param.to_s
|
929
|
+
if param[0, 1] == '?'
|
930
|
+
hash_params = CGI::parse(param[1..-1])
|
931
|
+
params = Hash[*hash_params.collect {|key, value| [key, value.first] }.flatten]
|
932
|
+
else
|
933
|
+
params['limit'] = param
|
934
|
+
end
|
935
|
+
end
|
936
|
+
params
|
937
|
+
end
|
938
|
+
|
939
|
+
end
|
543
940
|
end
|