createsend-sendowlfork 6.1.0.pre.hashie5
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/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.travis.yml +7 -0
- data/CONTRIBUTING.md +8 -0
- data/Gemfile +3 -0
- data/HISTORY.md +299 -0
- data/LICENSE +19 -0
- data/README.md +220 -0
- data/RELEASE.md +53 -0
- data/Rakefile +24 -0
- data/createsend.gemspec +31 -0
- data/lib/createsend/administrator.rb +49 -0
- data/lib/createsend/cacert.pem +3849 -0
- data/lib/createsend/campaign.rb +202 -0
- data/lib/createsend/client.rb +224 -0
- data/lib/createsend/createsend.rb +291 -0
- data/lib/createsend/journey.rb +58 -0
- data/lib/createsend/list.rb +258 -0
- data/lib/createsend/person.rb +59 -0
- data/lib/createsend/segment.rb +81 -0
- data/lib/createsend/subscriber.rb +113 -0
- data/lib/createsend/template.rb +42 -0
- data/lib/createsend/transactional_classic_email.rb +32 -0
- data/lib/createsend/transactional_smart_email.rb +31 -0
- data/lib/createsend/transactional_timeline.rb +45 -0
- data/lib/createsend/version.rb +3 -0
- data/lib/createsend.rb +17 -0
- data/samples/authentication_sample.rb +64 -0
- data/samples/clients_sample.rb +79 -0
- data/samples/journey_sample.rb +87 -0
- data/samples/lists_sample.rb +51 -0
- data/samples/segments_sample.rb +21 -0
- data/samples/subscribers_sample.rb +51 -0
- data/test/administrator_test.rb +37 -0
- data/test/campaign_test.rb +296 -0
- data/test/client_test.rb +253 -0
- data/test/createsend_test.rb +321 -0
- data/test/fixtures/active_subscribers.json +87 -0
- data/test/fixtures/add_admin.json +3 -0
- data/test/fixtures/add_person.json +3 -0
- data/test/fixtures/add_subscriber.json +1 -0
- data/test/fixtures/admin_details.json +5 -0
- data/test/fixtures/admin_get_primary_contact.json +3 -0
- data/test/fixtures/admin_set_primary_contact.json +3 -0
- data/test/fixtures/administrators.json +12 -0
- data/test/fixtures/billingdetails.json +3 -0
- data/test/fixtures/bounced_subscribers.json +20 -0
- data/test/fixtures/campaign_bounces.json +25 -0
- data/test/fixtures/campaign_clicks.json +50 -0
- data/test/fixtures/campaign_listsandsegments.json +15 -0
- data/test/fixtures/campaign_opens.json +71 -0
- data/test/fixtures/campaign_recipients.json +91 -0
- data/test/fixtures/campaign_spam.json +16 -0
- data/test/fixtures/campaign_summary.json +16 -0
- data/test/fixtures/campaign_unsubscribes.json +17 -0
- data/test/fixtures/campaigns.json +37 -0
- data/test/fixtures/client_details.json +28 -0
- data/test/fixtures/client_get_primary_contact.json +3 -0
- data/test/fixtures/client_set_primary_contact.json +3 -0
- data/test/fixtures/clients.json +10 -0
- data/test/fixtures/countries.json +247 -0
- data/test/fixtures/create_campaign.json +1 -0
- data/test/fixtures/create_client.json +1 -0
- data/test/fixtures/create_custom_field.json +1 -0
- data/test/fixtures/create_list.json +1 -0
- data/test/fixtures/create_list_webhook.json +1 -0
- data/test/fixtures/create_segment.json +1 -0
- data/test/fixtures/create_template.json +1 -0
- data/test/fixtures/custom_api_error.json +4 -0
- data/test/fixtures/custom_fields.json +23 -0
- data/test/fixtures/deleted_subscribers.json +61 -0
- data/test/fixtures/drafts.json +26 -0
- data/test/fixtures/email_client_usage.json +38 -0
- data/test/fixtures/expired_oauth_token_api_error.json +4 -0
- data/test/fixtures/external_session.json +3 -0
- data/test/fixtures/import_subscribers.json +7 -0
- data/test/fixtures/import_subscribers_partial_success.json +17 -0
- data/test/fixtures/invalid_oauth_token_api_error.json +4 -0
- data/test/fixtures/journey_bounces.json +35 -0
- data/test/fixtures/journey_clicks.json +35 -0
- data/test/fixtures/journey_opens.json +55 -0
- data/test/fixtures/journey_recipients.json +27 -0
- data/test/fixtures/journey_summary.json +18 -0
- data/test/fixtures/journey_unsubscribes.json +26 -0
- data/test/fixtures/journeys.json +20 -0
- data/test/fixtures/list_details.json +8 -0
- data/test/fixtures/list_stats.json +26 -0
- data/test/fixtures/list_webhooks.json +18 -0
- data/test/fixtures/lists.json +10 -0
- data/test/fixtures/listsforemail.json +14 -0
- data/test/fixtures/oauth_exchange_token.json +5 -0
- data/test/fixtures/oauth_exchange_token_error.json +4 -0
- data/test/fixtures/oauth_refresh_token_error.json +4 -0
- data/test/fixtures/people.json +14 -0
- data/test/fixtures/person_details.json +6 -0
- data/test/fixtures/refresh_oauth_token.json +5 -0
- data/test/fixtures/revoked_oauth_token_api_error.json +4 -0
- data/test/fixtures/scheduled_campaigns.json +30 -0
- data/test/fixtures/segment_details.json +24 -0
- data/test/fixtures/segment_subscribers.json +27 -0
- data/test/fixtures/segments.json +12 -0
- data/test/fixtures/subscriber_details.json +23 -0
- data/test/fixtures/subscriber_details_with_track_and_sms_pref.json +25 -0
- data/test/fixtures/subscriber_history.json +45 -0
- data/test/fixtures/suppressionlist.json +41 -0
- data/test/fixtures/systemdate.json +3 -0
- data/test/fixtures/tags.json +10 -0
- data/test/fixtures/template_details.json +6 -0
- data/test/fixtures/templates.json +14 -0
- data/test/fixtures/timezones.json +99 -0
- data/test/fixtures/transfer_credits.json +4 -0
- data/test/fixtures/tx_classicemail_groups.json +14 -0
- data/test/fixtures/tx_message_details.json +36 -0
- data/test/fixtures/tx_message_details_with_statistics.json +72 -0
- data/test/fixtures/tx_messages.json +38 -0
- data/test/fixtures/tx_messages_classic.json +15 -0
- data/test/fixtures/tx_messages_smart.json +15 -0
- data/test/fixtures/tx_resend_message.json +6 -0
- data/test/fixtures/tx_send_multiple.json +12 -0
- data/test/fixtures/tx_send_single.json +7 -0
- data/test/fixtures/tx_smartemail_details.json +23 -0
- data/test/fixtures/tx_smartemails.json +15 -0
- data/test/fixtures/tx_statistics_classic.json +14 -0
- data/test/fixtures/tx_statistics_smart.json +14 -0
- data/test/fixtures/unconfirmed_subscribers.json +43 -0
- data/test/fixtures/unsubscribed_subscribers.json +61 -0
- data/test/fixtures/update_custom_field.json +1 -0
- data/test/helper.rb +79 -0
- data/test/journey_test.rb +156 -0
- data/test/list_test.rb +288 -0
- data/test/person_test.rb +39 -0
- data/test/segment_test.rb +74 -0
- data/test/subscriber_test.rb +177 -0
- data/test/template_test.rb +36 -0
- data/test/transactional_classic_email_test.rb +60 -0
- data/test/transactional_smart_email_test.rb +83 -0
- data/test/transactional_timeline_test.rb +110 -0
- metadata +431 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ca60d5afa58a830b8adf97896ae64dba5bc8e97551b977739462c25720e3af33
|
4
|
+
data.tar.gz: 36b122611ce877ae30bec07846450a19279a3a5c713a7e1a0c32f9d8db360bdf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 845fdca84b22acaa047655d30730da0ed53bef30368b98a85c0fcb22661c8acb9d48f5c51ecc7193651fe6689bdf9a485d4d24d6565001120f587b2849d4cdf3
|
7
|
+
data.tar.gz: b7ea9e44cb6d65a3ddf4457a15d983bc97a4e81807edcae329c617dfaee4ead5ab99306b946e5830517cd17911b1b81f0d8b5e1cd842b7dea7e5f560346c7277
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Guidelines for contributing
|
2
|
+
|
3
|
+
1. [Fork the repository](https://help.github.com/articles/fork-a-repo).
|
4
|
+
2. Create a topic branch.
|
5
|
+
3. Make your changes, including tests for your changes which maintain [coverage](https://coveralls.io/r/campaignmonitor/createsend-ruby).
|
6
|
+
4. Ensure that all tests pass, by running `bundle exec rake`.
|
7
|
+
5. It should go without saying, but do not increment the version number in your commits.
|
8
|
+
6. [Submit a pull request](https://help.github.com/articles/using-pull-requests).
|
data/Gemfile
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
# createsend-ruby history
|
2
|
+
|
3
|
+
## v6.1.0 - 27 Oct 2023
|
4
|
+
* Added support for add/update subscribers specifying mobile_number and/or consent_to_send_sms (optional parameters)
|
5
|
+
* Subscriber.Add
|
6
|
+
* Subscriber.Update()
|
7
|
+
* Added support for lists endpoints to be able to return the ConsentToSendSms (keyword parameter, is optional)
|
8
|
+
* List.Active(include_sms_preference:true)
|
9
|
+
* List.Bounced(include_sms_preference:true)
|
10
|
+
* List.Unsubscribed(include_sms_preference:true)
|
11
|
+
* List.Unconfirmed(include_sms_preference:true)
|
12
|
+
* List.Deleted(include_sms_preference:true)
|
13
|
+
* Clean-up various warnings associated with this package (excluding dependency package warning)
|
14
|
+
* Add more samples
|
15
|
+
|
16
|
+
## v6.0.0 - 10 Feb, 2022
|
17
|
+
* Upgrades to Createsend API v3.3 which includes new breaking changes
|
18
|
+
* Breaking: 'client.campaigns' now returned an object to support pagination (use .Results to ge the array of campaigns)
|
19
|
+
* Added 'Tags' as another field that is returned in 'client.scheduled', 'client.drafts' and 'client.campaigns'
|
20
|
+
* Added 'Name' as another field that is returned in 'campaign.summary'
|
21
|
+
* Add new support for 'client.tags' endpoint (ie: getting list of tags for the client)
|
22
|
+
* Add support for pagination, filtering and sorting to 'client.campaigns' endpoint
|
23
|
+
* Bump `rake` to `~> 12.3.3`
|
24
|
+
* Adding support for returning ListJoinedDate for each subscriber.
|
25
|
+
* List.Active()
|
26
|
+
* List.Bounced()
|
27
|
+
* List.Unsubscribed()
|
28
|
+
* List.Unconfirmed()
|
29
|
+
* List.Deleted()
|
30
|
+
* Segment.Subscribers()
|
31
|
+
* Subscriber.Get()
|
32
|
+
|
33
|
+
## v5.1.1 - 8 Oct, 2021
|
34
|
+
* increased default timeout for HTTP requests to 120secs
|
35
|
+
|
36
|
+
## v5.1.0 - 3 Sep, 2019
|
37
|
+
* Added support for [Journeys API](https://www.campaignmonitor.com/api/journeys/)
|
38
|
+
|
39
|
+
## v5.0.0 - 19 Jun, 2018
|
40
|
+
* Upgrades to Createsend API v3.2 which includes new breaking changes
|
41
|
+
* Breaking: 'Consent to track' field is now mandatory for sending smart and classic transactionl emails
|
42
|
+
* Breaking: 'Consent to track' field is now mandatory when adding or updating subscribers
|
43
|
+
* Optional 'Include tracking preference' field when retrieving lists of subscribers
|
44
|
+
|
45
|
+
## v4.1.2 - 27 Nov, 2017
|
46
|
+
* Fix for the GZip compression issue: https://github.com/jnunemaker/httparty/issues/562
|
47
|
+
|
48
|
+
## v4.1.1 - 14 Jan, 2016
|
49
|
+
|
50
|
+
* Drop support for Ruby 1.9.3 ([#49](https://github.com/campaignmonitor/createsend-ruby/pull/49))
|
51
|
+
* Allow JSON 2 to be used ([#48](https://github.com/campaignmonitor/createsend-ruby/pull/48) and [#50](https://github.com/campaignmonitor/createsend-ruby/pull/50))
|
52
|
+
* Bump `httparty` to `~> 0.14` ([#50](https://github.com/campaignmonitor/createsend-ruby/pull/50))
|
53
|
+
|
54
|
+
## v4.1.0 - 4 Aug, 2015
|
55
|
+
|
56
|
+
* Added support for Transactional Email
|
57
|
+
|
58
|
+
## v4.0.2 - 15 Oct, 2014
|
59
|
+
|
60
|
+
* Bumped and simplified `hashie` dependency to `~> 3.0`
|
61
|
+
|
62
|
+
## v4.0.1 - 3 May, 2014
|
63
|
+
|
64
|
+
* This is a patch release which only changes development dependencies.
|
65
|
+
* Removed development dependency on `shoulda` and added more suitable dependency on `shoulda-context` instead.
|
66
|
+
|
67
|
+
## v4.0.0 - 19 Feb, 2014
|
68
|
+
|
69
|
+
* Removed `CreateSend::CreateSend#apikey` to promote using OAuth rather than basic auth with an API key.
|
70
|
+
* Started using the `https://api.createsend.com/api/v3.1/` API endpoint.
|
71
|
+
* Added support for new segments structure.
|
72
|
+
* Create and Update calls now require the new `rule_groups` structure, instead of a `rules` structure.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
CreateSend::Segment.create(auth, list_id, title, rule_groups)
|
76
|
+
CreateSend::Segment.update(title, rule_groups)
|
77
|
+
```
|
78
|
+
|
79
|
+
So for example, when you _previously_ would have created an argument like so:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
rules = [ { :Subject => "EmailAddress", :Clauses => [ "CONTAINS example.com" ] } ]
|
83
|
+
```
|
84
|
+
|
85
|
+
You would _now_ do this:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
rule_groups = [ { :Rules => [ { :RuleType => "EmailAddress", :Clause => "CONTAINS example.com" } ] } ]
|
89
|
+
```
|
90
|
+
|
91
|
+
* The Add Rule call is now Add Rule Group, taking a collection of rules in a single `rule_group` argument instead of separate `subject` & `clauses` arguments.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
CreateSend::Segment.add_rule_group(rule_group)
|
95
|
+
```
|
96
|
+
|
97
|
+
So for example, when you _previously_ would have added a rule like so:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
@segment.add_rule "EmailAddress", [ "CONTAINS example.com" ]
|
101
|
+
```
|
102
|
+
|
103
|
+
You would _now_ do this:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
@segment.add_rule_group [ { :RuleType => "EmailAddress", :Clause => "CONTAINS @hello.com" } ]
|
107
|
+
```
|
108
|
+
|
109
|
+
## v3.4.0 - 5 Jul, 2013
|
110
|
+
|
111
|
+
* Added support for validating SSL certificates to avoid man-in-the-middle attacks.
|
112
|
+
|
113
|
+
## v3.3.0 - 16 May, 2013
|
114
|
+
|
115
|
+
* Added Ruby version and platform details to default user agent string.
|
116
|
+
* Added support for setting a custom user agent string.
|
117
|
+
|
118
|
+
You can set a custom user agent string to be used for API calls by doing the following:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
CreateSend::CreateSend.user_agent "custom user agent"
|
122
|
+
```
|
123
|
+
|
124
|
+
## v3.2.0 - 15 Apr, 2013
|
125
|
+
|
126
|
+
* Added support for [single sign on](http://www.campaignmonitor.com/api/account/#single_sign_on) which allows initiation of external login sessions to Campaign Monitor.
|
127
|
+
|
128
|
+
## v3.1.1 - 10 Apr, 2013
|
129
|
+
|
130
|
+
* Fixed a bug occurring sometimes when refreshing OAuth access tokens, because of a URL encoding issue.
|
131
|
+
|
132
|
+
## v3.1.0 - 28 Mar, 2013
|
133
|
+
|
134
|
+
* Added `CreateSend::CreateSend.refresh_access_token` to allow easier refreshing of access tokens when using class methods.
|
135
|
+
|
136
|
+
So you can now refresh an access token using _any_ refresh token like so:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
access_token, expires_in, refresh_token =
|
140
|
+
CreateSend::CreateSend.refresh_access_token 'refresh token'
|
141
|
+
```
|
142
|
+
|
143
|
+
Or, you can refresh the _current_ access token (with your current refresh token) like so:
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
cs = CreateSend::CreateSend.new :access_token => 'access token',
|
147
|
+
:refresh_token => 'refresh token'
|
148
|
+
access_token, expires_in, refresh_token = cs.refresh_token
|
149
|
+
```
|
150
|
+
|
151
|
+
* Added `CreateSend::InvalidOAuthToken` and `CreateSend::RevokedOAuthToken` exceptions to make handling of OAuth exceptions in user code easier.
|
152
|
+
|
153
|
+
## v3.0.0 - 25 Mar, 2013
|
154
|
+
|
155
|
+
* Added support for authenticating using OAuth. See the [README](README.md#authenticating) for full usage instructions.
|
156
|
+
* Refactored authentication so that it is _always_ done at the instance level. This introduces some breaking changes, which are clearly explained below.
|
157
|
+
* Authentication is now _always_ done at the instance level.
|
158
|
+
|
159
|
+
So when you _previously_ would have authenticated using an API key as follows:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
CreateSend.api_key "your api key"
|
163
|
+
cs = CreateSend::CreateSend.new
|
164
|
+
cs.clients
|
165
|
+
```
|
166
|
+
|
167
|
+
If you want to authenticate using an API key, you should _now_ do this:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
auth = {:api_key => "your api key"}
|
171
|
+
cs = CreateSend::CreateSend.new auth
|
172
|
+
cs.clients
|
173
|
+
```
|
174
|
+
|
175
|
+
* Instances of `CreateSend::CreateSend` (and all subclasses) are now _always_ created by passing an `auth` hash as the first argument.
|
176
|
+
|
177
|
+
So for example, when you _previously_ would have called `CreateSend::Client.new` like so:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
CreateSend.api_key "your api key"
|
181
|
+
cl = CreateSend::Client.new "your client id"
|
182
|
+
```
|
183
|
+
|
184
|
+
You _now_ call `CreateSend::Client.new` like so:
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
auth = {:api_key => "your api key"}
|
188
|
+
cl = CreateSend::Client.new auth, "your client id"
|
189
|
+
```
|
190
|
+
|
191
|
+
* Any of the class methods on `CreateSend::CreateSend` (and all subclasses) are now _always_ called by passing an `auth` hash as the first argument.
|
192
|
+
|
193
|
+
So for example, when you _previously_ would have called `CreateSend::Subscriber.add` like so:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
CreateSend.api_key "your api key"
|
197
|
+
sub = CreateSend::Subscriber.add "list id", "dave@example.com", "Dave", [], true
|
198
|
+
```
|
199
|
+
|
200
|
+
You _now_ call `CreateSend::Subscriber.add` like so:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
auth = {:api_key => "your api key"}
|
204
|
+
sub = CreateSend::Subscriber.add auth, "list id", "dave@example.com", "Dave", [], true
|
205
|
+
```
|
206
|
+
|
207
|
+
## v2.5.1 - 4 Feb, 2013
|
208
|
+
|
209
|
+
* Updated dependencies in gemspec. Removed cane as a development dependency.
|
210
|
+
|
211
|
+
## v2.5.0 - 11 Dec, 2012
|
212
|
+
|
213
|
+
* Added support for including from name, from email, and reply to email in drafts, scheduled, and sent campaigns.
|
214
|
+
* Added support for campaign text version urls.
|
215
|
+
* Added support for transferring credits to/from a client.
|
216
|
+
* Added support for getting account billing details as well as client credits.
|
217
|
+
* Made all date fields optional when getting paged results.
|
218
|
+
|
219
|
+
## v2.4.0 - 5 Nov, 2012
|
220
|
+
|
221
|
+
* Added CreateSend::Campaign#email_client_usage.
|
222
|
+
* Added support for ReadsEmailWith field on subscriber objects.
|
223
|
+
* Added support for retrieving unconfirmed subscribers for a list.
|
224
|
+
* Added support for suppressing email addresses.
|
225
|
+
* Added support for retrieving spam complaints for a campaign, as well as
|
226
|
+
adding SpamComplaints field to campaign summary output.
|
227
|
+
* Added VisibleInPreferenceCenter field to custom field output.
|
228
|
+
* Added support for setting preference center visibility when creating custom
|
229
|
+
fields.
|
230
|
+
* Added the ability to update a custom field name and preference visibility.
|
231
|
+
* Added documentation explaining that text_url may now be nil or an empty
|
232
|
+
string when creating a campaign.
|
233
|
+
|
234
|
+
## v2.3.0 - 10 Oct, 2012
|
235
|
+
|
236
|
+
* Added support for creating campaigns from templates.
|
237
|
+
* Added support for unsuppressing an email address.
|
238
|
+
* Improved documentation and tests for getting active subscribers. Clearly
|
239
|
+
documented the data structure for multi option multi select fields.
|
240
|
+
|
241
|
+
## v2.2.0 - 17 Sep, 2012
|
242
|
+
|
243
|
+
* Added WorldviewURL field to campaign summary response.
|
244
|
+
* Added Latitude, Longitude, City, Region, CountryCode, and CountryName fields
|
245
|
+
to campaign opens and clicks response.
|
246
|
+
|
247
|
+
## v2.1.0 - 30 Aug, 2012
|
248
|
+
|
249
|
+
* Added support for basic / unlimited pricing.
|
250
|
+
|
251
|
+
## v2.0.0 - 22 Aug, 2012
|
252
|
+
|
253
|
+
* Added support for UnsubscribeSetting field when creating, updating and
|
254
|
+
getting list details.
|
255
|
+
* Added support for including AddUnsubscribesToSuppList and
|
256
|
+
ScrubActiveWithSuppList fields when updating a list.
|
257
|
+
* Added support for getting all client lists to which a subscriber with a
|
258
|
+
specific email address belongs.
|
259
|
+
* Removed deprecated warnings and disallowed calls to be made in a deprecated
|
260
|
+
manner.
|
261
|
+
|
262
|
+
## v1.1.1 - 24 Jul, 2012
|
263
|
+
|
264
|
+
* Added support for specifying whether subscription-based autoresponders
|
265
|
+
should be restarted when adding or updating subscribers.
|
266
|
+
|
267
|
+
## v1.1.0 - 11 Jul, 2012
|
268
|
+
|
269
|
+
* Added support for newly released team management functionality.
|
270
|
+
|
271
|
+
## v1.0.4 - 4 May, 2012
|
272
|
+
|
273
|
+
* Added Travis CI support.
|
274
|
+
* Added Gemnasium support.
|
275
|
+
* Fixes to usage of Shoulda and Hashie libraries.
|
276
|
+
|
277
|
+
## v1.0.3 - 3 Dec, 2011
|
278
|
+
|
279
|
+
* Fixes to support Ruby 1.9.* (both the library as well as the rake tasks).
|
280
|
+
* Fixed the User-Agent header so that it now uses the correct module VERSION.
|
281
|
+
|
282
|
+
## v1.0.2 - 31 Oct, 2011
|
283
|
+
|
284
|
+
* Added support for deleting a subscriber.
|
285
|
+
* Added support for specifying a 'clear' field when updating or importing
|
286
|
+
subscribers.
|
287
|
+
* Added support for queuing subscription-based autoresponders when importing
|
288
|
+
subscribers.
|
289
|
+
* Added support for retrieving deleted subscribers.
|
290
|
+
* Added support for including more social sharing stats in campaign summary.
|
291
|
+
* Added support for unscheduling a campaign.
|
292
|
+
|
293
|
+
## v1.0.1 - 25 Oct, 2011
|
294
|
+
|
295
|
+
* Remove CreateSendOptions and remove usage of yaml config file.
|
296
|
+
|
297
|
+
## v1.0.0 - 26 Sep, 2011
|
298
|
+
|
299
|
+
* Initial release which supports current Campaign Monitor API.
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010-2015 James Dennes
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
# createsend [](https://app.travis-ci.com/campaignmonitor/createsend-ruby)
|
2
|
+
|
3
|
+
A Ruby library which implements the complete functionality of the [Campaign Monitor API](http://www.campaignmonitor.com/api/). Requires Ruby >= 2.0.0.
|
4
|
+
|
5
|
+
## Quick start
|
6
|
+
|
7
|
+
Add the gem to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'createsend'
|
11
|
+
```
|
12
|
+
|
13
|
+
Or, install the gem:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install createsend
|
17
|
+
```
|
18
|
+
|
19
|
+
## Authenticating
|
20
|
+
|
21
|
+
The Campaign Monitor API supports authentication using either OAuth or an API key.
|
22
|
+
|
23
|
+
### Using OAuth
|
24
|
+
|
25
|
+
If you're developing a Rails or Rack based application, we recommend using [omniauth-createsend](https://github.com/jdennes/omniauth-createsend) to authenticate with the Campaign Monitor API. You might find this [example application](https://github.com/jdennes/createsendoauthtest) helpful.
|
26
|
+
|
27
|
+
If you don't use [omniauth-createsend](https://github.com/jdennes/omniauth-createsend), you'll need to get access tokens for your users by following the instructions included in the Campaign Monitor API [documentation](http://www.campaignmonitor.com/api/getting-started/#authenticating_with_oauth). This gem provides functionality to help you do this, as described below. There's also another [example application](https://gist.github.com/jdennes/4945412) you may wish to reference, which doesn't depend on any OAuth libraries.
|
28
|
+
|
29
|
+
#### Redirecting to the authorization URL
|
30
|
+
|
31
|
+
The first thing your application should do is redirect your user to the Campaign Monitor authorization URL where they will have the opportunity to approve your application to access their Campaign Monitor account. You can get this authorization URL by using `CreateSend::CreateSend.authorize_url`, like so:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'createsend'
|
35
|
+
|
36
|
+
authorize_url = CreateSend::CreateSend.authorize_url(
|
37
|
+
'Client ID for your application',
|
38
|
+
'Redirect URI for your application',
|
39
|
+
'The permission level your application requires',
|
40
|
+
'Optional state data to be included'
|
41
|
+
)
|
42
|
+
# Redirect your users to authorize_url.
|
43
|
+
```
|
44
|
+
|
45
|
+
#### Exchanging an OAuth code for an access token
|
46
|
+
|
47
|
+
If your user approves your application, they will then be redirected to the `redirect_uri` you specified, which will include a `code` parameter, and optionally a `state` parameter in the query string. Your application should implement a handler which can exchange the code passed to it for an access token, using `CreateSend::CreateSend.exchange_token` like so:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
require 'createsend'
|
51
|
+
|
52
|
+
access_token, expires_in, refresh_token = CreateSend::CreateSend.exchange_token(
|
53
|
+
'Client ID for your application',
|
54
|
+
'Client Secret for your application',
|
55
|
+
'Redirect URI for your application',
|
56
|
+
'A unique code for your user' # Get the code parameter from the query string
|
57
|
+
)
|
58
|
+
# Save access_token, expires_in, and refresh_token.
|
59
|
+
```
|
60
|
+
|
61
|
+
At this point you have an access token and refresh token for your user which you should store somewhere convenient so that your application can look up these values when your user wants to make future Campaign Monitor API calls.
|
62
|
+
|
63
|
+
#### Making API calls using an access token
|
64
|
+
|
65
|
+
Once you have an access token and refresh token for your user, you can use the `createsend` gem to authenticate and make further API calls like so:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
require 'createsend'
|
69
|
+
|
70
|
+
auth = {
|
71
|
+
:access_token => 'your access token',
|
72
|
+
:refresh_token => 'your refresh token'
|
73
|
+
}
|
74
|
+
cs = CreateSend::CreateSend.new auth
|
75
|
+
clients = cs.clients
|
76
|
+
```
|
77
|
+
|
78
|
+
#### Refreshing access tokens
|
79
|
+
|
80
|
+
All OAuth access tokens have an expiry time, and can be renewed with a refresh token. If your access token expires when attempting to make an API call, the `CreateSend::ExpiredOAuthToken` exception will be raised, so your code should handle this. You can handle this using either `CreateSend::CreateSend.refresh_access_token` (when calling class methods) or `CreateSend::CreateSend#refresh_token` (when calling instance methods).
|
81
|
+
|
82
|
+
Here's an example of using `CreateSend::CreateSend#refresh_token` to refresh your current access token when calling `CreateSend::CreateSend#clients`:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
require 'createsend'
|
86
|
+
|
87
|
+
auth = {
|
88
|
+
:access_token => 'your access token',
|
89
|
+
:refresh_token => 'your refresh token'
|
90
|
+
}
|
91
|
+
cs = CreateSend::CreateSend.new auth
|
92
|
+
|
93
|
+
begin
|
94
|
+
tries ||= 2
|
95
|
+
clients = cs.clients
|
96
|
+
rescue CreateSend::ExpiredOAuthToken => eot
|
97
|
+
access_token, expires_in, refresh_token = cs.refresh_token
|
98
|
+
# Here you should save your updated access token, 'expire in' value,
|
99
|
+
# and refresh token. `cs` will automatically have the new access token
|
100
|
+
# set, so there is no need to set it again.
|
101
|
+
retry unless (tries -= 1).zero?
|
102
|
+
p "Error: #{eot}"
|
103
|
+
rescue Exception => e
|
104
|
+
p "Error: #{e}"
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
In addition to raising `CreateSend::ExpiredOAuthToken` when an access token has expired, this library also raises `CreateSend::InvalidOAuthToken` if an invalid access token is used, and raises `CreateSend::RevokedOAuthToken` if a user has revoked the access token being used. This makes it easier for you to handle these cases in your code.
|
109
|
+
|
110
|
+
### Using an API key
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
require 'createsend'
|
114
|
+
|
115
|
+
cs = CreateSend::CreateSend.new :api_key => 'your api key'
|
116
|
+
clients = cs.clients
|
117
|
+
```
|
118
|
+
|
119
|
+
## Basic usage
|
120
|
+
This example of listing all your clients and their campaigns demonstrates basic usage of the library and the data returned from the API:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
require 'createsend'
|
124
|
+
|
125
|
+
auth = {
|
126
|
+
:access_token => 'your access token',
|
127
|
+
:refresh_token => 'your refresh token'
|
128
|
+
}
|
129
|
+
cs = CreateSend::CreateSend.new auth
|
130
|
+
|
131
|
+
clients = cs.clients
|
132
|
+
clients.each do |cl|
|
133
|
+
p "Client: #{cl.Name}"
|
134
|
+
client = CreateSend::Client.new auth, cl.ClientID
|
135
|
+
p "- Campaigns:"
|
136
|
+
client.drafts.each do |cm|
|
137
|
+
p " - #{cm.Subject}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
Running this example will result in something like:
|
143
|
+
|
144
|
+
```
|
145
|
+
Client: First Client
|
146
|
+
- Campaigns:
|
147
|
+
- Newsletter Number One
|
148
|
+
- Newsletter Number Two
|
149
|
+
Client: Second Client
|
150
|
+
- Campaigns:
|
151
|
+
- News for January 2013
|
152
|
+
```
|
153
|
+
|
154
|
+
## Handling errors
|
155
|
+
If the Campaign Monitor API returns an error, an exception will be raised. For example, if you attempt to create a campaign and enter empty values for subject and other required fields:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
require 'createsend'
|
159
|
+
|
160
|
+
auth = {
|
161
|
+
:access_token => 'your access token',
|
162
|
+
:refresh_token => 'your refresh token'
|
163
|
+
}
|
164
|
+
|
165
|
+
begin
|
166
|
+
id = CreateSend::Campaign.create auth, "4a397ccaaa55eb4e6aa1221e1e2d7122",
|
167
|
+
"", "", "", "", "", "", "", [], []
|
168
|
+
p "New campaign ID: #{id}"
|
169
|
+
rescue CreateSend::BadRequest => br
|
170
|
+
p "Bad request error: #{br}"
|
171
|
+
p "Error Code: #{br.data.Code}"
|
172
|
+
p "Error Message: #{br.data.Message}"
|
173
|
+
rescue Exception => e
|
174
|
+
p "Error: #{e}"
|
175
|
+
end
|
176
|
+
```
|
177
|
+
|
178
|
+
Running this example will result in:
|
179
|
+
|
180
|
+
```
|
181
|
+
Bad request error: The CreateSend API responded with the following error - 304: Campaign Subject Required
|
182
|
+
Error Code: 304
|
183
|
+
Error Message: Campaign Subject Required
|
184
|
+
```
|
185
|
+
|
186
|
+
## Expected input and output
|
187
|
+
|
188
|
+
The best way of finding out the expected input and output of a particular method in a particular class is to use the unit tests as a reference.
|
189
|
+
|
190
|
+
For example, if you wanted to find out how to call the `CreateSend::Subscriber.add` method, you would look at the file [test/subscriber_test.rb](https://github.com/campaignmonitor/createsend-ruby/blob/master/test/subscriber_test.rb)
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
should "add a subscriber with custom fields" do
|
194
|
+
stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
|
195
|
+
custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
|
196
|
+
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
|
197
|
+
email_address.should be == "subscriber@example.com"
|
198
|
+
end
|
199
|
+
```
|
200
|
+
|
201
|
+
## Documentation
|
202
|
+
|
203
|
+
Ruby documentation is available at [RubyDoc.info](http://rubydoc.info/gems/createsend/frames).
|
204
|
+
|
205
|
+
## Contributing
|
206
|
+
|
207
|
+
Please check the [guidelines for contributing](https://github.com/campaignmonitor/createsend-ruby/blob/master/CONTRIBUTING.md) to this repository.
|
208
|
+
|
209
|
+
## Releasing
|
210
|
+
|
211
|
+
Please check the [instructions for releasing](https://github.com/campaignmonitor/createsend-ruby/blob/master/RELEASE.md) the `createsend` gem.
|
212
|
+
|
213
|
+
## This stuff should be green
|
214
|
+
|
215
|
+
[](https://app.travis-ci.com/campaignmonitor/createsend-ruby) [][coveralls] [][gemnasium] [][gembadge]
|
216
|
+
|
217
|
+
[travis]: http://travis-ci.org/campaignmonitor/createsend-ruby
|
218
|
+
[coveralls]: https://coveralls.io/r/campaignmonitor/createsend-ruby
|
219
|
+
[gemnasium]: https://gemnasium.com/campaignmonitor/createsend-ruby
|
220
|
+
[gembadge]: http://badge.fury.io/rb/createsend
|
data/RELEASE.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Releasing createsend-ruby
|
2
|
+
|
3
|
+
## Requirements
|
4
|
+
|
5
|
+
- You must have a [RubyGems.org](https://rubygems.org/) account and must be an owner of the [createsend](https://rubygems.org/gems/createsend) gem.
|
6
|
+
|
7
|
+
Owners can be added to the `createsend` gem like this:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem owner createsend -a newowner@example.com
|
11
|
+
```
|
12
|
+
|
13
|
+
## Prepare the release
|
14
|
+
|
15
|
+
- Increment the `VERSION` constant in the `lib/createsend/version.rb` file, ensuring that you use [Semantic Versioning](http://semver.org/).
|
16
|
+
- Add an entry to `HISTORY.md` which clearly explains the new release.
|
17
|
+
- Commit your changes:
|
18
|
+
|
19
|
+
```
|
20
|
+
git commit -am "Version X.Y.Z"
|
21
|
+
```
|
22
|
+
|
23
|
+
- Tag the new version:
|
24
|
+
|
25
|
+
```
|
26
|
+
git tag -a vX.Y.Z -m "Version X.Y.Z"
|
27
|
+
```
|
28
|
+
|
29
|
+
- Push your changes to GitHub, including the tag you just created:
|
30
|
+
|
31
|
+
```
|
32
|
+
git push origin master --tags
|
33
|
+
```
|
34
|
+
|
35
|
+
- Ensure that all [tests](https://app.travis-ci.com/github/campaignmonitor/createsend-ruby) pass, and that [coverage](https://coveralls.io/r/campaignmonitor/createsend-ruby) is maintained or improved.
|
36
|
+
|
37
|
+
- Add a new [GitHub Release](https://github.com/campaignmonitor/createsend-ruby/releases) using the newly created tag.
|
38
|
+
|
39
|
+
## Build the gem
|
40
|
+
|
41
|
+
```
|
42
|
+
rake build
|
43
|
+
```
|
44
|
+
|
45
|
+
This builds the gem locally to a file named something like `createsend-X.Y.Z.gem`. You're now ready to release the gem.
|
46
|
+
|
47
|
+
## Release the gem
|
48
|
+
|
49
|
+
```
|
50
|
+
rake release
|
51
|
+
```
|
52
|
+
|
53
|
+
This publishes the gem to [RubyGems.org](https://rubygems.org/gems/createsend). You should see the newly published version of the gem there. All done!
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
require "bundler/version"
|
3
|
+
require "rake/testtask"
|
4
|
+
require "./lib/createsend"
|
5
|
+
|
6
|
+
desc "Run tests"
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.ruby_opts = ["-rrubygems"] if defined? Gem
|
9
|
+
test.libs << "lib" << "test"
|
10
|
+
test.pattern = "test/**/*_test.rb"
|
11
|
+
puts "running tests."
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Build the gem"
|
15
|
+
task :build do
|
16
|
+
system "gem build createsend.gemspec"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Build and release the gem"
|
20
|
+
task :release => :build do
|
21
|
+
system "gem push createsend-#{CreateSend::VERSION}.gem"
|
22
|
+
end
|
23
|
+
|
24
|
+
task :default => :test
|