express_pigeon 1.0.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +1 -0
  3. data/.gitignore +19 -16
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +17 -0
  6. data/.rubocop_todo.yml +15 -0
  7. data/.ruby-gemset +1 -0
  8. data/.ruby-version +1 -0
  9. data/CONTRIBUTING.md +21 -0
  10. data/Gemfile +13 -8
  11. data/Guardfile +56 -0
  12. data/LICENSE +9 -2
  13. data/README.md +4 -124
  14. data/Rakefile +1 -2
  15. data/express_pigeon.gemspec +31 -16
  16. data/lib/express_pigeon/api/campaigns.rb +62 -0
  17. data/lib/express_pigeon/api/contacts.rb +42 -0
  18. data/lib/express_pigeon/api/lists.rb +49 -0
  19. data/lib/express_pigeon/api/messages.rb +56 -0
  20. data/lib/express_pigeon/api.rb +66 -0
  21. data/lib/express_pigeon/autoresponders.rb +0 -0
  22. data/lib/express_pigeon/contacts.rb +71 -0
  23. data/lib/express_pigeon/lists.rb +111 -0
  24. data/lib/express_pigeon/meta_hash.rb +20 -0
  25. data/lib/express_pigeon/templates.rb +4 -0
  26. data/lib/express_pigeon/transactional_emails.rb +4 -0
  27. data/lib/express_pigeon/version.rb +1 -1
  28. data/lib/express_pigeon.rb +16 -442
  29. data/spec/express_pigeon/api/campaigns_spec.rb +100 -0
  30. data/spec/express_pigeon/api/contacts_spec.rb +146 -0
  31. data/spec/express_pigeon/api/lists_spec.rb +23 -0
  32. data/spec/express_pigeon/api/messages_spec.rb +36 -0
  33. data/spec/express_pigeon/contacts_spec.rb +111 -0
  34. data/spec/express_pigeon/lists_spec.rb +131 -0
  35. data/spec/fixtures/contacts.csv +2 -0
  36. data/spec/fixtures/contacts.csv.zip +0 -0
  37. data/spec/spec_helper.rb +100 -12
  38. data/vendor/cache/ast-2.0.0.gem +0 -0
  39. data/vendor/cache/astrolabe-1.3.0.gem +0 -0
  40. data/vendor/cache/awesome_print-1.2.0.gem +0 -0
  41. data/vendor/cache/byebug-3.5.1.gem +0 -0
  42. data/vendor/cache/celluloid-0.16.0.gem +0 -0
  43. data/vendor/cache/coderay-1.1.0.gem +0 -0
  44. data/vendor/cache/colorize-0.7.5.gem +0 -0
  45. data/vendor/cache/columnize-0.9.0.gem +0 -0
  46. data/vendor/cache/debugger-linecache-1.2.0.gem +0 -0
  47. data/vendor/cache/diff-lcs-1.2.5.gem +0 -0
  48. data/vendor/cache/docile-1.1.5.gem +0 -0
  49. data/vendor/cache/dotenv-1.0.2.gem +0 -0
  50. data/vendor/cache/ffi-1.9.6.gem +0 -0
  51. data/vendor/cache/formatador-0.2.5.gem +0 -0
  52. data/vendor/cache/guard-2.10.5.gem +0 -0
  53. data/vendor/cache/guard-compat-1.2.0.gem +0 -0
  54. data/vendor/cache/guard-rspec-4.5.0.gem +0 -0
  55. data/vendor/cache/hitimes-1.2.2.gem +0 -0
  56. data/vendor/cache/httmultiparty-0.3.16.gem +0 -0
  57. data/vendor/cache/httparty-0.13.3.gem +0 -0
  58. data/vendor/cache/json-1.8.1.gem +0 -0
  59. data/vendor/cache/listen-2.8.4.gem +0 -0
  60. data/vendor/cache/lumberjack-1.0.9.gem +0 -0
  61. data/vendor/cache/method_source-0.8.2.gem +0 -0
  62. data/vendor/cache/mimemagic-0.2.1.gem +0 -0
  63. data/vendor/cache/multi_json-1.10.1.gem +0 -0
  64. data/vendor/cache/multi_xml-0.5.5.gem +0 -0
  65. data/vendor/cache/multipart-post-2.0.0.gem +0 -0
  66. data/vendor/cache/nenv-0.1.1.gem +0 -0
  67. data/vendor/cache/parser-2.2.0.pre.8.gem +0 -0
  68. data/vendor/cache/powerpack-0.0.9.gem +0 -0
  69. data/vendor/cache/pry-0.10.1.gem +0 -0
  70. data/vendor/cache/pry-byebug-2.0.0.gem +0 -0
  71. data/vendor/cache/rainbow-2.0.0.gem +0 -0
  72. data/vendor/cache/rake-10.4.2.gem +0 -0
  73. data/vendor/cache/rb-fsevent-0.9.4.gem +0 -0
  74. data/vendor/cache/rb-inotify-0.9.5.gem +0 -0
  75. data/vendor/cache/rspec-3.1.0.gem +0 -0
  76. data/vendor/cache/rspec-core-3.1.7.gem +0 -0
  77. data/vendor/cache/rspec-expectations-3.1.2.gem +0 -0
  78. data/vendor/cache/rspec-mocks-3.1.3.gem +0 -0
  79. data/vendor/cache/rspec-support-3.1.2.gem +0 -0
  80. data/vendor/cache/rubocop-0.28.0.gem +0 -0
  81. data/vendor/cache/ruby-progressbar-1.7.1.gem +0 -0
  82. data/vendor/cache/simplecov-0.9.1.gem +0 -0
  83. data/vendor/cache/simplecov-html-0.8.0.gem +0 -0
  84. data/vendor/cache/slop-3.6.0.gem +0 -0
  85. data/vendor/cache/thor-0.19.1.gem +0 -0
  86. data/vendor/cache/timers-4.0.1.gem +0 -0
  87. metadata +183 -53
  88. data/.rvmrc +0 -52
  89. data/.travis.yml +0 -8
  90. data/CHANGELOG +0 -6
  91. data/bin/console +0 -12
  92. data/express_pigeon-rb.yml +0 -10
  93. data/lib/active_model/validations/date_format_validator.rb +0 -20
  94. data/script/lint +0 -6
  95. data/script/multispec +0 -23
  96. data/spec/web_forms_spec.rb +0 -164
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b3d1a3383fa183060358e85a5d33e8d207ee13f
4
+ data.tar.gz: 7b3f551bb3a794ab35b0751b68268a1c58f6e046
5
+ SHA512:
6
+ metadata.gz: 4420cdbf8650d0ee8cf8d6f1b4c8c7a44fa50874906f724ef2dad4c0ccd551cf39c3c86cb739cec046df0256cb8fdfac4be985f6765d121e66fe278cb2b723ea
7
+ data.tar.gz: ad5968fce96f86ed1f53ff4e12e66e063488e2e302782f9472acebe49d5b6c47950ed8f84e1ea36ef4b4af63990d4a1449b8381292fa811d8f63b56ed8d73a07
data/.env.example ADDED
@@ -0,0 +1 @@
1
+ EXPRESS_PIGEON_AUTH_KEY=yourauthkey
data/.gitignore CHANGED
@@ -1,18 +1,21 @@
1
- *.gem
1
+ **.orig
2
+ *.a
3
+ *.bundle
4
+ *.iml
5
+ *.o
2
6
  *.rbc
3
- .bundle
4
- .config
5
- .yardoc
7
+ *.so
8
+ .env
9
+ /.idea/
10
+ /.bundle/
11
+ /.yardoc
12
+ /Gemfile.lock
13
+ /_yardoc/
14
+ /coverage/
15
+ /doc/
16
+ /log/*
17
+ /pkg/
18
+ /spec/reports/
19
+ /tmp/
6
20
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .rbx/
21
+ mkmf.log
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
+ --require spec_helper
1
2
  --color
2
3
  --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - '*.gemspec'
6
+ - 'Guardfile'
7
+ - 'bin/**/*'
8
+ - 'vendor/**/*'
9
+
10
+ Style/LineLength:
11
+ Enabled: false
12
+
13
+ Style/MethodLength:
14
+ Enabled: false
15
+
16
+ Style/Documentation:
17
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,15 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-12-18 16:18:36 -0600 using RuboCop version 0.23.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 32
9
+ Style/LineLength:
10
+ Max: 129
11
+
12
+ # Offense count: 4
13
+ # Configuration parameters: CountComments.
14
+ Style/MethodLength:
15
+ Max: 18
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ express_pigeon
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,21 @@
1
+ # Hi!
2
+
3
+ **DO _NOT_ RUN THE SPECS AGAINST YOUR PRODUCTION ACCOUNT. THEY ARE INTEGRATION TESTS AND WILL CREATE LISTS, CONTACTS, ETC INSIDE YOUR ACCOUNT.**
4
+
5
+ - Create a "dummy" account on [https://expresspigeon.com](https://expresspigeon.com).
6
+ - Create three custom_fields on the account.
7
+ - `my_custom_text_field` as `text` (no default)
8
+ - `my_custom_number_field` as `number` (no default)
9
+ - `my_custom_date_field` as `date` (no default)
10
+
11
+ [![Steps to set up the custom fields](https://www.evernote.com/shard/s13/sh/f0eaefe9-5699-470e-8184-af03fa5cdd20/a000ef8eb5152edfe8f228f53aa71523/deep/0/ExpressPigeon---Custom-Fields-Settings.png)](https://expresspigeon.com/settings/custom_fields/)
12
+
13
+ - Copy the `.env.example` to `.env`
14
+ - Set the `EXPRESS_PIGEON_AUTH_KEY` to the *sandbox* auth key found in the integrations section of the ExpressPigeon account.
15
+
16
+ [![Steps to find the Sandbox Authorization Key](https://www.evernote.com/shard/s13/sh/def4ff82-eefe-4303-82cc-964578a9595d/cba8f07aeb5cd2ab30e1114b477497fa/deep/0/ExpressPigeon---Integrations.png)](https://expresspigeon.com/settings/integrations/)
17
+
18
+ - `bundle install ; bundle exec rspec` and you should be good.
19
+
20
+
21
+
data/Gemfile CHANGED
@@ -3,16 +3,21 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in expresspigeon.gemspec
4
4
  gemspec
5
5
 
6
- group :development, :test do
7
- gem 'awesome_print'
8
- gem 'pry'
9
- gem 'pry-nav'
6
+ group :development do
7
+ gem 'byebug'
8
+ gem 'pry-byebug'
9
+
10
+ gem 'rubocop'
10
11
 
11
- gem 'wirble'
12
+ gem 'colorize'
13
+ end
14
+
15
+ group :development, :test do
16
+ gem 'dotenv'
17
+ gem 'guard'
18
+ gem 'guard-rspec'
12
19
  end
13
20
 
14
21
  group :test do
15
- gem 'rspec'
16
- gem 'rspec-given'
17
- gem 'activemodel-rspec', :git => "git://github.com/matthooks/activemodel-rspec.git"
22
+ gem 'simplecov', require: :false
18
23
  end
data/Guardfile ADDED
@@ -0,0 +1,56 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ directories %w(. lib spec)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ clearing :on
9
+
10
+ ## Make Guard exit when config is changed so it can be restarted
11
+ #
12
+ ## Note: if you want Guard to automatically start up again, run guard in a
13
+ ## shell loop, e.g.:
14
+ #
15
+ # $ while bundle exec guard; do echo "Restarting Guard..."; done
16
+ #
17
+ ## Note: if you are using the `directories` clause above and you are not
18
+ ## watching the project directory ('.'), the you will want to move the Guardfile
19
+ ## to a watched dir and symlink it back, e.g.
20
+ #
21
+ # $ mkdir config
22
+ # $ mv Guardfile config/
23
+ # $ ln -s config/Guardfile .
24
+ #
25
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
26
+ #
27
+ watch ('Guardfile') do
28
+ UI.info 'Exiting because Guard must be restarted for changes to take effect'
29
+ exit 0
30
+ end
31
+
32
+ # Note: The cmd option is now required due to the increasing number of ways
33
+ # rspec may be run, below are examples of the most common uses.
34
+ # * bundler: 'bundle exec rspec'
35
+ # * bundler binstubs: 'bin/rspec'
36
+ # * spring: 'bin/rspec' (This will use spring if running and you have
37
+ # installed the spring binstubs per the docs)
38
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
39
+ # * 'just' rspec: 'rspec'
40
+
41
+ guard :rspec, cmd: 'bundle exec rspec' do
42
+ require 'guard/rspec/dsl'
43
+ dsl = Guard::RSpec::Dsl.new(self)
44
+
45
+ # Feel free to open issues for suggestions and improvements
46
+
47
+ # RSpec files
48
+ rspec = dsl.rspec
49
+ watch(rspec.spec_helper) { rspec.spec_dir }
50
+ watch(rspec.spec_support) { rspec.spec_dir }
51
+ watch(rspec.spec_files)
52
+
53
+ # Ruby files
54
+ ruby = dsl.ruby
55
+ dsl.watch_spec_files_for(ruby.lib_files)
56
+ end
data/LICENSE CHANGED
@@ -1,4 +1,11 @@
1
- Copyright (c) 2012 Michael D. Hall
1
+ The code for express_pigeon is Copyright (c) 2014 Mike Hall and is released
2
+ under the MIT license below. This code contains a modified version of
3
+ expresspigeon-ruby. The 0.0.1 version of expresspigeon-ruby which was modified
4
+ was obtained from: https://github.com/expresspigeon/expresspigeon-ruby. That
5
+ code is covered by the following copyright and was also released under the MIT
6
+ license below:
7
+
8
+ Copyright (c) 2014 ExpressPigeon
2
9
 
3
10
  MIT License
4
11
 
@@ -19,4 +26,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
26
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
27
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
28
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,124 +1,4 @@
1
- # ExpressPigeon
2
-
3
- # ExpressPigeon [![TravisCI](https://secure.travis-ci.org/just3ws/express_pigeon-rb.png?branch=master)](http://travis-ci.org/just3ws/express_pigeon-rb) [![Gemnasium](https://gemnasium.com/just3ws/express_pigeon-rb.png)](https://gemnasium.com/just3ws/express_pigeon-rb)
4
-
5
- Library to interact with ExpressPigeon email service.
6
-
7
- ## Pre-requisites
8
-
9
- 1. Go to [Express Pigeon](http://expresspigeon.com)
10
- 2. Sign up for a free account
11
- 3. Create a Contact List
12
- 4. Create a Web Form for the contact list
13
- 5. Enable all the fields
14
- 6. Take note of the guid generated for the web form.
15
-
16
- ## Installation
17
-
18
- Add this line to your application's Gemfile:
19
-
20
- gem 'express_pigeon'
21
-
22
- And then execute:
23
-
24
- $ bundle
25
-
26
- Or install it yourself as:
27
-
28
- $ gem install express_pigeon
29
-
30
- ## Usage
31
-
32
- TODO: Write usage instructions here
33
-
34
- ## Contributing
35
-
36
- 1. Fork it
37
- 2. Create your feature branch (`git checkout -b my-new-feature`)
38
- 3. Commit your changes (`git commit -am 'Added some feature'`)
39
- 4. Push to the branch (`git push origin my-new-feature`)
40
- 5. Create new Pull Request
41
-
42
-
43
- # Email Fields
44
-
45
- +---------------+--------------+
46
- | Field | Type |
47
- +---------------+--------------+
48
- | address1 | varchar(255) |
49
- | address2 | varchar(255) |
50
- | city | varchar(128) |
51
- | company | varchar(128) |
52
- | country | varchar(128) |
53
- | date_of_birth | varchar(255) |
54
- | email | varchar(50) | # likely upgraded to 100
55
- | email_format | varchar(20) |
56
- | first_name | varchar(50) |
57
- | last_name | varchar(50) |
58
- | phone | varchar(30) |
59
- | state | varchar(48) |
60
- | title | varchar(30) |
61
- | zip | varchar(24) |
62
- +---------------+--------------+
63
-
64
-
65
- ## Form Data
66
-
67
- view-source:https://expresspigeon.com/subscription/form/51697971-48b4-45d3-ab80-3b23152999ed
68
-
69
- - submits to
70
-
71
- <form action="/subscription/add_contact" method="post" id="subscribe_form" class="form-add clearer"
72
-
73
- - company name?
74
-
75
- <title just3ws, llc - subscription</title
76
-
77
- - Web form name
78
-
79
- <h2 express_pigeon.rb</h2
80
-
81
- - Web form title
82
-
83
- <h2 Sign-up for our newsletters.</h2
84
-
85
- - Subtitle
86
-
87
- <h4 This is optional text for the form. You may use it to further entice your audience to subscribe</h4
88
-
89
- - Form Fields
90
-
91
- input type="hidden" name="guid" value="51697971-48b4-45d3-ab80-3b23152999ed"
92
-
93
- input id="address1" name="address1"
94
- input id="address2" name="address2"
95
- input id="city" name="city"
96
- input id="company" name="company"
97
- input id="country" name="country"
98
- input id="date_of_birth" name="date_of_birth"
99
- input id="email" name="email"
100
- input id="first_name" name="first_name"
101
- input id="last_name" name="last_name"
102
- input id="phone" name="phone"
103
- input id="state" name="state"
104
- input id="title" name="title"
105
- input id="zip" name="zip"
106
-
107
- label for="address1" Group Address 1
108
- label for="address2" Group Address 2
109
- label for="city" Group City
110
- label for="company" Group Name
111
- label for="country" Group Website
112
- label for="date_of_birth" Group Twitter Name
113
- label for="email" Your Email
114
- label for="first_name" Your First Name
115
- label for="last_name" Your Last Name
116
- label for="phone" Group Management Site
117
- label for="state" Group State
118
- label for="title" Your Role In Group
119
- label for="zip" Group Zip
120
-
121
-
122
- - Submit simple form via cURL
123
-
124
- curl -v -d "guid=51697971-48b4-45d3-ab80-3b23152999ed&email=mdh@just3ws.com"
1
+ This is a complete rewrite of the `expresspigeon-ruby` gem using an entirely
2
+ different approach and effectively none of the original code. I've forked and
3
+ created a derivative work from the original work by Igor Polevoy hence the new
4
+ copyright on the license.
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -1,21 +1,36 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/express_pigeon/version', __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'express_pigeon/version'
3
5
 
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Michael D. Hall"]
6
- gem.email = ["mdh@just3ws.com"]
7
- gem.description = %q{Light-weight wrapper around ExpressPigeon.}
8
- gem.summary = %q{API for interacting with ExpressPigeon service.}
9
- gem.homepage = "http://github.com/just3ws/express_pigeon-rb"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'express_pigeon'
8
+ spec.version = ExpressPigeon::VERSION
9
+ # Inspired by Igor Polevoy but a total re-write of the expresspigeon-ruby RubyGem
10
+ spec.authors = %w(Mike Hall)
11
+ spec.email = %w(mike@just3ws.com)
12
+ spec.description = <<-EOS
13
+ (Another) ExpressPigeon Ruby API for sending transactional messages,
14
+ manipulating lists, contacts and more.
15
+ EOS
16
+ spec.summary = 'ExpressPigeon API Ruby Wrapper'
17
+ spec.homepage = 'https://github.com/just3ws/express_pigeon'
18
+ spec.license = 'MIT'
19
+ spec.extra_rdoc_files = %w(LICENSE README.md)
10
20
 
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "express_pigeon"
15
- gem.require_paths = ["lib"]
16
- gem.version = ExpressPigeon::VERSION
21
+ spec.files = `git ls-files -z`.split("\x0")
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = %w(lib)
17
25
 
18
- gem.add_runtime_dependency("activemodel")
19
- gem.add_runtime_dependency("curb-fu")
20
- gem.add_runtime_dependency("chronic")
26
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.1.0')
27
+
28
+ spec.add_dependency('httparty', '~> 0.13.3')
29
+ spec.add_runtime_dependency('httmultiparty', '~> 0.3', '>= 0.3.16')
30
+
31
+ spec.add_development_dependency('bundler', '~> 1.7')
32
+ spec.add_development_dependency('rake', '~> 10.0')
33
+ spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
34
+
35
+ spec.add_development_dependency('awesome_print', '~> 1.2', '>= 1.2.0')
21
36
  end
@@ -0,0 +1,62 @@
1
+ # module ExpressPigeon
2
+ # module API
3
+ # class Campaigns
4
+ # include ExpressPigeon::API
5
+ #
6
+ # def initialize
7
+ # @endpoint = 'campaigns'
8
+ # end
9
+ #
10
+ # def all
11
+ # get @endpoint
12
+ # end
13
+ #
14
+ # def report(campaign_id)
15
+ # get "#{@endpoint}/#{campaign_id}"
16
+ # end
17
+ #
18
+ # def bounced(campaign_id)
19
+ # get "#{@endpoint}/#{campaign_id}/bounced"
20
+ # end
21
+ #
22
+ # def unsubscribed(campaign_id)
23
+ # get "#{@endpoint}/#{campaign_id}/unsubscribed"
24
+ # end
25
+ #
26
+ # def spam(campaign_id)
27
+ # get "#{@endpoint}/#{campaign_id}/spam"
28
+ # end
29
+ #
30
+ # #
31
+ # # Schedules a new campaign to be sent.
32
+ # # Parameters:
33
+ # # * *list_id* - id of list to send to
34
+ # # * *template_id* - id of template to send
35
+ # # * *name* - name of a newly created campaign
36
+ # # * *from_name* - from name
37
+ # # * *reply_to* - reply to
38
+ # # * *subject* - subject of campaign
39
+ # # * *google_analytics* - true to turn Google Analytics on
40
+ # def send(params = {})
41
+ # post @endpoint, params
42
+ # end
43
+ #
44
+ # #
45
+ # # Schedules a new campaign to be sent.
46
+ # # Parameters:
47
+ # # * *list_id* - id of list to send to
48
+ # # * *template_id* - id of template to send
49
+ # # * *name* - name of a newly created campaign
50
+ # # * *from_name* - from name
51
+ # # * *reply_to* - reply to
52
+ # # * *subject* - subject of campaign
53
+ # # * *google_analytics* - true to turn Google Analytics on
54
+ # # * *schedule_for* - Specifies what time a campaign should be sent. If it is provided the campaign will
55
+ # # be scheduled to this time, otherwise campaign is sent immediately. The schedule_for
56
+ # # must be in ISO date format and should be in the future.
57
+ # def schedule(params = {})
58
+ # post @endpoint, params
59
+ # end
60
+ # end
61
+ # end
62
+ # end
@@ -0,0 +1,42 @@
1
+ # module ExpressPigeon
2
+ # module API
3
+ # class Contacts
4
+ # include ExpressPigeon::API
5
+ #
6
+ # def initialize
7
+ # @endpoint = 'contacts'
8
+ # end
9
+ #
10
+ # def find_by_email(email)
11
+ # get "#{@endpoint}?email=#{email}"
12
+ # end
13
+ #
14
+ # # JSON document represents a contact to be created or updated.
15
+ # # The email field is required.
16
+ # # When updating a contact, list_id is optional,
17
+ # # since the contact is uniquely identified by email across all lists.
18
+ # #
19
+ # # :param list_id: Contact list ID (Fixnum) the contact will be added to
20
+ # #
21
+ # # :param contact: Hash describes new contact. The "email" field is required.
22
+ # #
23
+ # # :returns: representation of a contact
24
+ # #
25
+ # def upsert(list_id, contact)
26
+ # post @endpoint, params = { list_id: list_id, contact: contact }
27
+ # end
28
+ #
29
+ # # Delete single contact. If list_id is not provided, contact will be deleted from system.
30
+ # # :param email: contact email to be deleted.
31
+ # # :param list_id: list id to remove contact from, if not provided, contact will be deleted from system.
32
+ # def delete(email, list_id = nil)
33
+ # if list_id
34
+ # query = "email=#{email}&list_id=#{list_id}"
35
+ # else
36
+ # query = "email=#{email}"
37
+ # end
38
+ # del "#{@endpoint}?#{query}", nil
39
+ # end
40
+ # end
41
+ # end
42
+ # end
@@ -0,0 +1,49 @@
1
+ # module ExpressPigeon
2
+ # module API
3
+ # class Lists
4
+ # include ExpressPigeon::API
5
+ #
6
+ # def initialize
7
+ # @endpoint = 'lists'
8
+ # end
9
+ #
10
+ # def create(list_name, from_name, reply_to)
11
+ # post @endpoint, name: list_name, from_name: from_name, reply_to: reply_to
12
+ # end
13
+ #
14
+ # # Query all lists.
15
+ # # returns: array of hashes each representing a list for this user
16
+ # def all
17
+ # get @endpoint
18
+ # end
19
+ #
20
+ # # Updates existing list
21
+ # #
22
+ # #:param list_id: Id of list to be updated
23
+ # #:type list_id: int
24
+ # #
25
+ # #:param params: JSON object represents a list to be updated
26
+ #
27
+ # #
28
+ # #:returns: EpResponse with status, code, message, and updated list
29
+ # #:rtype: EpResponse
30
+ # # TODO: resolve API on Python side, then implement this
31
+ # # def update(list_id, params = {})
32
+ # # params['id'] = list_id
33
+ # # return self.ep.put(self.endpoint, params=params)
34
+ # # end
35
+ #
36
+ # # Removes a list with a given id. A list must be enabled and has no dependent subscriptions and/or scheduled campaigns.
37
+ # #
38
+ # # param list_id: Id of list to be removed.
39
+ # # returns response hash with status, code, and message
40
+ # def delete(list_id)
41
+ # del "#{@endpoint}/#{list_id}"
42
+ # end
43
+ #
44
+ # def csv(list_id, &block)
45
+ # get "#{@endpoint}/#{list_id}/csv", &block
46
+ # end
47
+ # end
48
+ # end
49
+ # end
@@ -0,0 +1,56 @@
1
+ # module ExpressPigeon
2
+ # module API
3
+ # class Messages
4
+ # include ExpressPigeon::API
5
+ #
6
+ # def initialize
7
+ # @endpoint = 'messages'
8
+ # end
9
+ #
10
+ # def send_message(template_id, to, reply_to, from_name, subject, merge_fields = nil, view_online = false, click_tracking = true)
11
+ # post @endpoint, params = { template_id: template_id,
12
+ # to: to,
13
+ # reply_to: reply_to,
14
+ # from: from_name,
15
+ # subject: subject,
16
+ # merge_fields: merge_fields,
17
+ # view_online: view_online,
18
+ # click_tracking: click_tracking
19
+ # }
20
+ # end
21
+ #
22
+ # def report(message_id)
23
+ # get "#{@endpoint}/#{message_id}"
24
+ # end
25
+ #
26
+ # def reports(from_id, start_date = nil, end_date = nil)
27
+ # params = []
28
+ #
29
+ # if from_id
30
+ # params << "from_id=#{from_id}"
31
+ # end
32
+ #
33
+ # if start_date && !end_date
34
+ # fail 'must include both start_date and end_date'
35
+ # end
36
+ # if end_date && !start_date
37
+ # fail 'must include both start_date and end_date'
38
+ # end
39
+ #
40
+ # if start_date && end_date
41
+ # params << "start_date=#{start_date.strftime('%FT%T.%L%z')}"
42
+ # params << "end_date=#{end_date.strftime('%FT%T.%L%z')}"
43
+ # end
44
+ #
45
+ # query = "#{@endpoint}?"
46
+ #
47
+ # if params.size > 0
48
+ # query << params.join('&')
49
+ # end
50
+ #
51
+ # puts "calling: #{query}"
52
+ # get query
53
+ # end
54
+ # end
55
+ # end
56
+ # end