locaweb-emailmarketing 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +133 -0
- data/Rakefile +1 -0
- data/lib/locaweb-emailmarketing.rb +12 -0
- data/lib/locaweb-emailmarketing/adapters.rb +1 -0
- data/lib/locaweb-emailmarketing/adapters/http_request_adapter.rb +38 -0
- data/lib/locaweb-emailmarketing/client.rb +60 -0
- data/lib/locaweb-emailmarketing/clients.rb +14 -0
- data/lib/locaweb-emailmarketing/clients/account_client.rb +22 -0
- data/lib/locaweb-emailmarketing/clients/base_client.rb +52 -0
- data/lib/locaweb-emailmarketing/clients/campaign_client.rb +13 -0
- data/lib/locaweb-emailmarketing/clients/contact_client.rb +12 -0
- data/lib/locaweb-emailmarketing/clients/contact_import_client.rb +19 -0
- data/lib/locaweb-emailmarketing/clients/custom_field_client.rb +12 -0
- data/lib/locaweb-emailmarketing/clients/domain_client.rb +12 -0
- data/lib/locaweb-emailmarketing/clients/list_client.rb +12 -0
- data/lib/locaweb-emailmarketing/clients/message_client.rb +13 -0
- data/lib/locaweb-emailmarketing/clients/report_client.rb +41 -0
- data/lib/locaweb-emailmarketing/clients/sender_client.rb +15 -0
- data/lib/locaweb-emailmarketing/clients/template_client.rb +12 -0
- data/lib/locaweb-emailmarketing/clients/unsubscribe_reason_client.rb +13 -0
- data/lib/locaweb-emailmarketing/lib/hash.rb +9 -0
- data/lib/locaweb-emailmarketing/libs.rb +1 -0
- data/lib/locaweb-emailmarketing/version.rb +5 -0
- data/locaweb-emailmarketing.gemspec +30 -0
- data/spec/fixtures/cassettes/accounts_all.yml +74 -0
- data/spec/fixtures/cassettes/accounts_get.yml +77 -0
- data/spec/fixtures/cassettes/accounts_update.yml +124 -0
- data/spec/fixtures/cassettes/custom_field_all.yml +150 -0
- data/spec/fixtures/cassettes/custom_field_create.yml +263 -0
- data/spec/fixtures/cassettes/custom_field_destroy.yml +187 -0
- data/spec/fixtures/cassettes/custom_field_get.yml +146 -0
- data/spec/fixtures/cassettes/custom_field_update.yml +265 -0
- data/spec/fixtures/cassettes/reports_bounces.yml +75 -0
- data/spec/fixtures/cassettes/reports_clicks.yml +74 -0
- data/spec/fixtures/cassettes/reports_links.yml +73 -0
- data/spec/fixtures/cassettes/reports_openings.yml +74 -0
- data/spec/fixtures/cassettes/reports_overview.yml +75 -0
- data/spec/fixtures/cassettes/reports_uniq_openings.yml +74 -0
- data/spec/locaweb-emailmarketing/adapters/http_request_adapter_spec.rb +63 -0
- data/spec/locaweb-emailmarketing/client_spec.rb +14 -0
- data/spec/locaweb-emailmarketing/clients/account_client_spec.rb +37 -0
- data/spec/locaweb-emailmarketing/clients/base_client_spec.rb +77 -0
- data/spec/locaweb-emailmarketing/clients/campaign_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/contact_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/contact_import_client_spec.rb +9 -0
- data/spec/locaweb-emailmarketing/clients/custom_field_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/domains_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/list_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/message_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/report_client_spec.rb +70 -0
- data/spec/locaweb-emailmarketing/clients/sender_client_spec.rb +9 -0
- data/spec/locaweb-emailmarketing/clients/template_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/clients/unsubscribe_reason_client_spec.rb +10 -0
- data/spec/locaweb-emailmarketing/lib/hash_spec.rb +23 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/base_client_examples.rb +100 -0
- metadata +193 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://emailmarketing.locaweb.com.br/api/v1/accounts/50f8e28abf8d79f935000001/messages/50f9828436e1d9ce0d000fd5/openings
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Auth-Token:
|
15
|
+
- Nt5skc1xXsvKKSsyp3Bsx7ABNdJz9pc1uA9kyTdjnJkr
|
16
|
+
User-Agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: !binary |-
|
22
|
+
T0s=
|
23
|
+
headers:
|
24
|
+
!binary "U2VydmVy":
|
25
|
+
- !binary |-
|
26
|
+
bmdpbngvMS4xLjI=
|
27
|
+
!binary "RGF0ZQ==":
|
28
|
+
- !binary |-
|
29
|
+
RnJpLCAxOCBKYW4gMjAxMyAxNzozMTowMyBHTVQ=
|
30
|
+
!binary "Q29udGVudC1UeXBl":
|
31
|
+
- !binary |-
|
32
|
+
YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
|
33
|
+
!binary "VHJhbnNmZXItRW5jb2Rpbmc=":
|
34
|
+
- !binary |-
|
35
|
+
Y2h1bmtlZA==
|
36
|
+
!binary "Q29ubmVjdGlvbg==":
|
37
|
+
- !binary |-
|
38
|
+
a2VlcC1hbGl2ZQ==
|
39
|
+
!binary "VmFyeQ==":
|
40
|
+
- !binary |-
|
41
|
+
QWNjZXB0LUVuY29kaW5n
|
42
|
+
!binary "U3RhdHVz":
|
43
|
+
- !binary |-
|
44
|
+
MjAwIE9L
|
45
|
+
!binary "WC1VYS1Db21wYXRpYmxl":
|
46
|
+
- !binary |-
|
47
|
+
SUU9RWRnZSxjaHJvbWU9MQ==
|
48
|
+
!binary "RXRhZw==":
|
49
|
+
- !binary |-
|
50
|
+
IjEzZDZmMDY3NTY3NzM5ODczZmM0OGEzOGE0MzcyNDBiIg==
|
51
|
+
!binary "Q2FjaGUtQ29udHJvbA==":
|
52
|
+
- !binary |-
|
53
|
+
bWF4LWFnZT0wLCBwcml2YXRlLCBtdXN0LXJldmFsaWRhdGU=
|
54
|
+
!binary "WC1SZXF1ZXN0LUlk":
|
55
|
+
- !binary |-
|
56
|
+
OTliNDhlNjQ5MDRiYjY4MGRjYjIzYmFhNjAyYTc4YTU=
|
57
|
+
!binary "WC1SdW50aW1l":
|
58
|
+
- !binary |-
|
59
|
+
MC4wNjc4OTc=
|
60
|
+
!binary "WC1SYWNrLUNhY2hl":
|
61
|
+
- !binary |-
|
62
|
+
bWlzcw==
|
63
|
+
!binary "Q29udGVudC1FbmNvZGluZw==":
|
64
|
+
- !binary |-
|
65
|
+
Z3ppcA==
|
66
|
+
body:
|
67
|
+
encoding: ASCII-8BIT
|
68
|
+
string: !binary |-
|
69
|
+
H4sIAAAAAAAAA4uuVkrNTczMUbJSSktMyszXK0gtKkrNyUnULs0rLk0qTi7K
|
70
|
+
TEp1SAcp0UvOz1XSUcosAKo1tDDTMzIy0DM0AGJLoGhicnJqcXF8YglI0ljX
|
71
|
+
wFDX0ELB0NTK0MLK1EipVocO1ljgsYYSoy2tDIA+iAUAQ2dq3CoBAAA=
|
72
|
+
http_version:
|
73
|
+
recorded_at: Fri, 18 Jan 2013 17:31:03 GMT
|
74
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,75 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://emailmarketing.locaweb.com.br/api/v1/accounts/50f8e28abf8d79f935000001/messages/50f9828436e1d9ce0d000fd5/overview
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Auth-Token:
|
15
|
+
- Nt5skc1xXsvKKSsyp3Bsx7ABNdJz9pc1uA9kyTdjnJkr
|
16
|
+
User-Agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: !binary |-
|
22
|
+
T0s=
|
23
|
+
headers:
|
24
|
+
!binary "U2VydmVy":
|
25
|
+
- !binary |-
|
26
|
+
bmdpbngvMS4xLjI=
|
27
|
+
!binary "RGF0ZQ==":
|
28
|
+
- !binary |-
|
29
|
+
RnJpLCAxOCBKYW4gMjAxMyAxNzozMTowMyBHTVQ=
|
30
|
+
!binary "Q29udGVudC1UeXBl":
|
31
|
+
- !binary |-
|
32
|
+
YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
|
33
|
+
!binary "VHJhbnNmZXItRW5jb2Rpbmc=":
|
34
|
+
- !binary |-
|
35
|
+
Y2h1bmtlZA==
|
36
|
+
!binary "Q29ubmVjdGlvbg==":
|
37
|
+
- !binary |-
|
38
|
+
a2VlcC1hbGl2ZQ==
|
39
|
+
!binary "VmFyeQ==":
|
40
|
+
- !binary |-
|
41
|
+
QWNjZXB0LUVuY29kaW5n
|
42
|
+
!binary "U3RhdHVz":
|
43
|
+
- !binary |-
|
44
|
+
MjAwIE9L
|
45
|
+
!binary "WC1VYS1Db21wYXRpYmxl":
|
46
|
+
- !binary |-
|
47
|
+
SUU9RWRnZSxjaHJvbWU9MQ==
|
48
|
+
!binary "RXRhZw==":
|
49
|
+
- !binary |-
|
50
|
+
ImE1NDMxYWFkYTdkY2Q3NzA4ODE5ZWZiMTczNTcyZmVmIg==
|
51
|
+
!binary "Q2FjaGUtQ29udHJvbA==":
|
52
|
+
- !binary |-
|
53
|
+
bWF4LWFnZT0wLCBwcml2YXRlLCBtdXN0LXJldmFsaWRhdGU=
|
54
|
+
!binary "WC1SZXF1ZXN0LUlk":
|
55
|
+
- !binary |-
|
56
|
+
YmQ0YTZiMGI5OTJhMDM1OGQyMGNmMDQyODI2ZWQ5OWU=
|
57
|
+
!binary "WC1SdW50aW1l":
|
58
|
+
- !binary |-
|
59
|
+
MC4wNzQ3ODY=
|
60
|
+
!binary "WC1SYWNrLUNhY2hl":
|
61
|
+
- !binary |-
|
62
|
+
bWlzcw==
|
63
|
+
!binary "Q29udGVudC1FbmNvZGluZw==":
|
64
|
+
- !binary |-
|
65
|
+
Z3ppcA==
|
66
|
+
body:
|
67
|
+
encoding: ASCII-8BIT
|
68
|
+
string: !binary |-
|
69
|
+
H4sIAAAAAAAAA0XMMQ7CMAwF0Ksgzx3SlqKWnXMgx3aRRXFKk3RB3J1ABjb7
|
70
|
+
/W+/QBnOMLh5Grvx2J+k5YnEsXNu5gEaMHxIaSSJSQ64aqGYMOVY8GK7ImMh
|
71
|
+
CpaQUsG+AZZFd9lU6upDNvrObQNhFVO71SCbPq9/6cqbRelem9li9pE29b/T
|
72
|
+
9wfnxESFqgAAAA==
|
73
|
+
http_version:
|
74
|
+
recorded_at: Fri, 18 Jan 2013 17:31:03 GMT
|
75
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://emailmarketing.locaweb.com.br/api/v1/accounts/50f8e28abf8d79f935000001/messages/50f9828436e1d9ce0d000fd5/uniq_openings
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Auth-Token:
|
15
|
+
- Nt5skc1xXsvKKSsyp3Bsx7ABNdJz9pc1uA9kyTdjnJkr
|
16
|
+
User-Agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: !binary |-
|
22
|
+
T0s=
|
23
|
+
headers:
|
24
|
+
!binary "U2VydmVy":
|
25
|
+
- !binary |-
|
26
|
+
bmdpbngvMS4xLjI=
|
27
|
+
!binary "RGF0ZQ==":
|
28
|
+
- !binary |-
|
29
|
+
RnJpLCAxOCBKYW4gMjAxMyAxNzozNjo1NiBHTVQ=
|
30
|
+
!binary "Q29udGVudC1UeXBl":
|
31
|
+
- !binary |-
|
32
|
+
YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
|
33
|
+
!binary "VHJhbnNmZXItRW5jb2Rpbmc=":
|
34
|
+
- !binary |-
|
35
|
+
Y2h1bmtlZA==
|
36
|
+
!binary "Q29ubmVjdGlvbg==":
|
37
|
+
- !binary |-
|
38
|
+
a2VlcC1hbGl2ZQ==
|
39
|
+
!binary "VmFyeQ==":
|
40
|
+
- !binary |-
|
41
|
+
QWNjZXB0LUVuY29kaW5n
|
42
|
+
!binary "U3RhdHVz":
|
43
|
+
- !binary |-
|
44
|
+
MjAwIE9L
|
45
|
+
!binary "WC1VYS1Db21wYXRpYmxl":
|
46
|
+
- !binary |-
|
47
|
+
SUU9RWRnZSxjaHJvbWU9MQ==
|
48
|
+
!binary "RXRhZw==":
|
49
|
+
- !binary |-
|
50
|
+
IjRkOGQyOWRlN2E3NDEwZWU4MmI0NGFmMWY4Y2M3MTMxIg==
|
51
|
+
!binary "Q2FjaGUtQ29udHJvbA==":
|
52
|
+
- !binary |-
|
53
|
+
bWF4LWFnZT0wLCBwcml2YXRlLCBtdXN0LXJldmFsaWRhdGU=
|
54
|
+
!binary "WC1SZXF1ZXN0LUlk":
|
55
|
+
- !binary |-
|
56
|
+
NzlkZGZiNmJjOWZiZDMzMGFlZTgxZGI5NzhjOTY1ZjE=
|
57
|
+
!binary "WC1SdW50aW1l":
|
58
|
+
- !binary |-
|
59
|
+
MC4wMzA2MjY=
|
60
|
+
!binary "WC1SYWNrLUNhY2hl":
|
61
|
+
- !binary |-
|
62
|
+
bWlzcw==
|
63
|
+
!binary "Q29udGVudC1FbmNvZGluZw==":
|
64
|
+
- !binary |-
|
65
|
+
Z3ppcA==
|
66
|
+
body:
|
67
|
+
encoding: ASCII-8BIT
|
68
|
+
string: !binary |-
|
69
|
+
H4sIAAAAAAAAA4uuVkrNTczMUbJSSktMyszXK0gtKkrNyUnULs0rLk0qTi7K
|
70
|
+
TEp1SAcp0UvOz1XSUcosAKo1tDDTMzIy0DM0AGJLoGhicnJqcXF8YglI0ljX
|
71
|
+
wFDX0ELB0NTK0MLK1EipVgeXNZQYbWllADQ6FgC3MW2IwwAAAA==
|
72
|
+
http_version:
|
73
|
+
recorded_at: Fri, 18 Jan 2013 17:36:56 GMT
|
74
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include Locaweb::Emailmarketing
|
4
|
+
|
5
|
+
describe Locaweb::Emailmarketing::HttpRequestAdapter do
|
6
|
+
let(:subject) { HttpRequestAdapter.new(auth_token: AUTH_TOKEN, base_url: BASE_URL) }
|
7
|
+
|
8
|
+
describe ".initialize" do
|
9
|
+
context "when valid options" do
|
10
|
+
it "does not raise exception" do
|
11
|
+
http = HttpRequestAdapter.new(auth_token: 'aa', base_url: 'http://lalapoop.com')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when invalid options" do
|
16
|
+
it "raises argument error exception" do
|
17
|
+
lambda { http = HttpRequestAdapter.new(lala: 'aa') }.should raise_exception ArgumentError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".get" do
|
23
|
+
it "calls restclient GET with correct options" do
|
24
|
+
RestClient.should_receive(:get).with("#{BASE_URL}/aaa", "X-Auth-Token" => AUTH_TOKEN, accept: :json).and_return "{}"
|
25
|
+
subject.get "aaa"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns JSON of http response body" do
|
29
|
+
RestClient.stub(:get).and_return %q|{"aaaa":"123"}|
|
30
|
+
subject.get("aaa").should == {"aaaa" => "123"}
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when not found" do
|
34
|
+
it "returns nil" do
|
35
|
+
RestClient.stub(:get).and_raise RestClient::ResourceNotFound.new
|
36
|
+
subject.get("aaa").should be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".put" do
|
42
|
+
it "calls restclient PUT with correct options" do
|
43
|
+
attributes = {aa: 1}
|
44
|
+
RestClient.should_receive(:put).with("#{BASE_URL}/aaa", attributes.to_json, "X-Auth-Token" => AUTH_TOKEN, content_type: :json).and_return "{}"
|
45
|
+
subject.put "aaa", attributes
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".post" do
|
50
|
+
it "calls restclient POST with correct options" do
|
51
|
+
attributes = {aa: 1}
|
52
|
+
RestClient.should_receive(:post).with("#{BASE_URL}/aaa", attributes.to_json, "X-Auth-Token" => AUTH_TOKEN, content_type: :json).and_return "{}"
|
53
|
+
subject.post "aaa", attributes
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe ".delete" do
|
58
|
+
it "calls restclient DELETE with correct options" do
|
59
|
+
RestClient.should_receive(:delete).with("#{BASE_URL}/aaa", "X-Auth-Token" => AUTH_TOKEN, accept: :json).and_return "{}"
|
60
|
+
subject.delete "aaa"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
# include Locaweb::Emailmarketing
|
3
|
+
|
4
|
+
describe Locaweb::Emailmarketing::Client do
|
5
|
+
describe ".accounts" do
|
6
|
+
let(:client) { Client.new auth_token: "apikey", base_url: 'http://lalapopo', account_id: TRIAL_ACCOUNT_ID }
|
7
|
+
|
8
|
+
it "calls account method name" do
|
9
|
+
account_client_mock = mock 'AccountClient'
|
10
|
+
AccountClient.stub(:new).and_return account_client_mock
|
11
|
+
client.accounts.should == account_client_mock
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Locaweb::Emailmarketing
|
3
|
+
|
4
|
+
describe Locaweb::Emailmarketing::AccountClient do
|
5
|
+
let(:client) { Client.new auth_token: AUTH_TOKEN, base_url: BASE_URL, account_id: TRIAL_ACCOUNT_ID }
|
6
|
+
|
7
|
+
describe ".all" do
|
8
|
+
it "returns all accounts" do
|
9
|
+
VCR.use_cassette('accounts_all') do
|
10
|
+
client.accounts.all.should == { "items" =>
|
11
|
+
[
|
12
|
+
{"id"=> TRIAL_ACCOUNT_ID , "display_name"=>"trial", "plan_name"=>"Trial"}
|
13
|
+
],
|
14
|
+
"page" => {"current"=>1, "total"=>1} }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".get" do
|
20
|
+
it "returns the given account" do
|
21
|
+
VCR.use_cassette('accounts_get') do
|
22
|
+
client.accounts.get(TRIAL_ACCOUNT_ID).should include({
|
23
|
+
"id"=> TRIAL_ACCOUNT_ID , "display_name"=>"trial", "plan_name"=>"Trial"
|
24
|
+
})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".update" do
|
30
|
+
it "updates given account" do
|
31
|
+
VCR.use_cassette('accounts_update') do
|
32
|
+
client.accounts.update(TRIAL_ACCOUNT_ID, return_path_domain: 'trial3.newssender.com.br')
|
33
|
+
client.accounts.get(TRIAL_ACCOUNT_ID).should include({"return_path_domain" => 'trial3.newssender.com.br'})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# I choosed one resource (custom_fields) to test base client completely using VCR.
|
2
|
+
# To the other inherited clients, I tested using shared example base client
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
include Locaweb::Emailmarketing
|
6
|
+
|
7
|
+
describe Locaweb::Emailmarketing::CustomFieldClient do
|
8
|
+
let(:client) { Client.new auth_token: AUTH_TOKEN, base_url: BASE_URL, account_id: TRIAL_ACCOUNT_ID }
|
9
|
+
|
10
|
+
describe ".all" do
|
11
|
+
it "returns all custom_fields" do
|
12
|
+
VCR.use_cassette('custom_field_all') do
|
13
|
+
client.custom_fields.create(name: "Cidadee", type: "string")
|
14
|
+
client.custom_fields.all["items"].find{|c| c["name"] == "Cidadee"}.should include("name"=>"Cidadee", "type"=>"string")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when passing page param" do
|
19
|
+
it "returns page required" do
|
20
|
+
HttpRequestAdapter.any_instance.should_receive(:get).with(/page=2/)
|
21
|
+
client.custom_fields.all(2)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".get" do
|
27
|
+
it "returns a custom_field" do
|
28
|
+
VCR.use_cassette('custom_field_get') do
|
29
|
+
custom_field_id = client.custom_fields.all["items"].find{|c| c["name"] == "Cidade"}["id"]
|
30
|
+
client.custom_fields.get(custom_field_id).should include("name"=>"Cidade", "type"=>"string")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".create" do
|
36
|
+
it "creates a custom_field and return custom_field_id" do
|
37
|
+
VCR.use_cassette('custom_field_create') do
|
38
|
+
if custom_field = client.custom_fields.all["items"].find{|c| c["name"] == "codigo"}
|
39
|
+
client.custom_fields.destroy custom_field["id"]
|
40
|
+
end
|
41
|
+
custom_field_id = client.custom_fields.create(name: "codigo", type: "number")
|
42
|
+
client.custom_fields.get(custom_field_id).should include({"id"=>custom_field_id, "name"=>"codigo", "type"=>"number"})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".update" do
|
48
|
+
it "updates a custom_field" do
|
49
|
+
VCR.use_cassette('custom_field_update') do
|
50
|
+
custom_fields = client.custom_fields.all["items"]
|
51
|
+
if custom_field = custom_fields.find{|c| c["name"] == "city"}
|
52
|
+
client.custom_fields.destroy custom_field["id"]
|
53
|
+
end
|
54
|
+
|
55
|
+
custom_field = client.custom_fields.all["items"].find{|c| c["name"] == "Cidade"}
|
56
|
+
custom_field_id = if custom_field
|
57
|
+
custom_field["id"]
|
58
|
+
else
|
59
|
+
client.custom_fields.create(name: "Cidade", type: "string")
|
60
|
+
end
|
61
|
+
|
62
|
+
client.custom_fields.update(custom_field_id, name: "city")
|
63
|
+
client.custom_fields.get(custom_field_id)["name"].should == "city"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe ".destroy" do
|
69
|
+
it "destroys a custom_field" do
|
70
|
+
VCR.use_cassette('custom_field_destroy') do
|
71
|
+
custom_field_id = client.custom_fields.create(name: "lalapopo", type: "number")
|
72
|
+
client.custom_fields.destroy(custom_field_id)
|
73
|
+
client.custom_fields.get(custom_field_id).should be_nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include Locaweb::Emailmarketing
|
4
|
+
|
5
|
+
describe Locaweb::Emailmarketing::CampaignClient do
|
6
|
+
it_should_behave_like "a base client", "campaigns" do
|
7
|
+
let(:requires_keys_to_create) { [:name] }
|
8
|
+
let(:requires_keys_to_update) { [:name] }
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include Locaweb::Emailmarketing
|
4
|
+
|
5
|
+
describe Locaweb::Emailmarketing::ContactClient do
|
6
|
+
it_should_behave_like "a base client", "contacts" do
|
7
|
+
let(:requires_keys_to_create) { [:email, :list_ids] }
|
8
|
+
let(:requires_keys_to_update) { [] }
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include Locaweb::Emailmarketing
|
4
|
+
|
5
|
+
describe Locaweb::Emailmarketing::ContactImportClient do
|
6
|
+
it_should_behave_like "a base client", "contact_imports", [:update, :destroy] do
|
7
|
+
let(:requires_keys_to_create) { [:name, :list_tokens, :url] }
|
8
|
+
end
|
9
|
+
end
|