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

Commit

Permalink
Merge pull request #38 from csciuto/master
Browse files Browse the repository at this point in the history
Removed access token argument
  • Loading branch information
csciuto committed Mar 27, 2015
2 parents c78fed5 + e54cd68 commit 2294a97
Show file tree
Hide file tree
Showing 34 changed files with 697 additions and 822 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
constantcontact (1.3.2)
constantcontact (2.0.0)
json (~> 1.8, >= 1.8.1)
mime-types (~> 1.25, >= 1.25.1)
rest-client (~> 1.6, >= 1.6.7)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Installation
====
Via bundler:
```ruby
gem 'constantcontact', '~> 1.3.2'
gem 'constantcontact', '~> 2.0.0'
```
Otherwise:
```bash
Expand Down Expand Up @@ -49,8 +49,8 @@ if @code.present?
response = @oauth.get_access_token(@code)
if response.present?
token = response['access_token']
cc = ConstantContact::Api.new('your api key')
@contacts = cc.get_contacts(token)
cc = ConstantContact::Api.new('your api key', token)
@contacts = cc.get_contacts()
end
else
# if not code param is provided redirect into the OAuth flow
Expand Down Expand Up @@ -99,8 +99,8 @@ get '/my_url' do
response = @oauth.get_access_token(@code)
if response
token = response['access_token']
cc = ConstantContact::Api.new('your api key')
@contacts = cc.get_contacts(token)
cc = ConstantContact::Api.new('your api key', token)
@contacts = cc.get_contacts()
end
end

Expand Down
4 changes: 2 additions & 2 deletions constantcontact.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |s|
s.name = "constantcontact"
s.version = '1.3.2'
s.version = '2.0.0'
s.platform = Gem::Platform::RUBY
s.authors = ["ConstantContact"]
s.homepage = "http://www.constantcontact.com"
Expand All @@ -28,4 +28,4 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("json", '~> 1.8', '>= 1.8.1')
s.add_runtime_dependency('mime-types', '~> 1.25', '>= 1.25.1')
s.add_development_dependency("rspec", '~> 2.14')
end
end
10 changes: 5 additions & 5 deletions examples/bulk_activities/myapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
response = @oauth.get_access_token(@code)
@token = response['access_token']

cc = ConstantContact::Api.new(cnf['api_key'])
lists = cc.get_lists(@token)
cc = ConstantContact::Api.new(cnf['api_key'], @token)
lists = cc.get_lists()
if lists
lists.each do |list|
# Select the first list, by default
Expand Down Expand Up @@ -72,7 +72,7 @@
@token = params[:token]

if @code
cc = ConstantContact::Api.new(cnf['api_key'])
cc = ConstantContact::Api.new(cnf['api_key'], @token)

@activity = params[:activity]
lists = params[:lists] || {}
Expand Down Expand Up @@ -105,9 +105,9 @@
add_to_lists = add_to_lists.join(',')

if /remove_contacts/.match(file_name)
cc.add_remove_contacts_from_lists_activity_from_file(@token, file_name, contents, add_to_lists)
cc.add_remove_contacts_from_lists_activity_from_file(file_name, contents, add_to_lists)
elsif /add_contacts/.match(file_name)
cc.add_create_contacts_activity_from_file(@token, file_name, contents, add_to_lists)
cc.add_create_contacts_activity_from_file(file_name, contents, add_to_lists)
end

redirect '/cc_callback'
Expand Down
12 changes: 6 additions & 6 deletions examples/campaign/myapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
response = @oauth.get_access_token(@code)
@token = response['access_token']

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

@campaign = {
'name'=> nil,
Expand All @@ -61,7 +61,7 @@
}

@lists = []
lists = cc.get_lists(@token)
lists = cc.get_lists()
if lists
lists.each do |list|
# Select the first list, by default
Expand All @@ -74,7 +74,7 @@
end
end

response = cc.get_verified_email_addresses(@token) rescue 'Resource not found'
response = cc.get_verified_email_addresses() rescue 'Resource not found'
if response
verified_email = response.first.email_address
@campaign['from_email'] = verified_email
Expand Down Expand Up @@ -104,7 +104,7 @@
@token = params[:token]

if @code
cc = ConstantContact::Api.new(cnf['api_key'])
cc = ConstantContact::Api.new(cnf['api_key'], @token)

@campaign = params[:campaign]
@message = params[:message]
Expand Down Expand Up @@ -148,10 +148,10 @@
end

campaign = ConstantContact::Components::Campaign.create(@campaign)
campaign = cc.add_email_campaign(@token, campaign)
campaign = cc.add_email_campaign(campaign)
if campaign && !@schedule['scheduled_date'].blank?
schedule = ConstantContact::Components::Schedule.create(@schedule)
cc.add_email_campaign_schedule(@token, campaign, schedule)
cc.add_email_campaign_schedule(campaign, schedule)
end
redirect '/cc_callback'
end
Expand Down
15 changes: 8 additions & 7 deletions examples/contact/myapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
response = @oauth.get_access_token(@code)
@token = response['access_token']

cc = ConstantContact::Api.new(cnf['api_key'])
lists = cc.get_lists(@token)
cc = ConstantContact::Api.new(cnf['api_key'], @token)
lists = cc.get_lists()
if lists
lists.each do |list|
# Select the first list, by default
Expand Down Expand Up @@ -92,7 +92,7 @@
@token = params[:token]

if @code
cc = ConstantContact::Api.new(cnf['api_key'])
cc = ConstantContact::Api.new(cnf['api_key'], @token)

@contact = params[:contact]
@email = params[:email]
Expand Down Expand Up @@ -137,20 +137,21 @@
@contact['lists'] << {:id => list_id} if lists['checkboxes'][key]
end

response = cc.get_contact_by_email(@token, @email['email_address']) rescue 'Resource not found'
response = cc.get_contact_by_email(@email['email_address']) rescue 'Resource not found'
contact = ConstantContact::Components::Contact.create(@contact)
if response && response.respond_to?(:results)
if response && response.respond_to?(:results) && !response.results.empty?
contact.id = response.results.first.id.to_s
cc.update_contact(@token, contact)
cc.update_contact(contact)
else
cc.add_contact(@token, contact)
cc.add_contact(contact)
end

redirect '/cc_callback'
end
rescue => e
message = parse_exception(e)
@error = "An error occured when saving the contact : " + message
p e.backtrace
end
erb :contact
else
Expand Down
10 changes: 5 additions & 5 deletions examples/library/myapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
response = @oauth.get_access_token(@code)
@token = response['access_token']

cc = ConstantContact::Api.new(cnf['api_key'])
folders = cc.get_library_folders(@token).results
cc = ConstantContact::Api.new(cnf['api_key'], @token)
folders = cc.get_library_folders().results
if folders
folders.each do |folder|
# Select the first folder, by default
Expand Down Expand Up @@ -73,7 +73,7 @@
@token = params[:token]

if @code
cc = ConstantContact::Api.new(cnf['api_key'])
cc = ConstantContact::Api.new(cnf['api_key'], @token)

@library = params[:library]
folders = params[:folders] || {}
Expand Down Expand Up @@ -108,10 +108,10 @@
end
add_to_folders = add_to_folders.join(',')

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

if file_id
statuses = cc.get_library_files_upload_status(@token, file_id)
statuses = cc.get_library_files_upload_status(file_id)
response = statuses.first
@error = "File was successfully uploaded : ID=#{response.file_id}, status=#{response.status} and description=#{response.description}"
else
Expand Down
Loading

0 comments on commit 2294a97

Please sign in to comment.