constantcontact 2.0.1 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4482ee218582fce3baff7aac752c2307bdba32d7
4
- data.tar.gz: 748c1cbee8c014914d45af0742bd9518ee0542bb
3
+ metadata.gz: f28974a36aa166d1ec1e5aa197fb2d528ccd244d
4
+ data.tar.gz: a3343897602d9c14ba3a09d4aadbf4383f8917f0
5
5
  SHA512:
6
- metadata.gz: 154d1317c786da6b9716ff382ce55a1053bcb998906046d2fe2eea401b2006d9b7f9c2a31d10e6144e309cf20dc519df841cf5b46378b5cdd47b0fed647aed8b
7
- data.tar.gz: 1a08e5af4474160624d8d020a19fe0a1f1938cdfae881b633021668e5f09538d4c61003ed97bae402602b2db40433b156e6e9aae644045196eefcb6d2e23a72c
6
+ metadata.gz: e928981912c3b26ae556ede64e13dd75a421dbf75a84ad60f0bbfda6ad1ac2182381732ccf5ce3e54bb12249feb13322b2bd5804f2e1b3fa7be920630847b59e
7
+ data.tar.gz: 4aebc30eb29335a52a6a541ac23b071bac5bf02f55bcd7aa469d6c8a124fde72d19a76e3c1e674b5f919d54bd7e2672fd77d5942cb66633ef21ec92740780dd0
data/README.md CHANGED
@@ -9,7 +9,7 @@ Installation
9
9
  ====
10
10
  Via bundler:
11
11
  ```ruby
12
- gem 'constantcontact', '~> 2.0.1'
12
+ gem 'constantcontact', '~> 2.1.0'
13
13
  ```
14
14
  Otherwise:
15
15
  ```bash
@@ -27,6 +27,12 @@ ConstantContact::Util::Config.configure do |config|
27
27
  end
28
28
  ```
29
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
+
30
36
  Getting Started
31
37
  ====
32
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.
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "constantcontact"
8
- s.version = '2.0.1'
8
+ s.version = '2.1.0'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["ConstantContact"]
11
11
  s.homepage = "http://www.constantcontact.com"
@@ -30,85 +30,95 @@ module ConstantContact
30
30
  if column_names.empty?
31
31
  used_columns = [Util::Config.get('activities_columns.email')]
32
32
 
33
- contact = contacts[0]
33
+ contacts.each do |contact|
34
34
 
35
- if !contact.first_name.nil?
36
- used_columns << Util::Config.get('activities_columns.first_name')
37
- end
35
+ if !contact.first_name.nil?
36
+ used_columns << Util::Config.get('activities_columns.first_name')
37
+ end
38
38
 
39
- if !contact.middle_name.nil?
40
- used_columns << Util::Config.get('activities_columns.middle_name')
41
- end
39
+ if !contact.middle_name.nil?
40
+ used_columns << Util::Config.get('activities_columns.middle_name')
41
+ end
42
42
 
43
- if !contact.last_name.nil?
44
- used_columns << Util::Config.get('activities_columns.last_name')
45
- end
43
+ if !contact.last_name.nil?
44
+ used_columns << Util::Config.get('activities_columns.last_name')
45
+ end
46
46
 
47
- if !contact.job_title.nil?
48
- used_columns << Util::Config.get('activities_columns.job_title')
49
- end
47
+ if !contact.birthday_day.nil?
48
+ used_columns << Util::Config.get('activities_columns.birthday_day')
49
+ end
50
50
 
51
- if !contact.company_name.nil?
52
- used_columns << Util::Config.get('activities_columns.company_name')
53
- end
51
+ if !contact.birthday_month.nil?
52
+ used_columns << Util::Config.get('activities_columns.birthday_month')
53
+ end
54
54
 
55
- if !contact.work_phone.nil?
56
- used_columns << Util::Config.get('activities_columns.work_phone')
57
- end
55
+ if !contact.anniversary.nil?
56
+ used_columns << Util::Config.get('activities_columns.anniversary')
57
+ end
58
58
 
59
- if !contact.home_phone.nil?
60
- used_columns << Util::Config.get('activities_columns.home_phone')
61
- end
59
+ if !contact.job_title.nil?
60
+ used_columns << Util::Config.get('activities_columns.job_title')
61
+ end
62
62
 
63
- address = contact.addresses[0]
63
+ if !contact.company_name.nil?
64
+ used_columns << Util::Config.get('activities_columns.company_name')
65
+ end
64
66
 
65
- if !address.line1.nil?
66
- used_columns << Util::Config.get('activities_columns.address1')
67
- end
67
+ if !contact.work_phone.nil?
68
+ used_columns << Util::Config.get('activities_columns.work_phone')
69
+ end
68
70
 
69
- if !address.line2.nil?
70
- used_columns << Util::Config.get('activities_columns.address2')
71
- end
71
+ if !contact.home_phone.nil?
72
+ used_columns << Util::Config.get('activities_columns.home_phone')
73
+ end
72
74
 
73
- if !address.line3.nil?
74
- used_columns << Util::Config.get('activities_columns.address3')
75
- end
75
+ contact.addresses.each do |address|
76
76
 
77
- if !address.city.nil?
78
- used_columns << Util::Config.get('activities_columns.city')
79
- end
77
+ if !address.line1.nil?
78
+ used_columns << Util::Config.get('activities_columns.address1')
79
+ end
80
80
 
81
- if !address.state_code.nil?
82
- used_columns << Util::Config.get('activities_columns.state')
83
- end
81
+ if !address.line2.nil?
82
+ used_columns << Util::Config.get('activities_columns.address2')
83
+ end
84
84
 
85
- if !address.state_code.nil?
86
- used_columns << Util::Config.get('activities_columns.state_province')
87
- end
85
+ if !address.line3.nil?
86
+ used_columns << Util::Config.get('activities_columns.address3')
87
+ end
88
88
 
89
- if !address.country_code.nil?
90
- used_columns << Util::Config.get('activities_columns.country')
91
- end
89
+ if !address.city.nil?
90
+ used_columns << Util::Config.get('activities_columns.city')
91
+ end
92
92
 
93
- if !address.postal_code.nil?
94
- used_columns << Util::Config.get('activities_columns.postal_code')
95
- end
93
+ if !address.state_code.nil?
94
+ used_columns << Util::Config.get('activities_columns.state')
95
+ end
96
96
 
97
- if !address.sub_postal_code.nil?
98
- used_columns << Util::Config.get('activities_columns.sub_postal_code')
99
- end
97
+ if !address.country_code.nil?
98
+ used_columns << Util::Config.get('activities_columns.country')
99
+ end
100
+
101
+ if !address.postal_code.nil?
102
+ used_columns << Util::Config.get('activities_columns.postal_code')
103
+ end
104
+
105
+ if !address.sub_postal_code.nil?
106
+ used_columns << Util::Config.get('activities_columns.sub_postal_code')
107
+ end
108
+ end
100
109
 
101
- # Custom Fields
102
- if !contact.custom_fields.nil?
103
- contact.custom_fields.each do |custom_field|
104
- if custom_field.name.match('custom_field_')
105
- custom_field_number = custom_field.name[13, custom_field.name.length]
106
- used_columns << Util::Config.get('activities_columns.custom_field_' + custom_field_number)
110
+ # Custom Fields
111
+ if !contact.custom_fields.nil?
112
+ contact.custom_fields.each do |custom_field|
113
+ if custom_field.name.match('custom_field_')
114
+ custom_field_number = custom_field.name[13, custom_field.name.length]
115
+ used_columns << Util::Config.get('activities_columns.custom_field_' + custom_field_number)
116
+ end
107
117
  end
108
118
  end
109
119
  end
110
120
 
111
- @column_names = used_columns
121
+ @column_names = used_columns.uniq
112
122
  end
113
123
  end
114
124
 
@@ -8,15 +8,16 @@ module ConstantContact
8
8
  module Components
9
9
  class AddContactsImportData < Component
10
10
  attr_accessor :first_name, :middle_name, :last_name, :job_title, :company_name,
11
- :work_phone, :home_phone, :email_addresses, :addresses, :custom_fields
11
+ :work_phone, :home_phone, :birthday_month, :birthday_day, :anniversary,
12
+ :email_addresses, :addresses, :custom_fields
12
13
 
13
14
 
14
15
  # Constructor to create an AddContactsImportData object from the given hash
15
16
  # @param [Hash] props - properties to create object from
16
17
  # @return [AddContactsImportData]
17
18
  def initialize(props = {})
18
- instance_variables.each do |property, value|
19
- send("#{property}=", get_value(props, property)) if obj.respond_to? property
19
+ props.each do |key, value|
20
+ send("#{key}=", value) if respond_to? key
20
21
  end
21
22
  end
22
23
 
@@ -100,6 +100,9 @@ module ConstantContact
100
100
  :first_name => 'FIRST NAME',
101
101
  :middle_name => 'MIDDLE NAME',
102
102
  :last_name => 'LAST NAME',
103
+ :birthday_day => 'BIRTHDAY_DAY',
104
+ :birthday_month => 'BIRTHDAY_MONTH',
105
+ :anniversary => 'ANNIVERSARY',
103
106
  :job_title => 'JOB TITLE',
104
107
  :company_name => 'COMPANY NAME',
105
108
  :work_phone => 'WORK PHONE',
@@ -7,6 +7,6 @@
7
7
  module ConstantContact
8
8
  module SDK
9
9
  # Gem version
10
- VERSION = "2.0.1"
10
+ VERSION = "2.1.0"
11
11
  end
12
12
  end
@@ -1132,44 +1132,88 @@ describe ConstantContact::Api do
1132
1132
 
1133
1133
  describe "#add_create_contacts_activity" do
1134
1134
  it "adds an AddContacts activity to add contacts in bulk" do
1135
- json_add_contacts = load_file('add_contacts_response.json')
1136
- json_lists = load_file('lists_response.json')
1137
- json_contacts = load_file('contacts_response.json')
1135
+ json_request = load_file('add_contacts_request.json')
1136
+ json_response = load_file('add_contacts_response.json')
1138
1137
  net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
1139
1138
 
1140
- response = RestClient::Response.create(json_add_contacts, net_http_resp, {}, @request)
1139
+ response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
1141
1140
  RestClient.stub(:post).and_return(response)
1142
1141
 
1143
- import = ConstantContact::Components::AddContactsImportData.new
1142
+ contacts = []
1143
+
1144
+ # first contact
1145
+ import = ConstantContact::Components::AddContactsImportData.new({
1146
+ :first_name => "John",
1147
+ :last_name => "Smith",
1148
+ :birthday_month => "1",
1149
+ :birthday_day => "25",
1150
+ :anniversary => "03/12/2005",
1151
+ :job_title => "",
1152
+ :company_name => "My Company",
1153
+ :home_phone => "5555551212"
1154
+ })
1155
+
1156
+ # add emails
1157
+ import.add_email("user1@example.com")
1158
+
1159
+ # add addresses
1144
1160
  address = ConstantContact::Components::Address.create(
1145
- :line1 => "1601 Trapelo Rd",
1146
- :city => "Waltham",
1147
- :state => "MA"
1161
+ :line1 => "123 Partridge Lane",
1162
+ :line2 => "Apt. 3",
1163
+ :city => "Anytown",
1164
+ :address_type => "PERSONAL",
1165
+ :state_code => "NH",
1166
+ :country_code => "US",
1167
+ :postal_code => "02145"
1148
1168
  )
1149
1169
  import.add_address(address)
1150
1170
 
1171
+ contacts << import
1172
+
1173
+ # second contact
1174
+ import = ConstantContact::Components::AddContactsImportData.new({
1175
+ :first_name => "Jane",
1176
+ :last_name => "Doe",
1177
+ :job_title => "",
1178
+ :company_name => "Acme, Inc.",
1179
+ :home_phone => "5555551213"
1180
+ })
1181
+
1182
+ # add emails
1183
+ import.add_email("user2@example.com")
1184
+
1185
+ # add addresses
1186
+ address = ConstantContact::Components::Address.create(
1187
+ :line1 => "456 Jones Road",
1188
+ :city => "AnyTownShip",
1189
+ :address_type => "PERSONAL",
1190
+ :state_code => "DE",
1191
+ :country_code => "US",
1192
+ :postal_code => "01234"
1193
+ )
1194
+ import.add_address(address)
1195
+
1196
+ # add custom fields
1151
1197
  custom_field = ConstantContact::Components::CustomField.create(
1152
- :name => "custom_field_1",
1153
- :value => "my custom value"
1198
+ :name => "custom_field_6",
1199
+ :value => "Blue Jeans"
1200
+ )
1201
+ import.add_custom_field(custom_field)
1202
+
1203
+ custom_field = ConstantContact::Components::CustomField.create(
1204
+ :name => "custom_field_12",
1205
+ :value => "Special Order"
1154
1206
  )
1155
1207
  import.add_custom_field(custom_field)
1156
- import.add_email("abc@def.com")
1157
1208
 
1158
- contacts = []
1159
1209
  contacts << import
1160
- contacts_objects = JSON.parse(json_contacts)
1161
- contacts_objects['results'].each do |contact|
1162
- contacts << ConstantContact::Components::Contact.create(contact)
1163
- end
1164
1210
 
1165
- lists = []
1166
- lists_objects = JSON.parse(json_lists)
1167
- lists_objects.each do |list|
1168
- lists << ConstantContact::Components::ContactList.create(list)
1169
- end
1211
+ lists = ['4', '5', '6']
1170
1212
 
1171
1213
  add_contact = ConstantContact::Components::AddContacts.new(contacts, lists)
1172
1214
 
1215
+ JSON.parse(json_request).should eq(JSON.parse(JSON.generate(add_contact)))
1216
+
1173
1217
  activity = @api.add_create_contacts_activity(add_contact)
1174
1218
  activity.should be_kind_of(ConstantContact::Components::Activity)
1175
1219
  activity.type.should eq('ADD_CONTACTS')
@@ -41,44 +41,88 @@ describe ConstantContact::Services::ActivityService do
41
41
 
42
42
  describe "#create_add_contacts_activity" do
43
43
  it "creates an Add Contacts Activity" do
44
- json_add_contacts = load_file('add_contacts_response.json')
45
- json_lists = load_file('lists_response.json')
46
- json_contacts = load_file('contacts_response.json')
44
+ json_request = load_file('add_contacts_request.json')
45
+ json_response = load_file('add_contacts_response.json')
47
46
  net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
48
47
 
49
- response = RestClient::Response.create(json_add_contacts, net_http_resp, {}, @request)
48
+ response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
50
49
  RestClient.stub(:post).and_return(response)
51
50
 
52
- import = ConstantContact::Components::AddContactsImportData.new
51
+ contacts = []
52
+
53
+ # first contact
54
+ import = ConstantContact::Components::AddContactsImportData.new({
55
+ :first_name => "John",
56
+ :last_name => "Smith",
57
+ :birthday_month => "1",
58
+ :birthday_day => "25",
59
+ :anniversary => "03/12/2005",
60
+ :job_title => "",
61
+ :company_name => "My Company",
62
+ :home_phone => "5555551212"
63
+ })
64
+
65
+ # add emails
66
+ import.add_email("user1@example.com")
67
+
68
+ # add addresses
69
+ address = ConstantContact::Components::Address.create(
70
+ :line1 => "123 Partridge Lane",
71
+ :line2 => "Apt. 3",
72
+ :city => "Anytown",
73
+ :address_type => "PERSONAL",
74
+ :state_code => "NH",
75
+ :country_code => "US",
76
+ :postal_code => "02145"
77
+ )
78
+ import.add_address(address)
79
+
80
+ contacts << import
81
+
82
+ # second contact
83
+ import = ConstantContact::Components::AddContactsImportData.new({
84
+ :first_name => "Jane",
85
+ :last_name => "Doe",
86
+ :job_title => "",
87
+ :company_name => "Acme, Inc.",
88
+ :home_phone => "5555551213"
89
+ })
90
+
91
+ # add emails
92
+ import.add_email("user2@example.com")
93
+
94
+ # add addresses
53
95
  address = ConstantContact::Components::Address.create(
54
- :line1 => "1601 Trapelo Rd",
55
- :city => "Waltham",
56
- :state => "MA"
96
+ :line1 => "456 Jones Road",
97
+ :city => "AnyTownShip",
98
+ :address_type => "PERSONAL",
99
+ :state_code => "DE",
100
+ :country_code => "US",
101
+ :postal_code => "01234"
57
102
  )
58
103
  import.add_address(address)
59
104
 
105
+ # add custom fields
60
106
  custom_field = ConstantContact::Components::CustomField.create(
61
- :name => "custom_field_1",
62
- :value => "my custom value"
107
+ :name => "custom_field_6",
108
+ :value => "Blue Jeans"
109
+ )
110
+ import.add_custom_field(custom_field)
111
+
112
+ custom_field = ConstantContact::Components::CustomField.create(
113
+ :name => "custom_field_12",
114
+ :value => "Special Order"
63
115
  )
64
116
  import.add_custom_field(custom_field)
65
- import.add_email("abc@def.com")
66
117
 
67
- contacts = []
68
118
  contacts << import
69
- contacts_objects = JSON.parse(json_contacts)
70
- contacts_objects['results'].each do |contact|
71
- contacts << ConstantContact::Components::Contact.create(contact)
72
- end
73
119
 
74
- lists = []
75
- lists_objects = JSON.parse(json_lists)
76
- lists_objects.each do |list|
77
- lists << ConstantContact::Components::ContactList.create(list)
78
- end
120
+ lists = ['4', '5', '6']
79
121
 
80
122
  add_contact = ConstantContact::Components::AddContacts.new(contacts, lists)
81
123
 
124
+ JSON.parse(json_request).should eq(JSON.parse(JSON.generate(add_contact)))
125
+
82
126
  activity = ConstantContact::Services::ActivityService.create_add_contacts_activity(add_contact)
83
127
  activity.should be_kind_of(ConstantContact::Components::Activity)
84
128
  activity.type.should eq('ADD_CONTACTS')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constantcontact
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ConstantContact
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client