Skip to content
This repository was archived by the owner on Dec 16, 2021. It is now read-only.

Commit 2294a97

Browse files
committed
Merge pull request #38 from csciuto/master
Removed access token argument
2 parents c78fed5 + e54cd68 commit 2294a97

34 files changed

+697
-822
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
constantcontact (1.3.2)
4+
constantcontact (2.0.0)
55
json (~> 1.8, >= 1.8.1)
66
mime-types (~> 1.25, >= 1.25.1)
77
rest-client (~> 1.6, >= 1.6.7)

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Installation
99
====
1010
Via bundler:
1111
```ruby
12-
gem 'constantcontact', '~> 1.3.2'
12+
gem 'constantcontact', '~> 2.0.0'
1313
```
1414
Otherwise:
1515
```bash
@@ -49,8 +49,8 @@ if @code.present?
4949
response = @oauth.get_access_token(@code)
5050
if response.present?
5151
token = response['access_token']
52-
cc = ConstantContact::Api.new('your api key')
53-
@contacts = cc.get_contacts(token)
52+
cc = ConstantContact::Api.new('your api key', token)
53+
@contacts = cc.get_contacts()
5454
end
5555
else
5656
# if not code param is provided redirect into the OAuth flow
@@ -99,8 +99,8 @@ get '/my_url' do
9999
response = @oauth.get_access_token(@code)
100100
if response
101101
token = response['access_token']
102-
cc = ConstantContact::Api.new('your api key')
103-
@contacts = cc.get_contacts(token)
102+
cc = ConstantContact::Api.new('your api key', token)
103+
@contacts = cc.get_contacts()
104104
end
105105
end
106106

constantcontact.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
55

66
Gem::Specification.new do |s|
77
s.name = "constantcontact"
8-
s.version = '1.3.2'
8+
s.version = '2.0.0'
99
s.platform = Gem::Platform::RUBY
1010
s.authors = ["ConstantContact"]
1111
s.homepage = "http://www.constantcontact.com"
@@ -28,4 +28,4 @@ Gem::Specification.new do |s|
2828
s.add_runtime_dependency("json", '~> 1.8', '>= 1.8.1')
2929
s.add_runtime_dependency('mime-types', '~> 1.25', '>= 1.25.1')
3030
s.add_development_dependency("rspec", '~> 2.14')
31-
end
31+
end

examples/bulk_activities/myapp.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
response = @oauth.get_access_token(@code)
3737
@token = response['access_token']
3838

39-
cc = ConstantContact::Api.new(cnf['api_key'])
40-
lists = cc.get_lists(@token)
39+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
40+
lists = cc.get_lists()
4141
if lists
4242
lists.each do |list|
4343
# Select the first list, by default
@@ -72,7 +72,7 @@
7272
@token = params[:token]
7373

7474
if @code
75-
cc = ConstantContact::Api.new(cnf['api_key'])
75+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
7676

7777
@activity = params[:activity]
7878
lists = params[:lists] || {}
@@ -105,9 +105,9 @@
105105
add_to_lists = add_to_lists.join(',')
106106

107107
if /remove_contacts/.match(file_name)
108-
cc.add_remove_contacts_from_lists_activity_from_file(@token, file_name, contents, add_to_lists)
108+
cc.add_remove_contacts_from_lists_activity_from_file(file_name, contents, add_to_lists)
109109
elsif /add_contacts/.match(file_name)
110-
cc.add_create_contacts_activity_from_file(@token, file_name, contents, add_to_lists)
110+
cc.add_create_contacts_activity_from_file(file_name, contents, add_to_lists)
111111
end
112112

113113
redirect '/cc_callback'

examples/campaign/myapp.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
response = @oauth.get_access_token(@code)
3535
@token = response['access_token']
3636

37-
cc = ConstantContact::Api.new(cnf['api_key'])
37+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
3838

3939
@campaign = {
4040
'name'=> nil,
@@ -61,7 +61,7 @@
6161
}
6262

6363
@lists = []
64-
lists = cc.get_lists(@token)
64+
lists = cc.get_lists()
6565
if lists
6666
lists.each do |list|
6767
# Select the first list, by default
@@ -74,7 +74,7 @@
7474
end
7575
end
7676

77-
response = cc.get_verified_email_addresses(@token) rescue 'Resource not found'
77+
response = cc.get_verified_email_addresses() rescue 'Resource not found'
7878
if response
7979
verified_email = response.first.email_address
8080
@campaign['from_email'] = verified_email
@@ -104,7 +104,7 @@
104104
@token = params[:token]
105105

106106
if @code
107-
cc = ConstantContact::Api.new(cnf['api_key'])
107+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
108108

109109
@campaign = params[:campaign]
110110
@message = params[:message]
@@ -148,10 +148,10 @@
148148
end
149149

150150
campaign = ConstantContact::Components::Campaign.create(@campaign)
151-
campaign = cc.add_email_campaign(@token, campaign)
151+
campaign = cc.add_email_campaign(campaign)
152152
if campaign && !@schedule['scheduled_date'].blank?
153153
schedule = ConstantContact::Components::Schedule.create(@schedule)
154-
cc.add_email_campaign_schedule(@token, campaign, schedule)
154+
cc.add_email_campaign_schedule(campaign, schedule)
155155
end
156156
redirect '/cc_callback'
157157
end

examples/contact/myapp.rb

+8-7
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
response = @oauth.get_access_token(@code)
5757
@token = response['access_token']
5858

59-
cc = ConstantContact::Api.new(cnf['api_key'])
60-
lists = cc.get_lists(@token)
59+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
60+
lists = cc.get_lists()
6161
if lists
6262
lists.each do |list|
6363
# Select the first list, by default
@@ -92,7 +92,7 @@
9292
@token = params[:token]
9393

9494
if @code
95-
cc = ConstantContact::Api.new(cnf['api_key'])
95+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
9696

9797
@contact = params[:contact]
9898
@email = params[:email]
@@ -137,20 +137,21 @@
137137
@contact['lists'] << {:id => list_id} if lists['checkboxes'][key]
138138
end
139139

140-
response = cc.get_contact_by_email(@token, @email['email_address']) rescue 'Resource not found'
140+
response = cc.get_contact_by_email(@email['email_address']) rescue 'Resource not found'
141141
contact = ConstantContact::Components::Contact.create(@contact)
142-
if response && response.respond_to?(:results)
142+
if response && response.respond_to?(:results) && !response.results.empty?
143143
contact.id = response.results.first.id.to_s
144-
cc.update_contact(@token, contact)
144+
cc.update_contact(contact)
145145
else
146-
cc.add_contact(@token, contact)
146+
cc.add_contact(contact)
147147
end
148148

149149
redirect '/cc_callback'
150150
end
151151
rescue => e
152152
message = parse_exception(e)
153153
@error = "An error occured when saving the contact : " + message
154+
p e.backtrace
154155
end
155156
erb :contact
156157
else

examples/library/myapp.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
response = @oauth.get_access_token(@code)
3838
@token = response['access_token']
3939

40-
cc = ConstantContact::Api.new(cnf['api_key'])
41-
folders = cc.get_library_folders(@token).results
40+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
41+
folders = cc.get_library_folders().results
4242
if folders
4343
folders.each do |folder|
4444
# Select the first folder, by default
@@ -73,7 +73,7 @@
7373
@token = params[:token]
7474

7575
if @code
76-
cc = ConstantContact::Api.new(cnf['api_key'])
76+
cc = ConstantContact::Api.new(cnf['api_key'], @token)
7777

7878
@library = params[:library]
7979
folders = params[:folders] || {}
@@ -108,10 +108,10 @@
108108
end
109109
add_to_folders = add_to_folders.join(',')
110110

111-
file_id = cc.add_library_file(@token, file_name, add_to_folders, description, source, file_type, contents)
111+
file_id = cc.add_library_file(file_name, add_to_folders, description, source, file_type, contents)
112112

113113
if file_id
114-
statuses = cc.get_library_files_upload_status(@token, file_id)
114+
statuses = cc.get_library_files_upload_status(file_id)
115115
response = statuses.first
116116
@error = "File was successfully uploaded : ID=#{response.file_id}, status=#{response.status} and description=#{response.description}"
117117
else

0 commit comments

Comments
 (0)