send_with_us 1.9.1 → 1.10.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c3166be52d755e59c32175ea92a24c875167bc0
4
+ data.tar.gz: e14b4da5845a1c52f2f82f499e4281d732f07163
5
+ SHA512:
6
+ metadata.gz: b502c9aa83b54dbd090cf2a71943894b45442ce71b6ce62e081c1a698d61ab6681f3057dfe5db070a7fd864f72b6dddda96bb8b80419f6e421014290fc0981c8
7
+ data.tar.gz: c7ed1be0ffecbb22a046ec1a8d9d336ab2b8e28d61ddfb5af8869fad091d884dbe644ac572db80ff8341526b97a5837b53972e8c939c107f0db899215baa4f11
@@ -1,3 +1,4 @@
1
+ 1.10.1 - tag support, error base class, logs method
1
2
  1.9.0 - Locale support. Introduce send_email(). Deprecate send_with().
2
3
  1.8.0 - Tags support for send_with
3
4
  1.7.0 -
data/Gemfile CHANGED
@@ -5,13 +5,14 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  # Test Dependencies
8
- gem 'mocha', '0.10.5'
9
- gem 'i18n', '0.6.1'
10
- gem 'rake', '10.0.3'
11
- gem 'multi_json', '1.5.0'
12
- gem 'metaclass', '0.0.1'
13
- gem 'shoulda-context', '1.0.2'
14
- gem 'activesupport', '3.2.11'
15
- gem 'bourne', '1.1.2'
16
- gem 'shoulda-matchers', '1.4.2'
17
- gem 'shoulda', '3.3.2'
8
+ gem 'mocha', '~> 1.1'
9
+ gem 'i18n', '~> 0.7'
10
+ gem 'rake', '~> 10.4'
11
+ gem 'multi_json', '~> 1.11'
12
+ gem 'metaclass', '~> 0.0.4'
13
+ gem 'shoulda-context', '~> 1.2'
14
+ gem 'activesupport', '~> 4.2'
15
+ gem 'bourne', '~> 1.6'
16
+ gem 'shoulda-matchers','~> 2.8'
17
+ gem 'shoulda', '~> 3.5'
18
+ gem 'minitest', '~> 5.7'
data/README.md CHANGED
@@ -145,7 +145,7 @@ begin
145
145
  address: 'bcc@example.com' },
146
146
  { name: 'BCC2',
147
147
  address: 'bcc2@example.com' }
148
- ])
148
+ ],
149
149
  files: ['path/to/attachment.txt'],
150
150
  esp_account: 'esp_MYESPACCOUNT',
151
151
  version: 'v2',
@@ -172,7 +172,7 @@ begin
172
172
  address: 'bcc@example.com' },
173
173
  { name: 'BCC2',
174
174
  address: 'bcc2@example.com' }
175
- ])
175
+ ],
176
176
  ['path/to/attachment.txt'],
177
177
  'esp_MYESPACCOUNT',
178
178
  'v2',
@@ -309,6 +309,20 @@ Take a look at our Mailer that you can use to replace ActionMailer
309
309
  [sendwithus_ruby_action_mailer](https://github.com/sendwithus/sendwithus_ruby_action_mailer)
310
310
 
311
311
 
312
+ ## Logs
313
+
314
+ Optional Arguments:
315
+ - **count** – The number of logs to return. _Max: 100, Default: 100._
316
+ - **offset** – Offset the number of logs to return. _Default: 0_
317
+ - **created_gt** – Return logs created strictly after the given UTC timestamp.
318
+ - **created_gte** – Return logs created on or after the given UTC timestamp.
319
+ - **created_lt** – Return logs created strictly before the given UTC timestamp.
320
+ - **created_lte** – Return logs created on or before the given UTC timestamp.
321
+
322
+ ```ruby
323
+ obj.logs(count: 1, offset: 1)
324
+ ```
325
+
312
326
  ## Errors
313
327
 
314
328
  The following errors may be generated:
@@ -257,5 +257,31 @@ module SendWithUs
257
257
  endpoint = "customers/#{email}"
258
258
  SendWithUs::ApiRequest.new(@configuration).delete(endpoint)
259
259
  end
260
+
261
+ def logs(options = {})
262
+ endpoint = "logs"
263
+
264
+ params = {}
265
+
266
+ params[:count] = options[:count] unless options[:count].nil?
267
+ params[:offset] = options[:offset] unless options[:offset].nil?
268
+ params[:created_gt] = options[:created_gt] unless options[:created_gt].nil?
269
+ params[:created_gte] = options[:created_gte] unless options[:created_gte].nil?
270
+ params[:created_lt] = options[:created_lt] unless options[:created_lt].nil?
271
+ params[:created_lte] = options[:created_lte] unless options[:created_lte].nil?
272
+
273
+ if params.nil?
274
+ params = URI.encode_www_form(params)
275
+ endpoint = endpoint + "?" + params
276
+ end
277
+
278
+ SendWithUs::ApiRequest.new(@configuration).get(endpoint)
279
+ end
280
+
281
+ def log(log_id)
282
+ endpoint = "logs/#{log_id}"
283
+
284
+ SendWithUs::ApiRequest.new(@configuration).get(endpoint)
285
+ end
260
286
  end
261
287
  end
@@ -16,8 +16,8 @@ module SendWithUs
16
16
  request(Net::HTTP::Post, request_path(endpoint), payload)
17
17
  end
18
18
 
19
- def get(endpoint)
20
- request(Net::HTTP::Get, request_path(endpoint))
19
+ def get(endpoint, payload = nil)
20
+ request(Net::HTTP::Get, request_path(endpoint), payload)
21
21
  end
22
22
 
23
23
  def delete(endpoint)
@@ -1,3 +1,3 @@
1
1
  module SendWithUs
2
- VERSION = '1.9.1'
2
+ VERSION = '1.10.1'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
- class TestApiRequest < MiniTest::Unit::TestCase
3
+ class TestApiRequest < Minitest::Test
4
4
 
5
5
  def build_objects
6
6
  @payload = {}
@@ -195,6 +195,12 @@ class TestApiRequest < MiniTest::Unit::TestCase
195
195
  assert_instance_of( Net::HTTPSuccess, @request.get(:'drip_campaigns') )
196
196
  end
197
197
 
198
+ def test_get_with_params_for_logs
199
+ build_objects
200
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
201
+ assert_instance_of( Net::HTTPSuccess, @request.get(:'logs', {count: 10}.to_json) )
202
+ end
203
+
198
204
  def test_start_on_drip_campaign
199
205
  build_objects
200
206
  Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
@@ -254,4 +260,10 @@ class TestApiRequest < MiniTest::Unit::TestCase
254
260
  assert_instance_of( Net::HTTPSuccess, @request.delete(:'customers/#{@customer[:email]}'))
255
261
  end
256
262
 
263
+ def test_logs_with_options()
264
+ build_objects
265
+ Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
266
+ assert_instance_of( Net::HTTPSuccess, @request.get(:'logs?count=2&offset=10'))
267
+ end
268
+
257
269
  end
@@ -1,6 +1,7 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  describe SendWithUs::Api do
4
+ let(:subject) { SendWithUs::Api.new }
4
5
 
5
6
  describe '.configuration with initializer' do
6
7
  before do
@@ -21,4 +22,25 @@ describe SendWithUs::Api do
21
22
  it('configs') { SendWithUs::Api.new( api_key: @custom_api_key ).configuration.api_key.must_equal @custom_api_key }
22
23
  end
23
24
 
25
+ describe '#logs' do
26
+ describe 'without options' do
27
+ let(:options) { nil }
28
+ before { SendWithUs::ApiRequest.any_instance.expects(:get).with('logs') }
29
+
30
+ it { subject.logs }
31
+ end
32
+ end
33
+
34
+ describe '#log' do
35
+ describe 'with log_id' do
36
+ let(:log_id) { 'log_TESTTEST123' }
37
+ before { SendWithUs::ApiRequest.any_instance.expects(:get).with("logs/#{log_id}") }
38
+
39
+ it { subject.log(log_id) }
40
+ end
41
+
42
+ describe 'without log_id' do
43
+ it { -> { subject.log }.must_raise ArgumentError }
44
+ end
45
+ end
24
46
  end
@@ -1,6 +1,6 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
- class TestAttachment < MiniTest::Unit::TestCase
3
+ class TestAttachment < Minitest::Test
4
4
  describe "#filename" do
5
5
  describe "when a filename is explicitly declared" do
6
6
  before do
@@ -1,6 +1,6 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
- class TestConfig < MiniTest::Unit::TestCase
3
+ class TestConfig < Minitest::Test
4
4
 
5
5
  def test_class_defaults
6
6
  assert_equal( false, SendWithUs::Config.defaults.empty? )
@@ -1,6 +1,6 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
- class TestVersion < MiniTest::Unit::TestCase
3
+ class TestVersion < Minitest::Test
4
4
 
5
5
  def test_version
6
6
  assert_equal( false, SendWithUs::VERSION.nil? )
@@ -5,7 +5,7 @@ require File.expand_path('../../lib/send_with_us.rb', __FILE__)
5
5
 
6
6
  require 'rubygems'
7
7
  require 'bundler'
8
- require 'mocha'
8
+ require "mocha/mini_test"
9
9
 
10
10
  begin
11
11
  Bundler.setup(:default, :development)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: send_with_us
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
5
- prerelease:
4
+ version: 1.10.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Harris
@@ -11,54 +10,48 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2015-02-06 00:00:00.000000000 Z
13
+ date: 2015-06-09 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rake
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - ">="
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
24
22
  type: :development
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - ">="
30
27
  - !ruby/object:Gem::Version
31
28
  version: '0'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: shoulda
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - ">="
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0'
40
36
  type: :development
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - ">="
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: mocha
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - ">="
54
48
  - !ruby/object:Gem::Version
55
49
  version: '0'
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - ">="
62
55
  - !ruby/object:Gem::Version
63
56
  version: '0'
64
57
  description: SendWithUs.com Ruby Client
@@ -68,8 +61,8 @@ executables: []
68
61
  extensions: []
69
62
  extra_rdoc_files: []
70
63
  files:
71
- - .gitignore
72
- - .travis.yml
64
+ - ".gitignore"
65
+ - ".travis.yml"
73
66
  - CHANGELOG.md
74
67
  - Gemfile
75
68
  - LICENSE
@@ -92,27 +85,26 @@ files:
92
85
  homepage: https://github.com/sendwithus/sendwithus_ruby
93
86
  licenses:
94
87
  - Apache-2.0
88
+ metadata: {}
95
89
  post_install_message:
96
90
  rdoc_options: []
97
91
  require_paths:
98
92
  - lib
99
93
  required_ruby_version: !ruby/object:Gem::Requirement
100
- none: false
101
94
  requirements:
102
- - - ! '>='
95
+ - - ">="
103
96
  - !ruby/object:Gem::Version
104
97
  version: '0'
105
98
  required_rubygems_version: !ruby/object:Gem::Requirement
106
- none: false
107
99
  requirements:
108
- - - ! '>='
100
+ - - ">="
109
101
  - !ruby/object:Gem::Version
110
102
  version: '0'
111
103
  requirements: []
112
104
  rubyforge_project:
113
- rubygems_version: 1.8.23.2
105
+ rubygems_version: 2.2.2
114
106
  signing_key:
115
- specification_version: 3
107
+ specification_version: 4
116
108
  summary: SendWithUs.com Ruby Client
117
109
  test_files:
118
110
  - test/lib/send_with_us/api_request_test.rb