send_with_us 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb22ce6f21aba1a56300d9053b3dcfd32f6a86e8
4
- data.tar.gz: c76b1a8d8164876606ad0e557eee35b44feb7f83
3
+ metadata.gz: a57e3e4b0f5abe4f4cabc867fbc17337be2ba10c
4
+ data.tar.gz: 17a35935697a76d5d537172ac6038c50565078b5
5
5
  SHA512:
6
- metadata.gz: 99ec0c8f81778add459db53d53aa9ca44a88f4f68aa2e980eceee9968352dd51f6c19e5361df9873ec3159c4719545d450f2595d78bbe7a6f594ff871c69019f
7
- data.tar.gz: d1772d7fef1f93635b7e4dbd386bba5194dca363a4f9e2c261cb6e5cee6ded9928d35c71c5ec37631a0e36d6296a411b7fe8139eedbc2826ee8ff8dc3db80852
6
+ metadata.gz: 046333ff32245579376b1710560c53da4a69376516f62db4580311489d0eb48584982c13cfa2adcfc1663e510f2bbed343aaff2cd012cd5d468e5adc08180bdd
7
+ data.tar.gz: d36dca29256262b28888455194397b411d3ed93de23557a3c3164e311a11e75ea9cface3e69a74d39efa96a6efa002099e17f55a418e8c69d5ea6031aae39ea9
data/README.md CHANGED
@@ -8,68 +8,113 @@ Ruby bindings for sending email via the sendwithus API.
8
8
 
9
9
  ## Installation
10
10
 
11
- gem install send_with_us
11
+ ```bash
12
+ gem install send_with_us
13
+ ```
12
14
 
13
15
  or with Bundler:
14
16
 
15
- gem 'send_with_us'
16
- bundle install
17
+ ```bash
18
+ gem 'send_with_us'
19
+ bundle install
20
+ ```
17
21
 
18
22
  ## Usage
19
23
 
20
24
  ### General
21
25
 
22
26
  For any Ruby project:
23
-
24
- require 'rubygems'
25
- require 'send_with_us'
26
-
27
- begin
28
- obj = SendWithUs::Api.new( api_key: 'YOUR API KEY', debug: true )
29
-
30
- # with only required params
31
- result = obj.send_with(
27
+ ```ruby
28
+ require 'rubygems'
29
+ require 'send_with_us'
30
+
31
+ begin
32
+ obj = SendWithUs::Api.new( api_key: 'YOUR API KEY', debug: true )
33
+
34
+ # only required params
35
+ result = obj.send_with(
36
+ 'EMAIL_ID',
37
+ { address: "user@email.com" })
38
+ puts result
39
+
40
+ # with all optional params
41
+ result = obj.send_with(
32
42
  'email_id',
33
- { address: "user@email.com" },
34
- { company_name: 'TestCo' })
35
- puts result
36
-
37
- # with all optional params
38
- result = obj.send_with(
43
+ { name: 'Matt', address: 'recipient@testco.com' },
44
+ { company_name: 'TestCo' },
45
+ { name: 'Company',
46
+ address: 'company@testco.com',
47
+ reply_to: 'info@testco.com' })
48
+ puts result
49
+
50
+ # COMING SOON
51
+ # cc/bb support is coming soon, here's a taste test
52
+ result = obj.send_with(
39
53
  'email_id',
40
54
  { name: 'Matt', address: 'recipient@testco.com' },
41
55
  { company_name: 'TestCo' },
42
56
  { name: 'Company',
43
- address: 'company@testco.com',
44
- reply_to: 'info@testco.com' })
45
- puts result
46
- rescue Exception => e
47
- puts "Error - #{e.class.name}: #{e.message}"
48
- end
57
+ address: 'company@testco.com',
58
+ reply_to: 'info@testco.com' },
59
+ [
60
+ { name: 'CC',
61
+ address: 'cc@testco.com' }
62
+ ],
63
+ [
64
+ { name: 'BCC',
65
+ address: 'bcc@testco.com' },
66
+ { name: 'BCC2',
67
+ address: 'bcc2@test.com' }
68
+ ])
69
+ puts result
70
+ rescue Exception => e
71
+ puts "Error - #{e.class.name}: #{e.message}"
72
+ end
73
+ ```
49
74
 
50
75
  ### Rails
51
76
 
52
77
  For a Rails app, create `send_with_us.rb` in `/config/initializers/`
53
78
  with the following:
54
79
 
55
- SendWithUs::Api.configure do |config|
56
- config.api_key = 'YOUR API KEY'
57
- config.debug = true
58
- end
80
+ ```ruby
81
+ SendWithUs::Api.configure do |config|
82
+ config.api_key = 'YOUR API KEY'
83
+ config.debug = true
84
+ end
85
+ ```
59
86
 
60
87
  In your application code where you want to send an email:
61
88
 
62
- begin
63
- result = SendWithUs::Api.new.send_with('email_id', { address: 'recipient@testco.com' }, { company_name: 'TestCo' })
64
- puts result
65
- rescue Exception => e
66
- puts "Error - #{e.class.name}: #{e.message}"
67
- end
89
+ ```ruby
90
+ begin
91
+ result = SendWithUs::Api.new.send_with('email_id', { address: 'recipient@testco.com' }, { company_name: 'TestCo' })
92
+ puts result
93
+ rescue Exception => e
94
+ puts "Error - #{e.class.name}: #{e.message}"
95
+ end
96
+ ```
68
97
 
69
98
  ## Errors
70
99
 
71
100
  The following errors may be generated:
72
101
 
73
- SendWithUs::ApiInvalidEndpoint - the target URI is probably incorrect or email_id is invalid
74
- SendWithUs::ApiConnectionRefused - the target URI is probably incorrect
75
- SendWithUs::ApiUnknownError - an unhandled HTTP error occurred
102
+ ```ruby
103
+ SendWithUs::ApiInvalidEndpoint - the target URI is probably incorrect or email_id is invalid
104
+ SendWithUs::ApiConnectionRefused - the target URI is probably incorrect
105
+ SendWithUs::ApiUnknownError - an unhandled HTTP error occurred
106
+ ```
107
+
108
+ ## Internal
109
+ Build gem with
110
+
111
+ ```bash
112
+ gem build send_with_us.gemspec
113
+ ```
114
+
115
+ Publish gem with
116
+
117
+ ```bash
118
+ gem publish send_with_us-VERSION.gem
119
+ ```
120
+
@@ -20,12 +20,21 @@ module SendWithUs
20
20
  @configuration = SendWithUs::Config.new(settings)
21
21
  end
22
22
 
23
- def send_with(email_id, to, data = {}, from = {})
23
+ def send_with(email_id, to, data = {}, from = {}, cc={}, bcc={})
24
+ payload = { email_id: email_id, recipient: to,
25
+ email_data: data }
26
+
24
27
  if from.any?
25
- payload = { email_id: email_id, recipient: to, sender: from, email_data: data }.to_json
26
- else
27
- payload = { email_id: email_id, recipient: to, email_data: data }.to_json
28
+ payload[:sender] = from
29
+ end
30
+ if cc.any?
31
+ payload[:cc] = cc
28
32
  end
33
+ if bcc.any?
34
+ payload[:bcc] = bcc
35
+ end
36
+
37
+ payload = payload.to_json
29
38
  SendWithUs::ApiRequest.new(@configuration).send_with(payload)
30
39
  end
31
40
 
@@ -14,6 +14,7 @@ module SendWithUs
14
14
  path = request_path(:send)
15
15
  request = Net::HTTP::Post.new(path, initheader = {'Content-Type' =>'application/json'})
16
16
  request.add_field('X-SWU-API-KEY', @configuration.api_key)
17
+ request.add_field('X-SWU-API-CLIENT', @configuration.client_stub)
17
18
 
18
19
  http = Net::HTTP.new(@configuration.host, @configuration.port)
19
20
  http.use_ssl = use_ssl?
@@ -38,6 +39,7 @@ module SendWithUs
38
39
  path = request_path(endpoint)
39
40
  request = Net::HTTP::Get.new(path, initheader = {'Content-Type' =>'application/json'})
40
41
  request.add_field('X-SWU-API-KEY', @configuration.api_key)
42
+ request.add_field('X-SWU-API-CLIENT', @configuration.client_stub)
41
43
 
42
44
  http = Net::HTTP.new(@configuration.host, @configuration.port)
43
45
  http.use_ssl = use_ssl?
@@ -1,3 +1,5 @@
1
+ require_relative 'version'
2
+
1
3
  module SendWithUs
2
4
  class Config
3
5
  attr_accessor :settings
@@ -15,7 +17,8 @@ module SendWithUs
15
17
  host: source.host,
16
18
  port: source.port,
17
19
  api_version: '1_0',
18
- debug: true
20
+ debug: true,
21
+ client_stub: "ruby-#{VERSION}"
19
22
  }
20
23
  end
21
24
 
@@ -1,3 +1,3 @@
1
1
  module SendWithUs
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
data/send_with_us.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.email = ["us@sendwithus.com"]
12
12
  gem.description = %q{SendWithUs.com Ruby Client}
13
13
  gem.summary = %q{SendWithUs.com Ruby Client}
14
- gem.homepage = "http://www.sendwithus.com"
14
+ gem.homepage = "https://github.com/sendwithus/sendwithus_ruby"
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: send_with_us
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Harris
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-22 00:00:00.000000000 Z
12
+ date: 2013-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ! '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: shoulda
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ! '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ! '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: mocha
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ! '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ! '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  description: SendWithUs.com Ruby Client
@@ -79,7 +79,7 @@ files:
79
79
  - test/lib/send_with_us/config_test.rb
80
80
  - test/lib/send_with_us/version_test.rb
81
81
  - test/test_helper.rb
82
- homepage: http://www.sendwithus.com
82
+ homepage: https://github.com/sendwithus/sendwithus_ruby
83
83
  licenses: []
84
84
  metadata: {}
85
85
  post_install_message:
@@ -88,17 +88,17 @@ require_paths:
88
88
  - lib
89
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.0.3
101
+ rubygems_version: 2.0.7
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: SendWithUs.com Ruby Client