createsend 0.0.2 → 0.1.0
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.
- data/lib/client.rb +1 -2
- data/lib/createsend.rb +3 -3
- data/test/client_test.rb +1 -1
- data/test/createsend_test.rb +4 -4
- data/test/fixtures/campaign_unsubscribes.json +0 -1
- metadata +3 -3
data/lib/client.rb
CHANGED
@@ -102,10 +102,9 @@ class Client
|
|
102
102
|
end
|
103
103
|
|
104
104
|
# Sets the monthly billing settings for this client.
|
105
|
-
def set_monthly_billing(currency,
|
105
|
+
def set_monthly_billing(currency, client_pays, markup_percentage)
|
106
106
|
options = { :body => {
|
107
107
|
:Currency => currency,
|
108
|
-
:CanPurchaseCredits => can_purchase_credits,
|
109
108
|
:ClientPays => client_pays,
|
110
109
|
:MarkupPercentage => markup_percentage }.to_json }
|
111
110
|
put 'setmonthlybilling', options
|
data/lib/createsend.rb
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
class ClientError < StandardError; end
|
36
36
|
class ServerError < StandardError; end
|
37
37
|
class BadRequest < CreateSendError; end
|
38
|
-
class Unauthorized <
|
38
|
+
class Unauthorized < CreateSendError; end
|
39
39
|
class NotFound < ClientError; end
|
40
40
|
class Unavailable < StandardError; end
|
41
41
|
|
@@ -43,7 +43,7 @@ class Unavailable < StandardError; end
|
|
43
43
|
class CreateSend
|
44
44
|
include HTTParty
|
45
45
|
|
46
|
-
VER = "0.0
|
46
|
+
VER = "0.1.0" unless defined?(CreateSend::VER)
|
47
47
|
headers({ 'User-Agent' => "createsend-ruby-#{CreateSend::VER}", 'Content-Type' => 'application/json' })
|
48
48
|
base_uri CreateSendOptions['base_uri']
|
49
49
|
basic_auth CreateSendOptions['api_key'], 'x'
|
@@ -100,7 +100,7 @@ class CreateSend
|
|
100
100
|
when 400
|
101
101
|
raise BadRequest.new(Hashie::Mash.new response)
|
102
102
|
when 401
|
103
|
-
raise Unauthorized.new
|
103
|
+
raise Unauthorized.new(Hashie::Mash.new response)
|
104
104
|
when 404
|
105
105
|
raise NotFound.new
|
106
106
|
when 400...500
|
data/test/client_test.rb
CHANGED
@@ -105,7 +105,7 @@ class ClientTest < Test::Unit::TestCase
|
|
105
105
|
|
106
106
|
should "set monthly billing" do
|
107
107
|
stub_put(@api_key, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
|
108
|
-
@client.set_monthly_billing "CAD", true,
|
108
|
+
@client.set_monthly_billing "CAD", true, 150
|
109
109
|
end
|
110
110
|
|
111
111
|
should "delete a client" do
|
data/test/createsend_test.rb
CHANGED
@@ -64,14 +64,14 @@ class CreateSendTest < Test::Unit::TestCase
|
|
64
64
|
}.each do |status, exception|
|
65
65
|
context "#{status.first}, a get" do
|
66
66
|
should "raise a #{exception.name} error" do
|
67
|
-
stub_get(@api_key, "countries.json", status.first == '400' ? 'custom_api_error.json' : nil, status)
|
67
|
+
stub_get(@api_key, "countries.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
|
68
68
|
lambda { c = @cs.countries }.should raise_error(exception)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
context "#{status.first}, a post" do
|
73
73
|
should "raise a #{exception.name} error" do
|
74
|
-
stub_post(@api_key, "clients.json", status.first == '400' ? 'custom_api_error.json' : nil, status)
|
74
|
+
stub_post(@api_key, "clients.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
|
75
75
|
lambda { Client.create "Client Company Name", "Client Contact Name", "client@example.com",
|
76
76
|
"(GMT+10:00) Canberra, Melbourne, Sydney", "Australia" }.should raise_error(exception)
|
77
77
|
end
|
@@ -79,7 +79,7 @@ class CreateSendTest < Test::Unit::TestCase
|
|
79
79
|
|
80
80
|
context "#{status.first}, a put" do
|
81
81
|
should "raise a #{exception.name} error" do
|
82
|
-
stub_put(@api_key, "templates/#{@template.template_id}.json", status.first == '400' ? 'custom_api_error.json' : nil, status)
|
82
|
+
stub_put(@api_key, "templates/#{@template.template_id}.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
|
83
83
|
lambda { @template.update "Template One Updated", "http://templates.org/index.html",
|
84
84
|
"http://templates.org/files.zip", "http://templates.org/screenshot.jpg" }.should raise_error(exception)
|
85
85
|
end
|
@@ -87,7 +87,7 @@ class CreateSendTest < Test::Unit::TestCase
|
|
87
87
|
|
88
88
|
context "#{status.first}, a delete" do
|
89
89
|
should "raise a #{exception.name} error" do
|
90
|
-
stub_delete(@api_key, "templates/#{@template.template_id}.json", status.first == '400' ? 'custom_api_error.json' : nil, status)
|
90
|
+
stub_delete(@api_key, "templates/#{@template.template_id}.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
|
91
91
|
lambda { @template.delete }.should raise_error(exception)
|
92
92
|
end
|
93
93
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Dennes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-25 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|