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
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# webhooks_util.rb
|
3
|
+
# ConstantContact
|
4
|
+
#
|
5
|
+
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
|
+
|
7
|
+
module ConstantContact
|
8
|
+
class WebhooksUtil
|
9
|
+
attr_accessor :client_secret
|
10
|
+
|
11
|
+
# Class constructor
|
12
|
+
# @param [String] api_secret - the Constant Contact secret key
|
13
|
+
# @return
|
14
|
+
def initialize(api_secret = nil)
|
15
|
+
@client_secret = api_secret || Util::Config.get('auth.api_secret')
|
16
|
+
if @client_secret.nil? || @client_secret == ''
|
17
|
+
raise ArgumentError.new(Util::Config.get('errors.api_secret_missing'))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Get the BillingChangeNotification model object (has url and event_type as properties)
|
23
|
+
# Validates and parses the received data into a BillingChangeNotification model
|
24
|
+
# @param [String] hmac The value in the x-ctct-hmac-sha256 header.
|
25
|
+
# @param [String] data The body message from the POST received from ConstantContact in Webhook callback.
|
26
|
+
# @return [BillingChangeNotification] object corresponding to data in case of success
|
27
|
+
def get_billing_change_notification(hmac, data)
|
28
|
+
if is_valid_webhook(hmac, data)
|
29
|
+
Webhooks::Models::BillingChangeNotification.create(JSON.parse(data))
|
30
|
+
else
|
31
|
+
raise Exceptions::WebhooksException, Util::Config.get('errors.invalid_webhook')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Validates a Webhook encrypted message
|
37
|
+
# @param [String] hmac The value in the x-ctct-hmac-sha256 header.
|
38
|
+
# @param [String] data The body message from the POST received from ConstantContact in Webhook callback.
|
39
|
+
# @return true in case of success; false if the Webhook is invalid.
|
40
|
+
def is_valid_webhook(hmac, data)
|
41
|
+
Webhooks::Helpers::Validator.validate(@client_secret, hmac, data)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#
|
2
|
+
# constantcontact.rb
|
3
|
+
# ConstantContact
|
4
|
+
#
|
5
|
+
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rest_client'
|
9
|
+
require 'json'
|
10
|
+
require 'cgi'
|
11
|
+
require 'cgi/session'
|
12
|
+
require 'cgi/session/pstore'
|
13
|
+
require 'openssl'
|
14
|
+
require 'base64'
|
15
|
+
|
16
|
+
module ConstantContact
|
17
|
+
autoload :Api, 'constantcontact/api'
|
18
|
+
autoload :WebhooksUtil, 'constantcontact/webhooks/webhooks_util'
|
19
|
+
autoload :SDK, 'constantcontact/version'
|
20
|
+
|
21
|
+
module Auth
|
22
|
+
autoload :OAuth2, 'constantcontact/auth/oauth2'
|
23
|
+
autoload :Session, 'constantcontact/auth/session_data_store'
|
24
|
+
end
|
25
|
+
|
26
|
+
module Components
|
27
|
+
autoload :Component, 'constantcontact/components/component'
|
28
|
+
autoload :ResultSet, 'constantcontact/components/result_set'
|
29
|
+
autoload :Activity, 'constantcontact/components/activities/activity'
|
30
|
+
autoload :ActivityError, 'constantcontact/components/activities/activity_error'
|
31
|
+
autoload :AddContacts, 'constantcontact/components/activities/add_contacts'
|
32
|
+
autoload :AddContactsImportData, 'constantcontact/components/activities/add_contacts_import_data'
|
33
|
+
autoload :ExportContacts, 'constantcontact/components/activities/export_contacts'
|
34
|
+
autoload :Address, 'constantcontact/components/contacts/address'
|
35
|
+
autoload :Contact, 'constantcontact/components/contacts/contact'
|
36
|
+
autoload :ContactList, 'constantcontact/components/contacts/contact_list'
|
37
|
+
autoload :CustomField, 'constantcontact/components/contacts/custom_field'
|
38
|
+
autoload :EmailAddress, 'constantcontact/components/contacts/email_address'
|
39
|
+
autoload :Note, 'constantcontact/components/contacts/note'
|
40
|
+
autoload :ClickThroughDetails, 'constantcontact/components/email_marketing/click_through_details'
|
41
|
+
autoload :Campaign, 'constantcontact/components/email_marketing/campaign'
|
42
|
+
autoload :CampaignPreview, 'constantcontact/components/email_marketing/campaign_preview'
|
43
|
+
autoload :MessageFooter, 'constantcontact/components/email_marketing/message_footer'
|
44
|
+
autoload :Schedule, 'constantcontact/components/email_marketing/schedule'
|
45
|
+
autoload :TestSend, 'constantcontact/components/email_marketing/test_send'
|
46
|
+
autoload :BounceActivity, 'constantcontact/components/tracking/bounce_activity'
|
47
|
+
autoload :ClickActivity, 'constantcontact/components/tracking/click_activity'
|
48
|
+
autoload :ForwardActivity, 'constantcontact/components/tracking/forward_activity'
|
49
|
+
autoload :OpenActivity, 'constantcontact/components/tracking/open_activity'
|
50
|
+
autoload :UnsubscribeActivity, 'constantcontact/components/tracking/unsubscribe_activity'
|
51
|
+
autoload :SendActivity, 'constantcontact/components/tracking/send_activity'
|
52
|
+
autoload :TrackingActivity, 'constantcontact/components/tracking/tracking_activity'
|
53
|
+
autoload :TrackingSummary, 'constantcontact/components/tracking/tracking_summary'
|
54
|
+
autoload :VerifiedEmailAddress, 'constantcontact/components/account/verified_email_address'
|
55
|
+
autoload :AccountInfo, 'constantcontact/components/account/account_info'
|
56
|
+
autoload :AccountAddress, 'constantcontact/components/account/account_address'
|
57
|
+
autoload :Event, 'constantcontact/components/event_spot/event'
|
58
|
+
autoload :EventFee, 'constantcontact/components/event_spot/event_fee'
|
59
|
+
autoload :Registrant, 'constantcontact/components/event_spot/registrant'
|
60
|
+
autoload :EventItem, 'constantcontact/components/event_spot/event_item'
|
61
|
+
autoload :EventItemAttribute, 'constantcontact/components/event_spot/event_item_attribute'
|
62
|
+
autoload :Promocode, 'constantcontact/components/event_spot/promocode'
|
63
|
+
autoload :LibrarySummary, 'constantcontact/components/library/info/library_summary'
|
64
|
+
autoload :UploadStatus, 'constantcontact/components/library/info/upload_status'
|
65
|
+
autoload :MoveResults, 'constantcontact/components/library/info/move_results'
|
66
|
+
autoload :LibraryFolder, 'constantcontact/components/library/folder/library_folder'
|
67
|
+
autoload :LibraryFile, 'constantcontact/components/library/file/library_file'
|
68
|
+
|
69
|
+
module EventSpot
|
70
|
+
autoload :EventAddress, 'constantcontact/components/event_spot/event_address'
|
71
|
+
autoload :Contact, 'constantcontact/components/event_spot/contact'
|
72
|
+
autoload :NotificationOption, 'constantcontact/components/event_spot/notification_option'
|
73
|
+
autoload :OnlineMeeting, 'constantcontact/components/event_spot/online_meeting'
|
74
|
+
autoload :PaymentAddress, 'constantcontact/components/event_spot/payment_address'
|
75
|
+
autoload :PaymentSummary, 'constantcontact/components/event_spot/payment_summary'
|
76
|
+
autoload :Guest, 'constantcontact/components/event_spot/guest'
|
77
|
+
autoload :GuestSection, 'constantcontact/components/event_spot/guest_section'
|
78
|
+
autoload :EventTrack, 'constantcontact/components/event_spot/event_track'
|
79
|
+
autoload :RegistrantFee, 'constantcontact/components/event_spot/registrant_fee'
|
80
|
+
autoload :RegistrantField, 'constantcontact/components/event_spot/registrant_field'
|
81
|
+
autoload :RegistrantOrder, 'constantcontact/components/event_spot/registrant_order'
|
82
|
+
autoload :RegistrantPromoCode, 'constantcontact/components/event_spot/registrant_promo_code'
|
83
|
+
autoload :RegistrantPromoCodeInfo, 'constantcontact/components/event_spot/registrant_promo_code_info'
|
84
|
+
autoload :RegistrantSection, 'constantcontact/components/event_spot/registrant_section'
|
85
|
+
autoload :SaleItem, 'constantcontact/components/event_spot/sale_item'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
module Exceptions
|
90
|
+
autoload :CtctException, 'constantcontact/exceptions/ctct_exception'
|
91
|
+
autoload :IllegalArgumentException, 'constantcontact/exceptions/illegal_argument_exception'
|
92
|
+
autoload :OAuth2Exception, 'constantcontact/exceptions/oauth2_exception'
|
93
|
+
autoload :WebhooksException, 'constantcontact/exceptions/webhooks_exception'
|
94
|
+
end
|
95
|
+
|
96
|
+
module Services
|
97
|
+
autoload :BaseService, 'constantcontact/services/base_service'
|
98
|
+
autoload :ActivityService, 'constantcontact/services/activity_service'
|
99
|
+
autoload :CampaignScheduleService, 'constantcontact/services/campaign_schedule_service'
|
100
|
+
autoload :CampaignTrackingService, 'constantcontact/services/campaign_tracking_service'
|
101
|
+
autoload :ContactService, 'constantcontact/services/contact_service'
|
102
|
+
autoload :ContactTrackingService, 'constantcontact/services/contact_tracking_service'
|
103
|
+
autoload :EmailMarketingService, 'constantcontact/services/email_marketing_service'
|
104
|
+
autoload :ListService, 'constantcontact/services/list_service'
|
105
|
+
autoload :AccountService, 'constantcontact/services/account_service'
|
106
|
+
autoload :EventSpotService, 'constantcontact/services/event_spot_service'
|
107
|
+
autoload :LibraryService, 'constantcontact/services/library_service'
|
108
|
+
end
|
109
|
+
|
110
|
+
module Util
|
111
|
+
autoload :Config, 'constantcontact/util/config'
|
112
|
+
autoload :Helpers, 'constantcontact/util/helpers'
|
113
|
+
end
|
114
|
+
|
115
|
+
module Webhooks
|
116
|
+
module Helpers
|
117
|
+
autoload :Validator, 'constantcontact/webhooks/helpers/validator'
|
118
|
+
end
|
119
|
+
|
120
|
+
module Models
|
121
|
+
autoload :BillingChangeNotification, 'constantcontact/webhooks/models/billing_change_notification'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|