express_pigeon 2.0.2 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.hound.yml +3 -0
  4. data/CHANGELOG.md +15 -0
  5. data/CONTRIBUTING.md +9 -0
  6. data/Gemfile +1 -0
  7. data/Guardfile +2 -36
  8. data/README.md +57 -0
  9. data/lib/express_pigeon/auto_responders.rb +70 -0
  10. data/lib/express_pigeon/campaigns.rb +120 -0
  11. data/lib/express_pigeon/contacts.rb +15 -4
  12. data/lib/express_pigeon/messages.rb +83 -0
  13. data/lib/express_pigeon/templates.rb +24 -0
  14. data/lib/express_pigeon/version.rb +1 -1
  15. data/lib/express_pigeon.rb +4 -11
  16. data/spec/lib/express_pigeon/auto_responders_spec.rb +2 -0
  17. data/spec/lib/express_pigeon/campaigns_spec.rb +2 -0
  18. data/spec/{express_pigeon → lib/express_pigeon}/contacts_spec.rb +0 -0
  19. data/spec/{express_pigeon → lib/express_pigeon}/lists_spec.rb +0 -0
  20. data/spec/lib/express_pigeon/messages_spec.rb +37 -0
  21. data/spec/lib/express_pigeon/templates_spec.rb +43 -0
  22. data/spec/spec_helper.rb +3 -18
  23. data.tar.gz.sig +2 -2
  24. metadata +19 -22
  25. metadata.gz.sig +0 -0
  26. data/lib/express_pigeon/api/campaigns.rb +0 -62
  27. data/lib/express_pigeon/api/contacts.rb +0 -42
  28. data/lib/express_pigeon/api/lists.rb +0 -49
  29. data/lib/express_pigeon/api/messages.rb +0 -56
  30. data/lib/express_pigeon/api.rb +0 -66
  31. data/lib/express_pigeon/autoresponders.rb +0 -0
  32. data/lib/express_pigeon/meta_hash.rb +0 -20
  33. data/lib/express_pigeon/transactional_emails.rb +0 -4
  34. data/spec/express_pigeon/api/campaigns_spec.rb +0 -100
  35. data/spec/express_pigeon/api/contacts_spec.rb +0 -146
  36. data/spec/express_pigeon/api/lists_spec.rb +0 -23
  37. data/spec/express_pigeon/api/messages_spec.rb +0 -36
data/spec/spec_helper.rb CHANGED
@@ -4,24 +4,9 @@ Dotenv.load
4
4
  require 'codeclimate-test-reporter'
5
5
  CodeClimate::TestReporter.start
6
6
 
7
+ require 'awesome_print'
7
8
  require 'express_pigeon'
8
9
 
9
- # PIGEON ||= ExpressPigeon::API
10
- TEMPLATE_ID ||= 1
11
- LIST_ID ||= 12
12
- API_USER ||= 'non@non.non'
13
- DISABLED_LIST ||= 12
14
-
15
- # module PigeonSpecHelper
16
- # def validate_response(res, code, status, message)
17
- # res.code.should eq code
18
- # res.status.should eq status
19
- # if message
20
- # (res.message =~ message).should_not be_nil
21
- # end
22
- # end
23
- # end
24
-
25
10
  # This file was generated by the `rspec --init` command. Conventionally, all
26
11
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
27
12
  # The generated `.rspec` file contains `--require spec_helper` which will cause this
@@ -76,11 +61,11 @@ RSpec.configure do |config|
76
61
  # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
77
62
  # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
78
63
  # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
79
- # config.disable_monkey_patching!
64
+ config.disable_monkey_patching!
80
65
 
81
66
  # This setting enables warnings. It's recommended, but in some cases may
82
67
  # be too noisy due to issues in dependencies.
83
- config.warnings = true
68
+ config.warnings = false
84
69
 
85
70
  # Many RSpec users commonly either run the entire suite or an individual
86
71
  # file, and it's useful to allow more verbose output when running an
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- z�E��]`W
2
- N��ž9�~�0���- v
1
+ N��h�c�c5��n�Y > ���(�M�܂}⺂��/ΰB�<����a�z.6�V����j�ɪ���_����1�H��YC�GI��U���8n�|� 쳔%f�I5�z©𓨸��r��;��=೩H��f��7��'�SF:΢伐�) �N-�l��Ǭ
2
+ OXF�_��Z<�E�!�qQ�m鉬����u���}>�:7@��{j��/n��lj��[��cA#��|��/]{?zJ̹�#� �)S7��Ӕ�"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_pigeon
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Hall
@@ -30,7 +30,7 @@ cert_chain:
30
30
  QsY+KOCED3hFaYalTIDZVUeuSy8F+blfl2rMqqNGz9nzzr/517C5pE21U3PNBbe6
31
31
  xt+ryn9JcEryrWbF
32
32
  -----END CERTIFICATE-----
33
- date: 2014-12-24 00:00:00.000000000 Z
33
+ date: 2014-12-26 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: httparty
@@ -147,11 +147,13 @@ extra_rdoc_files:
147
147
  files:
148
148
  - ".env.example"
149
149
  - ".gitignore"
150
+ - ".hound.yml"
150
151
  - ".rspec"
151
152
  - ".rubocop.yml"
152
153
  - ".rubocop_todo.yml"
153
154
  - ".ruby-gemset"
154
155
  - ".ruby-version"
156
+ - CHANGELOG.md
155
157
  - CONTRIBUTING.md
156
158
  - Gemfile
157
159
  - Guardfile
@@ -161,26 +163,21 @@ files:
161
163
  - certs/just3ws.pem
162
164
  - express_pigeon.gemspec
163
165
  - lib/express_pigeon.rb
164
- - lib/express_pigeon/api.rb
165
- - lib/express_pigeon/api/campaigns.rb
166
- - lib/express_pigeon/api/contacts.rb
167
- - lib/express_pigeon/api/lists.rb
168
- - lib/express_pigeon/api/messages.rb
169
- - lib/express_pigeon/autoresponders.rb
166
+ - lib/express_pigeon/auto_responders.rb
167
+ - lib/express_pigeon/campaigns.rb
170
168
  - lib/express_pigeon/contacts.rb
171
169
  - lib/express_pigeon/lists.rb
172
- - lib/express_pigeon/meta_hash.rb
170
+ - lib/express_pigeon/messages.rb
173
171
  - lib/express_pigeon/templates.rb
174
- - lib/express_pigeon/transactional_emails.rb
175
172
  - lib/express_pigeon/version.rb
176
- - spec/express_pigeon/api/campaigns_spec.rb
177
- - spec/express_pigeon/api/contacts_spec.rb
178
- - spec/express_pigeon/api/lists_spec.rb
179
- - spec/express_pigeon/api/messages_spec.rb
180
- - spec/express_pigeon/contacts_spec.rb
181
- - spec/express_pigeon/lists_spec.rb
182
173
  - spec/fixtures/contacts.csv
183
174
  - spec/fixtures/contacts.csv.zip
175
+ - spec/lib/express_pigeon/auto_responders_spec.rb
176
+ - spec/lib/express_pigeon/campaigns_spec.rb
177
+ - spec/lib/express_pigeon/contacts_spec.rb
178
+ - spec/lib/express_pigeon/lists_spec.rb
179
+ - spec/lib/express_pigeon/messages_spec.rb
180
+ - spec/lib/express_pigeon/templates_spec.rb
184
181
  - spec/spec_helper.rb
185
182
  - tmp/.keep
186
183
  homepage: https://github.com/just3ws/express_pigeon
@@ -208,12 +205,12 @@ signing_key:
208
205
  specification_version: 4
209
206
  summary: "(Another) ExpressPigeon API Ruby Wrapper"
210
207
  test_files:
211
- - spec/express_pigeon/api/campaigns_spec.rb
212
- - spec/express_pigeon/api/contacts_spec.rb
213
- - spec/express_pigeon/api/lists_spec.rb
214
- - spec/express_pigeon/api/messages_spec.rb
215
- - spec/express_pigeon/contacts_spec.rb
216
- - spec/express_pigeon/lists_spec.rb
217
208
  - spec/fixtures/contacts.csv
218
209
  - spec/fixtures/contacts.csv.zip
210
+ - spec/lib/express_pigeon/auto_responders_spec.rb
211
+ - spec/lib/express_pigeon/campaigns_spec.rb
212
+ - spec/lib/express_pigeon/contacts_spec.rb
213
+ - spec/lib/express_pigeon/lists_spec.rb
214
+ - spec/lib/express_pigeon/messages_spec.rb
215
+ - spec/lib/express_pigeon/templates_spec.rb
219
216
  - spec/spec_helper.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,62 +0,0 @@
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
@@ -1,42 +0,0 @@
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
@@ -1,49 +0,0 @@
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
@@ -1,56 +0,0 @@
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
@@ -1,66 +0,0 @@
1
- # require_relative 'api/campaign'
2
- # require_relative 'api/contact'
3
- # require_relative 'api/list'
4
- # require_relative 'api/message'
5
- #
6
- # module ExpressPigeon
7
- # module API
8
- # def http(path, method, params = {})
9
- # uri = URI.parse "#{ROOT}#{path}"
10
- # req = Net::HTTP.const_get("#{method}").new "#{ROOT}#{path}"
11
- # req['X-auth-key'] = AUTH_KEY
12
- # if params
13
- # req.body = params.to_json
14
- # req['Content-type'] = 'application/json'
15
- # end
16
- #
17
- # if block_given?
18
- # Net::HTTP.start(uri.host, uri.port, use_ssl: USE_SSL) do |http|
19
- # http.request req do |res|
20
- # res.read_body do |seg|
21
- # yield seg
22
- # end
23
- # end
24
- # end
25
- # else
26
- # resp = Net::HTTP.start(uri.host, uri.port, use_ssl: USE_SSL) do |http|
27
- # http.request req
28
- # end
29
- # parsed = JSON.parse(resp.body)
30
- # if parsed.is_a? Hash
31
- # MetaHash.new parsed
32
- # else
33
- # parsed
34
- # end
35
- # end
36
- # end
37
- #
38
- # def get(path, &block)
39
- # http path, 'Get', nil, &block
40
- # end
41
- #
42
- # def post(path, params = {})
43
- # http path, 'Post', params
44
- # end
45
- #
46
- # def del(path, params = {})
47
- # http path, 'Delete', params
48
- # end
49
- #
50
- # def self.campaigns
51
- # Campaigns.new
52
- # end
53
- #
54
- # def self.lists
55
- # Lists.new
56
- # end
57
- #
58
- # def self.contacts
59
- # Contacts.new
60
- # end
61
- #
62
- # def self.messages
63
- # Messages.new
64
- # end
65
- # end
66
- # end
File without changes
@@ -1,20 +0,0 @@
1
- # class MetaHash < Hash
2
- # def initialize(delegate)
3
- # super
4
- # @delegate = delegate
5
- # @delegate.each_key do |k|
6
- # v = @delegate[k] # lets go only one level down for now
7
- # if v.is_a? Hash
8
- # @delegate[k] = MetaHash.new(v)
9
- # end
10
- # end
11
- # end
12
- #
13
- # def method_missing(m, *_args, &_block)
14
- # @delegate[m.to_s]
15
- # end
16
- #
17
- # def to_s
18
- # @delegate.to_s
19
- # end
20
- # end
@@ -1,4 +0,0 @@
1
- module ExpressPigeon
2
- class TransactionalEmails
3
- end
4
- end
@@ -1,100 +0,0 @@
1
- # RSpec.describe 'campaigns integration test', skip: true do
2
- # include PigeonSpecHelper
3
- #
4
- # it 'should return more than 0 campaign ids' do
5
- # res = PIGEON.campaigns.all
6
- # res.class.should == Array
7
- # res.size.should > 0
8
- # end
9
- #
10
- # it 'cannot send with missing parameters' do
11
- # res = PIGEON.campaigns.send(template_id: 15_233, name: 'API Test campaign',
12
- # from_name: 'Igor Polevoy', reply_to: 'igor@polevoy.org',
13
- # subject: 'API test', google_analytics: true)
14
- # validate_response res, 400, 'error', /required parameters: list_id, template_id, name, from_name, reply_to, subject, google_analytics/
15
- # end
16
- #
17
- # it 'cannot send with bad reply_to' do
18
- # res = PIGEON.campaigns.send(list_id: -1, template_id: -1, name: 'My Campaign', from_name: 'John', reply_to: 'j',
19
- # subject: 'Hi', google_analytics: false)
20
- # validate_response res, 400, 'error', /reply_to should be valid email address/
21
- # end
22
- #
23
- # it 'cannot send with non-existing template' do
24
- # res = PIGEON.campaigns.send(list_id: -1, template_id: -1, name: 'My Campaign', from_name: 'John',
25
- # reply_to: 'j@j.j',
26
- # subject: 'Hi', google_analytics: false)
27
- # validate_response res, 400, 'error', /template=-1 is not found/
28
- # end
29
- #
30
- # it 'cannot send to non-existing list' do
31
- # res = PIGEON.campaigns.send(list_id: -1, template_id: TEMPLATE_ID, name: 'My Campaign', from_name: 'John',
32
- # reply_to: 'j@j.j',
33
- # subject: 'Hi', google_analytics: false)
34
- # validate_response res, 400, 'error', /list=-1 is not found/
35
- # end
36
- #
37
- # it 'cannot send to disabled list' do
38
- # res = PIGEON.campaigns.send(list_id: LIST_ID, template_id: TEMPLATE_ID, name: 'My Campaign', from_name: 'John',
39
- # reply_to: 'j@j.j',
40
- # subject: 'Hi', google_analytics: false)
41
- # validate_response res, 400, 'error', /list=#{DISABLED_LIST} is disabled/
42
- # end
43
- #
44
- # it 'should create new list, add contact and send successful campaign' do
45
- # list_resp = PIGEON.lists.create('My list', 'John', API_USER)
46
- # list_id = list_resp.list.id
47
- # PIGEON.contacts.upsert(list_id, email: API_USER)
48
- # resp = PIGEON.campaigns.send(list_id: list_id, template_id: TEMPLATE_ID, name: 'My Campaign', from_name: 'John',
49
- # reply_to: API_USER,
50
- # subject: 'Hi', google_analytics: false)
51
- # validate_response resp, 200, 'success', /new campaign created successfully/
52
- # report = PIGEON.campaigns.report(resp.campaign_id)
53
- # (report.delivered == 0 || report.delivered == 1).should be_true
54
- # report.clicked.should eq 0
55
- # report.opened.should eq 0
56
- # report.spam.should eq 0
57
- # (report.in_transit == 0 || report.in_transit == 1).should be_true
58
- # report.unsubscribed.should eq 0
59
- # report.bounced.should eq 0
60
- # bounced = PIGEON.campaigns.bounced(resp.campaign_id)
61
- # unsubscribed = PIGEON.campaigns.unsubscribed(resp.campaign_id)
62
- # spam = PIGEON.campaigns.spam(resp.campaign_id)
63
- #
64
- # bounced.size.should eq 0
65
- # unsubscribed.size.should eq 0
66
- # spam.size.should eq 0
67
- #
68
- # resp = PIGEON.contacts.delete(API_USER)
69
- # validate_response resp, 200, 'success', /contact=non@non.non deleted successfully/
70
- #
71
- # resp = PIGEON.contacts.find_by_email(API_USER)
72
- # validate_response resp, 404, 'error', /contact=non@non.non not found/
73
- #
74
- # resp = PIGEON.lists.delete(list_id)
75
- # validate_response resp, 200, 'success', /deleted successfully/
76
- # end
77
- #
78
- # it 'cannot send campaign if scheduling with bad date' do
79
- # list_resp = PIGEON.lists.create 'My list', 'John', API_USER
80
- # resp = PIGEON.campaigns.schedule list_id: list_resp.list.id, template_id: TEMPLATE_ID, name: 'My Campaign',
81
- #
82
- # from_name: 'John',
83
- # reply_to: API_USER, subject: 'Hi',
84
- # google_analytics: false, schedule_for: '2013-05-28'
85
- #
86
- # validate_response resp, 400, 'error', /schedule_for is not in ISO date format, example: 2013-05-28T17:19:50.779/
87
- # resp = PIGEON.lists.delete(list_resp.list.id)
88
- # validate_response resp, 200, 'success', /deleted successfully/
89
- # end
90
- #
91
- # it 'should not schedule campaign with date in the past' do
92
- # list_resp = PIGEON.lists.create('My list', 'John', API_USER)
93
- # resp = PIGEON.campaigns.schedule list_id: list_resp.list.id, template_id: TEMPLATE_ID, name: 'My Campaign',
94
- # from_name: 'John',
95
- # reply_to: API_USER, subject: 'Hi',
96
- # google_analytics: false, schedule_for: '2010-05-28T17:19:50.779+0300'
97
- #
98
- # validate_response resp, 400, 'error', /schedule_for should be in the future/
99
- # end
100
- # end