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

Commit c78fed5

Browse files
committed
Merge pull request #34 from csciuto/master
Bringing in #22 plus updates to TravisCI to not test 1.8.7
2 parents 94771c4 + 992f57b commit c78fed5

File tree

12 files changed

+84
-13
lines changed

12 files changed

+84
-13
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ rvm:
44
- 2.0.0
55
- 1.9.3
66
- 1.9.2
7-
- 1.8.7
87
- jruby-19mode
9-
- jruby-18mode
108
#script: rspec spec

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.1)
4+
constantcontact (1.3.2)
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Installation
99
====
1010
Via bundler:
1111
```ruby
12-
gem 'constantcontact', '~> 1.3.1'
12+
gem 'constantcontact', '~> 1.3.2'
1313
```
1414
Otherwise:
1515
```bash

constantcontact.gemspec

+1-1
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.1'
8+
s.version = '1.3.2'
99
s.platform = Gem::Platform::RUBY
1010
s.authors = ["ConstantContact"]
1111
s.homepage = "http://www.constantcontact.com"

lib/constantcontact.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module Components
5151
autoload :TrackingActivity, 'constantcontact/components/tracking/tracking_activity'
5252
autoload :TrackingSummary, 'constantcontact/components/tracking/tracking_summary'
5353
autoload :VerifiedEmailAddress, 'constantcontact/components/account/verified_email_address'
54+
autoload :AccountInfo, 'constantcontact/components/account/account_info'
5455
autoload :Event, 'constantcontact/components/event_spot/event'
5556
autoload :EventFee, 'constantcontact/components/event_spot/event_fee'
5657
autoload :Registrant, 'constantcontact/components/event_spot/registrant'
@@ -118,4 +119,4 @@ module Models
118119
autoload :BillingChangeNotification, 'constantcontact/webhooks/models/billing_change_notification'
119120
end
120121
end
121-
end
122+
end

lib/constantcontact/api.rb

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ def initialize(api_key = nil)
1717
end
1818

1919

20+
def get_account_info(access_token)
21+
Services::AccountService.get_account_info(access_token)
22+
end
23+
24+
2025
# Get verified addresses for the account
2126
# @param [String] access_token - Valid access token
2227
# @param [String] status - status to filter query results by
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# account_info.rb
3+
# ConstantContact
4+
#
5+
# Copyright (c) 2013 Constant Contact. All rights reserved.
6+
7+
module ConstantContact
8+
module Components
9+
class AccountInfo < Component
10+
attr_accessor :website, :organization_name, :first_name, :last_name, :email, :phone, :country_code, :state_code
11+
12+
# Class constructor
13+
# @return [AccountInfo]
14+
def initialize
15+
end
16+
17+
# Factory method to create an AccountInfo object from a json string
18+
# @param [Hash] props - properties to create object from
19+
# @return [AccountInfo]
20+
def self.create(props)
21+
obj = AccountInfo.new
22+
if props
23+
props.each do |key, value|
24+
obj.send("#{key}=", value) if obj.respond_to? key
25+
end
26+
end
27+
obj
28+
end
29+
end
30+
end
31+
end

lib/constantcontact/services/account_service.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ module Services
99
class AccountService < BaseService
1010
class << self
1111

12+
# Get a summary of account information
13+
# @param [String] access_token
14+
# @return
15+
def get_account_info(access_token)
16+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.account_info')
17+
url = build_url(url)
18+
response = RestClient.get(url, get_headers(access_token))
19+
Components::AccountInfo.create(JSON.parse(response.body))
20+
end
21+
22+
1223
# Get all verified email addresses associated with an account
1324
# @param [String] access_token - Constant Contact OAuth2 access token
1425
# @param [Hash] params - hash of query parameters/values to append to the request
@@ -27,4 +38,4 @@ def get_verified_email_addresses(access_token, params)
2738
end
2839
end
2940
end
30-
end
41+
end

lib/constantcontact/services/base_service.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def build_url(url, params = nil)
5151
if value.respond_to? :iso8601
5252
params[key] = value.iso8601
5353
end
54+
55+
if key.to_s == 'next' && value.match(/^.*?next=(.*)$/)
56+
params[key] = $1
57+
end
5458
end
5559
else
5660
params ||= {}
@@ -63,4 +67,4 @@ def build_url(url, params = nil)
6367
end
6468
end
6569
end
66-
end
70+
end

lib/constantcontact/util/config.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Config
2323
:add_contacts_activity => 'activities/addcontacts',
2424

2525
:account_verified_addresses => 'account/verifiedemailaddresses',
26+
:account_info => 'account/info',
2627

2728
:contact => 'contacts/%s',
2829
:contacts => 'contacts',
@@ -169,4 +170,4 @@ def get_value(index, value)
169170

170171
end
171172
end
172-
end
173+
end

lib/constantcontact/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
module ConstantContact
88
module SDK
99
# Gem version
10-
VERSION = "1.3.1"
10+
VERSION = "1.3.2"
1111
end
1212
end

spec/constantcontact/services/base_service_spec.rb

+23-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@
2424
expect(headers[:user_agent].include?(RUBY_DESCRIPTION)).to be_true
2525
expect(headers[:x_ctct_request_source]).to be_a String
2626
expect(headers[:x_ctct_request_source].include?(ConstantContact::SDK::VERSION)).to be_true
27-
end
28-
end
29-
end
27+
end
28+
end
29+
30+
describe "#build_url" do
31+
it "combines all the given parameters into the url" do
32+
components = ConstantContact::Services::BaseService.send(:build_url, "http://testing.com", :arg1 => 'abc', :arg2 => 123).split('&')
33+
expect(components[0]).to eq('http://testing.com?api_key=api+key')
34+
expect(components.length).to eq(3)
35+
expect(components.include?('arg1=abc')).to be_true
36+
expect(components.include?('arg2=123')).to be_true
37+
end
38+
39+
it "does not parse the next param when not in next_link format" do
40+
url = ConstantContact::Services::BaseService.send(:build_url, "http://testing.com", :next => "abcdef")
41+
expect(url).to eq('http://testing.com?api_key=api+key&next=abcdef')
42+
end
43+
44+
it "parses next id from next param given in next_link format" do
45+
url = ConstantContact::Services::BaseService.send(:build_url, "http://testing.com", :next => "/some/path?next=abcdefg")
46+
expect(url).to eq('http://testing.com?api_key=api+key&next=abcdefg')
47+
end
48+
end
49+
end

0 commit comments

Comments
 (0)