smtpapi 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0043c8ac0083fe2af73989b278f8d35437204b8
4
- data.tar.gz: 7d31d3e34e64a8dcac7fcb8925f7034e718127ee
3
+ metadata.gz: 4fbf767bac2cbf7e60ff3b5dcd0096a57813b439
4
+ data.tar.gz: 65dd3337529a894178d6e3dc4889e6a0c7fb2a8d
5
5
  SHA512:
6
- metadata.gz: bef30f02b5936961dadb844ea916320cfc318dde0133da4001214925cb295d2dbda1974df7d03c2365477b0691711692c2700f09ee86e3acecec9e4a263c8a45
7
- data.tar.gz: 2068c1b27e55032e2bdae4664b8648ca31041a338bc976a5915b47c61e1e01080f5e41b3cb2ade497002f5bcd30a09e307f80982c21043f747475597b3d33d99
6
+ metadata.gz: ab1fb72c15745b6e81088a5e234d931626d88d1102b8d24cf0823b6fd603852b46d6c8a929a2d3998e5d37d61dd9957a1be5104bf833f7b539adb3bcef23a0c1
7
+ data.tar.gz: 15eb7ef5f5c6ca140a6e5613fb7c98f08adeef8db31c4e74f9d4e84ba16f619a3228528c6cfdc9db4c1d5f4bbf9277f524ee6fdf53cc9c8006a18154a85d217d
data/README.md CHANGED
@@ -26,13 +26,13 @@ Or install it yourself as:
26
26
  header = Smtpapi::Header.new
27
27
  ```
28
28
 
29
- ### json_string
29
+ ### to_json
30
30
 
31
- This gives you back the stringified json formatted X-SMTPAPI header.
31
+ This gives you back the stringified json formatted X-SMTPAPI header.
32
32
 
33
33
  ```ruby
34
34
  header = Smtpapi::Header.new
35
- header.json_string
35
+ header.to_json
36
36
  ```
37
37
 
38
38
  ### add_to
@@ -43,7 +43,7 @@ header.add_to('you@youremail.com')
43
43
  header.add_to('other@otheremail.com')
44
44
  ```
45
45
 
46
- ### set_to
46
+ ### set_tos
47
47
 
48
48
  ```ruby
49
49
  header = Smtpapi::Header.new
@@ -122,17 +122,35 @@ header.add_filter('footer', 'text/html', '<strong>boo</strong>')
122
122
 
123
123
  ```ruby
124
124
  header = Smtpapi::Header.new
125
- filter = {
126
- 'footer' => {
127
- 'setting' => {
125
+ filter = {
126
+ 'footer' => {
127
+ 'setting' => {
128
128
  'enable' => 1,
129
129
  "text/plain" => 'You can haz footers!'
130
130
  }
131
131
  }
132
- }
132
+ }
133
133
  header.set_filters(filter)
134
134
  ```
135
135
 
136
+ ### set_send_all
137
+
138
+ ```ruby
139
+ header = Smtpapi::Header.new
140
+ lt = Time.local(2014, 8, 29, 17, 56, 35)
141
+ header.set_send_all(lt)
142
+ ```
143
+
144
+ ### set_send_each_at
145
+
146
+ ```ruby
147
+ header = Smtpapi::Header.new
148
+ lt1 = Time.local(2014, 8, 29, 17, 56, 35)
149
+ lt2 = Time.local(2013, 12, 31, 0, 0, 0)
150
+ lt3 = Time.local(2015, 9, 1, 4, 5, 6)
151
+ header.set_send_each_at([lt1, lt2, lt3])
152
+ ```
153
+
136
154
  ## Contributing
137
155
 
138
156
  1. Fork it ( http://github.com/sendgridjp/smtpapi-ruby/fork )
@@ -1,3 +1,3 @@
1
1
  module Smtpapi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/smtpapi.rb CHANGED
@@ -6,7 +6,7 @@ require "json"
6
6
  module Smtpapi
7
7
  class Header
8
8
 
9
- attr_reader :to, :sub, :section, :category, :unique_args, :filters
9
+ attr_reader :to, :sub, :section, :category, :unique_args, :filters, :send_all, :send_each_at
10
10
 
11
11
  def initialize
12
12
  @to = []
@@ -15,6 +15,8 @@ module Smtpapi
15
15
  @category = []
16
16
  @unique_args = {}
17
17
  @filters = {}
18
+ @send_all = nil
19
+ @send_each_at = []
18
20
  end
19
21
 
20
22
  def add_to(address, name=nil)
@@ -81,6 +83,14 @@ module Smtpapi
81
83
  self
82
84
  end
83
85
 
86
+ def set_send_all(send_all)
87
+ @send_all = send_all
88
+ end
89
+
90
+ def set_send_each_at(send_each_at)
91
+ @send_each_at = send_each_at
92
+ end
93
+
84
94
  def to_array
85
95
  data = {}
86
96
  data["to"] = @to if @to.length > 0
@@ -89,6 +99,12 @@ module Smtpapi
89
99
  data["unique_args"] = @unique_args if @unique_args.length > 0
90
100
  data["category"] = @category if @category.length > 0
91
101
  data["filters"] = @filters if @filters.length > 0
102
+ data["send_all"] = @send_all.to_i.to_s if @send_all != nil
103
+ str_each_at = []
104
+ @send_each_at.each {|val|
105
+ str_each_at.push(val.to_i.to_s)
106
+ }
107
+ data["send_each_at"] = str_each_at if str_each_at.length > 0
92
108
  data
93
109
  end
94
110
  protected :to_array
data/test/test.rb CHANGED
@@ -5,7 +5,7 @@ require "./lib/smtpapi"
5
5
  class SmtpapiTest < Test::Unit::TestCase
6
6
 
7
7
  def test_version
8
- assert_equal("0.0.3", Smtpapi::VERSION)
8
+ assert_equal("0.0.4", Smtpapi::VERSION)
9
9
  end
10
10
 
11
11
  def test_empty
@@ -106,4 +106,22 @@ class SmtpapiTest < Test::Unit::TestCase
106
106
  assert_equal("{\"category\":[\"\\u5929\\u7834\\u6d3b\\u6bba\",\"\\u5929\\u7fd4\\u5341\\u5b57\\u9cf3\"]}",header.json_string)
107
107
  end
108
108
 
109
+ def test_sent_send_all
110
+ header = Smtpapi::Header.new
111
+ localtime = Time.local(2014, 8, 29, 17, 56, 35)
112
+ header.set_send_all(localtime)
113
+
114
+ assert_equal("{\"send_all\":\"#{localtime.to_i}\"}", header.json_string)
115
+ end
116
+
117
+ def test_send_each_at
118
+ header = Smtpapi::Header.new
119
+ localtime1 = Time.local(2014, 8, 29, 17, 56, 35)
120
+ localtime2 = Time.local(2013, 12, 31, 0, 0, 0)
121
+ localtime3 = Time.local(2015, 9, 1, 4, 5, 6)
122
+ header.set_send_each_at([localtime1, localtime2, localtime3])
123
+
124
+ assert_equal("{\"send_each_at\":[\"#{localtime1.to_i}\",\"#{localtime2.to_i}\",\"#{localtime3.to_i}\"]}", header.json_string)
125
+ end
126
+
109
127
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smtpapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wataru Sato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler