constantcontact-ruby 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/README.md +136 -0
- data/constantcontact-ruby.gemspec +31 -0
- data/lib/constantcontact/api.rb +1012 -0
- data/lib/constantcontact/auth/oauth2.rb +105 -0
- data/lib/constantcontact/auth/session_data_store.rb +69 -0
- data/lib/constantcontact/components/account/account_address.rb +26 -0
- data/lib/constantcontact/components/account/account_info.rb +38 -0
- data/lib/constantcontact/components/account/verified_email_address.rb +26 -0
- data/lib/constantcontact/components/activities/activity.rb +43 -0
- data/lib/constantcontact/components/activities/activity_error.rb +26 -0
- data/lib/constantcontact/components/activities/add_contacts.rb +127 -0
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +46 -0
- data/lib/constantcontact/components/activities/export_contacts.rb +30 -0
- data/lib/constantcontact/components/component.rb +48 -0
- data/lib/constantcontact/components/contacts/address.rb +27 -0
- data/lib/constantcontact/components/contacts/contact.rb +92 -0
- data/lib/constantcontact/components/contacts/contact_list.rb +26 -0
- data/lib/constantcontact/components/contacts/custom_field.rb +26 -0
- data/lib/constantcontact/components/contacts/email_address.rb +33 -0
- data/lib/constantcontact/components/contacts/note.rb +26 -0
- data/lib/constantcontact/components/email_marketing/campaign.rb +83 -0
- data/lib/constantcontact/components/email_marketing/campaign_preview.rb +29 -0
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +27 -0
- data/lib/constantcontact/components/email_marketing/message_footer.rb +29 -0
- data/lib/constantcontact/components/email_marketing/schedule.rb +27 -0
- data/lib/constantcontact/components/email_marketing/test_send.rb +45 -0
- data/lib/constantcontact/components/event_spot/contact.rb +27 -0
- data/lib/constantcontact/components/event_spot/event.rb +69 -0
- data/lib/constantcontact/components/event_spot/event_address.rb +29 -0
- data/lib/constantcontact/components/event_spot/event_fee.rb +27 -0
- data/lib/constantcontact/components/event_spot/event_item.rb +36 -0
- data/lib/constantcontact/components/event_spot/event_item_attribute.rb +26 -0
- data/lib/constantcontact/components/event_spot/event_track.rb +31 -0
- data/lib/constantcontact/components/event_spot/guest.rb +31 -0
- data/lib/constantcontact/components/event_spot/guest_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
- data/lib/constantcontact/components/event_spot/online_meeting.rb +28 -0
- data/lib/constantcontact/components/event_spot/payment_address.rb +29 -0
- data/lib/constantcontact/components/event_spot/payment_summary.rb +33 -0
- data/lib/constantcontact/components/event_spot/promocode.rb +25 -0
- data/lib/constantcontact/components/event_spot/registrant.rb +52 -0
- data/lib/constantcontact/components/event_spot/registrant_fee.rb +29 -0
- data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_order.rb +39 -0
- data/lib/constantcontact/components/event_spot/registrant_promo_code.rb +31 -0
- data/lib/constantcontact/components/event_spot/registrant_promo_code_info.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/sale_item.rb +29 -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/result_set.rb +50 -0
- data/lib/constantcontact/components/tracking/bounce_activity.rb +28 -0
- data/lib/constantcontact/components/tracking/click_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/forward_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/open_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/send_activity.rb +27 -0
- data/lib/constantcontact/components/tracking/tracking_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/tracking_summary.rb +27 -0
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +27 -0
- data/lib/constantcontact/exceptions/ctct_exception.rb +25 -0
- data/lib/constantcontact/exceptions/illegal_argument_exception.rb +11 -0
- data/lib/constantcontact/exceptions/oauth2_exception.rb +11 -0
- data/lib/constantcontact/exceptions/webhooks_exception.rb +11 -0
- data/lib/constantcontact/services/account_service.rb +39 -0
- data/lib/constantcontact/services/activity_service.rb +136 -0
- data/lib/constantcontact/services/base_service.rb +68 -0
- data/lib/constantcontact/services/campaign_schedule_service.rb +101 -0
- data/lib/constantcontact/services/campaign_tracking_service.rb +152 -0
- data/lib/constantcontact/services/contact_service.rb +105 -0
- data/lib/constantcontact/services/contact_tracking_service.rb +152 -0
- data/lib/constantcontact/services/email_marketing_service.rb +94 -0
- data/lib/constantcontact/services/event_spot_service.rb +448 -0
- data/lib/constantcontact/services/library_service.rb +281 -0
- data/lib/constantcontact/services/list_service.rb +81 -0
- data/lib/constantcontact/util/config.rb +180 -0
- data/lib/constantcontact/util/helpers.rb +27 -0
- data/lib/constantcontact/version.rb +12 -0
- data/lib/constantcontact/webhooks/helpers/validator.rb +30 -0
- data/lib/constantcontact/webhooks/models/billing_change_notification.rb +27 -0
- data/lib/constantcontact/webhooks/webhooks_util.rb +45 -0
- data/lib/constantcontact.rb +124 -0
- data/spec/constantcontact/api_spec.rb +1560 -0
- data/spec/constantcontact/auth/oauth2_spec.rb +125 -0
- data/spec/constantcontact/components/contacts/address_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/contact_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/custom_field_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/email_address_spec.rb +18 -0
- data/spec/constantcontact/sdk_spec.rb +24 -0
- data/spec/constantcontact/services/account_service_spec.rb +46 -0
- data/spec/constantcontact/services/activity_service_spec.rb +244 -0
- data/spec/constantcontact/services/base_service_spec.rb +50 -0
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +115 -0
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +131 -0
- data/spec/constantcontact/services/contact_service_spec.rb +111 -0
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +131 -0
- data/spec/constantcontact/services/email_marketing_spec.rb +100 -0
- data/spec/constantcontact/services/event_spot_spec.rb +423 -0
- data/spec/constantcontact/services/library_service_spec.rb +252 -0
- data/spec/constantcontact/services/list_service_spec.rb +89 -0
- data/spec/constantcontact/webhooks/webhooks_spec.rb +26 -0
- metadata +243 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74ceb09ee19f5f7af57343c79fc8ef94416a1ae1
|
4
|
+
data.tar.gz: 1ca40a24f720b500e490b8bcccdb3f54da184075
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f9e336a081468da87bfe1ba9cef99434083421030da104098f4cc67d13b5d65e89bb35067123b0ce518c046a56a841d4e6c113c0d61762d965db412b1fa7668
|
7
|
+
data.tar.gz: c1d534fe869dc559ec6f6751ef7e7e17f3ba1b4b24b53cbd9a7d986ddc7a2ded8ec8478155760e25c07e3e53c88f904552826a76ed795bba80688843764df653
|
data/.rspec
ADDED
data/README.md
ADDED
@@ -0,0 +1,136 @@
|
|
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
|
+
[](https://travis-ci.org/constantcontact/ruby-sdk)
|
7
|
+
|
8
|
+
Installation
|
9
|
+
====
|
10
|
+
Via bundler:
|
11
|
+
```ruby
|
12
|
+
gem 'constantcontact', '~> 2.2.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
|
+
Documentation
|
31
|
+
=====
|
32
|
+
SDK Documentation is hosted at http://constantcontact.github.io/ruby-sdk
|
33
|
+
|
34
|
+
API Documentation is located at http://developer.constantcontact.com/docs/developer-guides/api-documentation-index.html
|
35
|
+
|
36
|
+
Getting Started
|
37
|
+
====
|
38
|
+
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.
|
39
|
+
|
40
|
+
Rails
|
41
|
+
=====
|
42
|
+
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:
|
43
|
+
```ruby
|
44
|
+
@oauth = ConstantContact::Auth::OAuth2.new(
|
45
|
+
:api_key => 'your api key',
|
46
|
+
:api_secret => 'your secret key',
|
47
|
+
:redirect_url => 'your redirect url' # the URL given when registering your app with Mashery.
|
48
|
+
)
|
49
|
+
|
50
|
+
@error = params[:error]
|
51
|
+
@user = params[:username]
|
52
|
+
@code = params[:code]
|
53
|
+
|
54
|
+
if @code.present?
|
55
|
+
response = @oauth.get_access_token(@code)
|
56
|
+
if response.present?
|
57
|
+
token = response['access_token']
|
58
|
+
cc = ConstantContact::Api.new('your api key', token)
|
59
|
+
@contacts = cc.get_contacts()
|
60
|
+
end
|
61
|
+
else
|
62
|
+
# if not code param is provided redirect into the OAuth flow
|
63
|
+
redirect_to @oauth.get_authorization_url and return
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Create a view for the above mentioned action with the following code:
|
68
|
+
```erb
|
69
|
+
|
70
|
+
<% if @error %>
|
71
|
+
<p><%= @error %></p>
|
72
|
+
<% end %>
|
73
|
+
|
74
|
+
<% if @contacts.present? %>
|
75
|
+
<% @contacts.each do |contact| %>
|
76
|
+
<p>Contact name: <%= "#{contact.first_name} #{contact.last_name}" %></p>
|
77
|
+
<% end %>
|
78
|
+
<% end %>
|
79
|
+
```
|
80
|
+
|
81
|
+
The first time you access the action you will be redirected into the Constant Contact OAuth flow.
|
82
|
+
Then you will be redirected back to your action and you should see the list of contacts.
|
83
|
+
|
84
|
+
Sinatra
|
85
|
+
=====
|
86
|
+
Require AppConnect:
|
87
|
+
```ruby
|
88
|
+
require 'constantcontact'
|
89
|
+
```
|
90
|
+
|
91
|
+
Add the following route. The redirect_url should be the same given when registering the app with Mashery.
|
92
|
+
```ruby
|
93
|
+
get '/my_url' do
|
94
|
+
@oauth = ConstantContact::Auth::OAuth2.new(
|
95
|
+
:api_key => 'your api key',
|
96
|
+
:api_secret => 'your secret key',
|
97
|
+
:redirect_url => 'your redirect url'
|
98
|
+
)
|
99
|
+
|
100
|
+
@error = params[:error]
|
101
|
+
@user = params[:username]
|
102
|
+
@code = params[:code]
|
103
|
+
|
104
|
+
if @code
|
105
|
+
response = @oauth.get_access_token(@code)
|
106
|
+
if response
|
107
|
+
token = response['access_token']
|
108
|
+
cc = ConstantContact::Api.new('your api key', token)
|
109
|
+
@contacts = cc.get_contacts()
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
erb :my_view
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
117
|
+
Create a my_view.erb with the following code:
|
118
|
+
```ruby
|
119
|
+
<% if @error %>
|
120
|
+
<p><%=@error%></p>
|
121
|
+
<% end %>
|
122
|
+
|
123
|
+
<% if @code %>
|
124
|
+
<% if @contacts %>
|
125
|
+
<% @contacts.each do |contact| %>
|
126
|
+
<p>\Contact name: <%= "#{contact.first_name} #{contact.last_name}" %></p>
|
127
|
+
<% end %>
|
128
|
+
<% end %>
|
129
|
+
<% else %>
|
130
|
+
<a href="<%=@oauth.get_authorization_url%>">Click to authorize</a>
|
131
|
+
<% end %>
|
132
|
+
```
|
133
|
+
|
134
|
+
The first time you access the action in browser you should see the "Click to authorize" link.
|
135
|
+
Follow the link, go through all the Constant Contact steps required
|
136
|
+
and then you will be redirected back to your action and you should see the list of contacts.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "constantcontact-ruby"
|
8
|
+
s.version = '2.2.0'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["ConstantContact", "ConferenceCloud"]
|
11
|
+
s.homepage = "http://www.constantcontact.com"
|
12
|
+
s.summary = %q{Constant Contact SDK for Ruby}
|
13
|
+
s.email = "webservices@constantcontact.com"
|
14
|
+
s.description = "Ruby library for interactions with Constant Contact v2 API"
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.files = [
|
18
|
+
'.rspec',
|
19
|
+
'constantcontact-ruby.gemspec',
|
20
|
+
'README.md'
|
21
|
+
]
|
22
|
+
s.files += Dir['lib/**/*.rb']
|
23
|
+
s.executables = []
|
24
|
+
s.require_paths = [ "lib" ]
|
25
|
+
s.test_files = Dir['spec/**/*_spec.rb']
|
26
|
+
|
27
|
+
s.add_runtime_dependency("rest-client", '~> 1.6', '>= 1.6.7')
|
28
|
+
s.add_runtime_dependency("json", '~> 1.8', '>= 1.8.1')
|
29
|
+
s.add_runtime_dependency('mime-types', '~> 2.4', '>= 2.4.1')
|
30
|
+
s.add_development_dependency("rspec", '~> 2.14')
|
31
|
+
end
|