Commit d1dd675ddeac3eb561b850984243a1b66c8730f0
1 parent
3d2cc9a9
Exists in
master
add api_url
Showing
3 changed files
with
7 additions
and
22 deletions
Show diff stats
lib/sendcloud/attachment.rb
... | ... | @@ -1,16 +0,0 @@ |
1 | -module Sendcloud | |
2 | - class Attachment < StringIO | |
3 | - attr_reader :original_filename, :content_type, :path | |
4 | - | |
5 | - def initialize (attachment, *rest) | |
6 | - @path = '' | |
7 | - if rest.detect {|opt| opt[:inline] } | |
8 | - basename = @original_filename = attachment.cid | |
9 | - else | |
10 | - basename = @original_filename = attachment.filename | |
11 | - end | |
12 | - @content_type = attachment.content_type.split(';')[0] | |
13 | - super attachment.body.decoded | |
14 | - end | |
15 | - end | |
16 | -end |
lib/sendcloud/client.rb
... | ... | @@ -2,11 +2,12 @@ require 'rest_client' |
2 | 2 | |
3 | 3 | module Sendcloud |
4 | 4 | class Client |
5 | - attr_reader :api_key, :domain | |
5 | + attr_reader :api_key, :domain, :api_url | |
6 | 6 | |
7 | 7 | def initialize(api_key, domain) |
8 | 8 | @api_key = api_key |
9 | 9 | @domain = domain |
10 | + @api_url = api_url | |
10 | 11 | end |
11 | 12 | |
12 | 13 | def send_message(options) |
... | ... | @@ -14,11 +15,7 @@ module Sendcloud |
14 | 15 | end |
15 | 16 | |
16 | 17 | def sendcloud_url |
17 | - api_url+"/messages" | |
18 | - end | |
19 | - | |
20 | - def api_url | |
21 | - "http://api.sendcloud.net/apiv2/mail" | |
18 | + @api_url | |
22 | 19 | end |
23 | 20 | end |
24 | 21 | end | ... | ... |
lib/sendcloud/deliverer.rb
... | ... | @@ -15,6 +15,10 @@ module Sendcloud |
15 | 15 | self.settings[:api_key] |
16 | 16 | end |
17 | 17 | |
18 | + def api_url | |
19 | + self.settings[:api_url] | |
20 | + end | |
21 | + | |
18 | 22 | def deliver!(rails_message) |
19 | 23 | response = sendcloud_client.send_message build_sendcloud_message_for(rails_message) |
20 | 24 | if response.code == 200 | ... | ... |