dynect_email 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86ecdacf5d3513f787d81d7f2e043fb0f095e609
4
+ data.tar.gz: 8bf487d41f69a5a76e03fc8b10b2653f3ffef99e
5
+ SHA512:
6
+ metadata.gz: 022f1b3861561c212fb66335182e56283c0d9819c35aa0fc5e48333210a43ed8f41a7f452dce2a45ed3b98874621d460317733ea74f3ef47baf7b3b415249167
7
+ data.tar.gz: 5e0c023cc8ddda019d71c1fb6dac77f6ddff3ba6fab38a9d62987b0964443bc48647a597f00333ed939a4580d1866c61a1ae63823e5a1521194623cb77f5d2cd
Binary file
@@ -0,0 +1,4 @@
1
+ �L���C�_��83���<m3 �����e���@��v�淧
2
+ )s9� ��� ��kQZ�ő�i���B��y��B��X�w|�Y7� �4�24���;��b~�4�
3
+ �]Յ-w/�/��<A����Z-%�$V�
4
+ �vT��>������f "|�_�>He5�� �ɱ�����6��R�.F���_HD�(ø��\��s���p�rkU1�5�|��
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ script: bundle exec rake test
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in smart_mta.gemspec
4
4
  gemspec
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["John Duff"]
10
10
  s.email = ["john.duff@shopify.com"]
11
- s.homepage = "https://github.com/Shopify/dynect_email"
11
+ s.homepage = ""
12
12
  s.summary = %q{Integrate with the DynECT Email API.}
13
13
  s.description = %q{Provides integration with the DynECT Email API.}
14
14
 
@@ -16,7 +16,8 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_runtime_dependency("httparty")
18
18
  s.add_development_dependency("fakeweb")
19
- s.add_development_dependency("mocha")
19
+ s.add_development_dependency("mocha", "0.14.0")
20
+ s.add_development_dependency("rake")
20
21
 
21
22
  s.files = `git ls-files`.split("\n")
22
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -9,25 +9,53 @@ module DynectEmail
9
9
  attr_accessor :api_key
10
10
  end
11
11
 
12
+ # senders
13
+
12
14
  def self.add_sender(email, apikey=nil)
13
- post_data("/senders", {:emailaddress => email}, apikey)
15
+ request(:post, "/senders", {:emailaddress => email}, apikey)
14
16
  end
15
17
 
16
18
  def self.remove_sender(email, apikey=nil)
17
- post_data("/senders/delete", {:emailaddress => email}, apikey)
19
+ request(:post, "/senders/delete", {:emailaddress => email}, apikey)
18
20
  end
19
21
 
22
+ # accounts
23
+
20
24
  def self.add_account(username, password, company, phone, options={})
21
- post_data("/accounts", options.merge({:username => username, :password => password, :companyname => company, :phone => phone}))
25
+ request(:post, "/accounts", options.merge({:username => username, :password => password, :companyname => company, :phone => phone}))
22
26
  end
23
27
 
24
28
  def self.remove_account(username)
25
- post_data("/accounts/delete", :username => username)
29
+ request(:post, "/accounts/delete", :username => username)
30
+ end
31
+
32
+ # reports/bounces
33
+
34
+ def self.get_bounces_count(options = {})
35
+ request(:get, "/reports/bounces/count", options)
36
+ end
37
+
38
+ def self.get_bounces(options = {})
39
+ request(:get, "/reports/bounces", options)
40
+ end
41
+
42
+ # suppressions
43
+
44
+ def self.get_suppressions_count(options = {})
45
+ request(:get, "/suppressions/count", options)
46
+ end
47
+
48
+ def self.get_suppressions(options = {})
49
+ request(:get, "/suppressions", options)
50
+ end
51
+
52
+ def self.activate_suppression(email)
53
+ request(:post, "/suppressions/activate", :emailaddress => email)
26
54
  end
27
55
 
28
56
  # {:xheader1 => "X-header", xheader2 => ....}
29
57
  def self.set_headers(headers, apikey=nil)
30
- post_data("/accounts/xheaders", headers, apikey)
58
+ request(:post, "/accounts/xheaders", headers, apikey)
31
59
  end
32
60
 
33
61
  private
@@ -37,10 +65,16 @@ module DynectEmail
37
65
  response['response']['data']
38
66
  end
39
67
 
40
- def self.post_data(url, options={}, apikey=nil)
68
+ def self.request(http_method, url, options={}, apikey=nil)
41
69
  options.merge!(:apikey => apikey || DynectEmail.api_key)
42
- result = post(url, :body => options)
43
-
70
+ result = case http_method
71
+ when :post
72
+ post(url, :body => options)
73
+ when :get
74
+ get(url, :query => options)
75
+ else
76
+ raise "Invalid HTTP method"
77
+ end
44
78
  handle_response(result)
45
79
  end
46
80
  end
@@ -1,3 +1,3 @@
1
1
  module DynectEmail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,15 @@
1
+ dependencies:
2
+ override:
3
+ - bundle install --path=./data/bundler
4
+
5
+ deploy:
6
+ override:
7
+ - |
8
+ BUILD=`bundle exec rake build`
9
+ if [ $? != 0 ]; then
10
+ echo $BUILD;
11
+ exit 1;
12
+ fi
13
+ PKG=`echo $BUILD | cut -d" " -f5 | sed -e s/\.$//`;
14
+ VERSION=`echo $BUILD | cut -d" " -f2`;
15
+ gem push $PKG
@@ -131,4 +131,79 @@ class DynectEmailTest < Test::Unit::TestCase
131
131
 
132
132
  DynectEmail.set_headers({:xheader1 => "X-Sample1", :xheader2 => "X-Sample2"})
133
133
  end
134
+
135
+ def test_get_bounces_count
136
+ FakeWeb.register_uri(:get, %r|http://emailapi.dynect.net/rest/json/reports/bounces/count\?|, :body => load_fixture('ok'), :status => 200, :content_type => "text/json")
137
+
138
+ assert_nothing_raised do
139
+ DynectEmail.get_bounces_count
140
+ end
141
+ end
142
+
143
+ def test_get_bounces_count_sends_correct_parameters
144
+ DynectEmail.expects(:get).with("/reports/bounces/count", :query => {:startdate => "2012-08-01", :enddate => "2012-08-17", :sender => "test@example.com", :apikey => "12345"})
145
+ DynectEmail.expects(:handle_response)
146
+
147
+ DynectEmail.get_bounces_count({:startdate => '2012-08-01', :enddate => '2012-08-17', :sender => 'test@example.com'})
148
+ end
149
+
150
+ def test_get_bounces
151
+ FakeWeb.register_uri(:get, %r|http://emailapi.dynect.net/rest/json/reports/bounces\?|, :body => load_fixture('ok'), :status => 200, :content_type => "text/json")
152
+
153
+ assert_nothing_raised do
154
+ DynectEmail.get_bounces
155
+ end
156
+ end
157
+
158
+ def test_get_bounces_sends_correct_parameters
159
+ DynectEmail.expects(:get).with("/reports/bounces", :query => {:startdate => "2012-08-01", :enddate => "2012-08-17", :sender => "test@example.com", :apikey => "12345"})
160
+ DynectEmail.expects(:handle_response)
161
+
162
+ DynectEmail.get_bounces({:startdate => '2012-08-01', :enddate => '2012-08-17', :sender => 'test@example.com'})
163
+ end
164
+
165
+ def test_get_suppressions_count
166
+ FakeWeb.register_uri(:get, %r|http://emailapi.dynect.net/rest/json/suppressions/count\?|, :body => load_fixture('ok'), :status => 200, :content_type => "text/json")
167
+
168
+ assert_nothing_raised do
169
+ DynectEmail.get_suppressions_count
170
+ end
171
+ end
172
+
173
+ def test_get_suppressions_count_sends_correct_parameters
174
+ DynectEmail.expects(:get).with("/suppressions/count", :query => {:startdate => "2012-08-01", :enddate => "2012-08-17", :apikey => "12345"})
175
+ DynectEmail.expects(:handle_response)
176
+
177
+ DynectEmail.get_suppressions_count({:startdate => '2012-08-01', :enddate => '2012-08-17'})
178
+ end
179
+
180
+ def test_get_suppressions
181
+ FakeWeb.register_uri(:get, %r|http://emailapi.dynect.net/rest/json/suppressions\?|, :body => load_fixture('ok'), :status => 200, :content_type => "text/json")
182
+
183
+ assert_nothing_raised do
184
+ DynectEmail.get_suppressions
185
+ end
186
+ end
187
+
188
+ def test_get_suppressions_sends_correct_parameters
189
+ DynectEmail.expects(:get).with("/suppressions", :query => {:startdate => "2012-08-01", :enddate => "2012-08-17", :apikey => "12345"})
190
+ DynectEmail.expects(:handle_response)
191
+
192
+ DynectEmail.get_suppressions({:startdate => '2012-08-01', :enddate => '2012-08-17'})
193
+ end
194
+
195
+ def test_activate_suppression
196
+ FakeWeb.register_uri(:post, "http://emailapi.dynect.net/rest/json/suppressions/activate", :body => load_fixture('ok'), :status => 200, :content_type => "text/json")
197
+
198
+ assert_nothing_raised do
199
+ DynectEmail.activate_suppression('test@example.com')
200
+ end
201
+ end
202
+
203
+ def test_activate_suppression_sends_correct_parameters
204
+ DynectEmail.expects(:post).with("/suppressions/activate", :body => {:emailaddress => 'test@example.com', :apikey => "12345"})
205
+ DynectEmail.expects(:handle_response)
206
+
207
+ DynectEmail.activate_suppression('test@example.com')
208
+ end
134
209
  end
@@ -1,8 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'fakeweb'
4
- require 'mocha'
5
- require 'lib/dynect_email'
4
+ require 'mocha/setup'
5
+ require 'dynect_email'
6
6
 
7
7
  FakeWeb.allow_net_connect = false
8
8
 
metadata CHANGED
@@ -1,49 +1,93 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynect_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Duff
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain: []
12
- date: 2012-02-09 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZhZG1p
14
+ bnMxFzAVBgoJkiaJk/IsZAEZFgdzaG9waWZ5MRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTE0MDUxNTIwMzM0OFoXDTE1MDUxNTIwMzM0OFowPzEPMA0GA1UEAwwGYWRt
16
+ aW5zMRcwFQYKCZImiZPyLGQBGRYHc2hvcGlmeTETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0/81O3e1vh5smcwp2G
18
+ MpLQ6q0kejQLa65bPYPxdzWA1SYOKyGfw+yR9LdFzsuKpwWzKq6zX35lj1IckWS4
19
+ bNBEQzxmufUxU0XPM02haFB8fOfDJzdXsWte9Ge4IFwahwn68gpMqN+BvxL+KMYz
20
+ Iut9YmN44d4LZdsENEIO5vmybuG2vYDz7R56qB0PA+Q2P2CdhymsBad2DQs69FBo
21
+ uico9V6VMYYctL9lCYdzu9IXrOYNTt88suKIVzzAlHOKeN0Ng5qdztFoTR8sfxDr
22
+ Ydg3KHl5n47wlpgd8R0f/4b5gGxW+v9pyJCgQnLlRu7DedVSvv7+GMtj3g9r3nhJ
23
+ KqECAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFI/o
24
+ maf34HXbUOQsdoLHacEKQgunMB0GA1UdEQQWMBSBEmFkbWluc0BzaG9waWZ5LmNv
25
+ bTAdBgNVHRIEFjAUgRJhZG1pbnNAc2hvcGlmeS5jb20wDQYJKoZIhvcNAQEFBQAD
26
+ ggEBADkK9aj5T0HPExsov4EoMWFnO+G7RQ28C30VAfKxnL2UxG6i4XMHVs6Xi94h
27
+ qXFw1ec9Y2eDUqaolT3bviOk9BB197+A8Vz/k7MC6ci2NE+yDDB7HAC8zU6LAx8Y
28
+ Iqvw7B/PSZ/pz4bUVFlTATif4mi1vO3lidRkdHRtM7UePSn2rUpOi0gtXBP3bLu5
29
+ YjHJN7wx5cugMEyroKITG5gL0Nxtu21qtOlHX4Hc4KdE2JqzCPOsS4zsZGhgwhPs
30
+ fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
31
+ TConQSX2BnZdhIEYW+cKzEC/bLc=
32
+ -----END CERTIFICATE-----
33
+ date: 2014-05-20 00:00:00.000000000 Z
13
34
  dependencies:
14
35
  - !ruby/object:Gem::Dependency
15
36
  name: httparty
16
- requirement: &2156801220 !ruby/object:Gem::Requirement
17
- none: false
37
+ requirement: !ruby/object:Gem::Requirement
18
38
  requirements:
19
- - - ! '>='
39
+ - - ">="
20
40
  - !ruby/object:Gem::Version
21
41
  version: '0'
22
42
  type: :runtime
23
43
  prerelease: false
24
- version_requirements: *2156801220
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
25
49
  - !ruby/object:Gem::Dependency
26
50
  name: fakeweb
27
- requirement: &2156800780 !ruby/object:Gem::Requirement
28
- none: false
51
+ requirement: !ruby/object:Gem::Requirement
29
52
  requirements:
30
- - - ! '>='
53
+ - - ">="
31
54
  - !ruby/object:Gem::Version
32
55
  version: '0'
33
56
  type: :development
34
57
  prerelease: false
35
- version_requirements: *2156800780
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
36
63
  - !ruby/object:Gem::Dependency
37
64
  name: mocha
38
- requirement: &2156800360 !ruby/object:Gem::Requirement
39
- none: false
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.14.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '='
75
+ - !ruby/object:Gem::Version
76
+ version: 0.14.0
77
+ - !ruby/object:Gem::Dependency
78
+ name: rake
79
+ requirement: !ruby/object:Gem::Requirement
40
80
  requirements:
41
- - - ! '>='
81
+ - - ">="
42
82
  - !ruby/object:Gem::Version
43
83
  version: '0'
44
84
  type: :development
45
85
  prerelease: false
46
- version_requirements: *2156800360
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
47
91
  description: Provides integration with the DynECT Email API.
48
92
  email:
49
93
  - john.duff@shopify.com
@@ -51,7 +95,8 @@ executables: []
51
95
  extensions: []
52
96
  extra_rdoc_files: []
53
97
  files:
54
- - .gitignore
98
+ - ".gitignore"
99
+ - ".travis.yml"
55
100
  - Gemfile
56
101
  - MIT-LICENSE
57
102
  - README.md
@@ -59,40 +104,34 @@ files:
59
104
  - dynect_email.gemspec
60
105
  - lib/dynect_email.rb
61
106
  - lib/dynect_email/version.rb
107
+ - shipit.rubygems.yml
62
108
  - test/dynect_email_test.rb
63
109
  - test/fixtures/missing_or_invalid_api_key.json
64
110
  - test/fixtures/missing_or_invalid_fields.json
65
111
  - test/fixtures/object_already_exists.json
66
112
  - test/fixtures/ok.json
67
113
  - test/test_helper.rb
68
- homepage: https://github.com/Shopify/dynect_email
114
+ homepage: ''
69
115
  licenses: []
116
+ metadata: {}
70
117
  post_install_message:
71
118
  rdoc_options: []
72
119
  require_paths:
73
120
  - lib
74
121
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
122
  requirements:
77
- - - ! '>='
123
+ - - ">="
78
124
  - !ruby/object:Gem::Version
79
125
  version: '0'
80
126
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
127
  requirements:
83
- - - ! '>='
128
+ - - ">="
84
129
  - !ruby/object:Gem::Version
85
130
  version: '0'
86
131
  requirements: []
87
132
  rubyforge_project: dynect_email
88
- rubygems_version: 1.8.11
133
+ rubygems_version: 2.2.0
89
134
  signing_key:
90
- specification_version: 3
135
+ specification_version: 4
91
136
  summary: Integrate with the DynECT Email API.
92
- test_files:
93
- - test/dynect_email_test.rb
94
- - test/fixtures/missing_or_invalid_api_key.json
95
- - test/fixtures/missing_or_invalid_fields.json
96
- - test/fixtures/object_already_exists.json
97
- - test/fixtures/ok.json
98
- - test/test_helper.rb
137
+ test_files: []
Binary file