revere_mobile 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.
- checksums.yaml +7 -0
- data/README.md +98 -0
- data/bin/console +8 -0
- data/lib/revere_mobile/client/authentication.rb +28 -0
- data/lib/revere_mobile/client/campaign.rb +19 -0
- data/lib/revere_mobile/client/mobile_flow.rb +11 -0
- data/lib/revere_mobile/client/shortcode.rb +11 -0
- data/lib/revere_mobile/client.rb +29 -0
- data/lib/revere_mobile/configuration.rb +107 -0
- data/lib/revere_mobile/connection.rb +30 -0
- data/lib/revere_mobile/default.rb +45 -0
- data/lib/revere_mobile/error.rb +121 -0
- data/lib/revere_mobile/request.rb +39 -0
- data/lib/revere_mobile/response/raise_error.rb +18 -0
- data/lib/revere_mobile/response.rb +13 -0
- data/lib/revere_mobile/version.rb +5 -0
- data/lib/revere_mobile.rb +51 -0
- data/spec/revere_mobile/client/campaign_spec.rb +105 -0
- data/spec/revere_mobile/client/mobile_flow_spec.rb +51 -0
- data/spec/revere_mobile/client/shortcode_spec.rb +49 -0
- data/spec/revere_mobile/client_spec.rb +36 -0
- data/spec/revere_mobile/configuration_spec.rb +140 -0
- data/spec/revere_mobile/errors_spec.rb +84 -0
- data/spec/revere_mobile/request_spec.rb +125 -0
- data/spec/revere_mobile/revere_mobile_spec.rb +21 -0
- data/spec/revere_mobile/support/fixtures/campaigns/create_campaign.json +11 -0
- data/spec/revere_mobile/support/fixtures/campaigns/get_all_campaigns.json +49 -0
- data/spec/revere_mobile/support/fixtures/mobile_flows/get_all_mobile_flows.json +39 -0
- data/spec/revere_mobile/support/fixtures/shortcodes/get_all_shortcodes.json +34 -0
- data/spec/revere_mobile/support/path_helpers.rb +9 -0
- data/spec/revere_mobile/support/url_helpers.rb +5 -0
- data/spec/revere_mobile/support/webmock.rb +5 -0
- data/spec/spec_helper.rb +23 -0
- metadata +257 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
class Client
|
7
|
+
RSpec.describe Campaign do
|
8
|
+
let(:client) { RevereMobile::Client.new }
|
9
|
+
|
10
|
+
describe '#campaigns' do
|
11
|
+
let(:params) { Hash.new }
|
12
|
+
let(:response) { fixture('campaigns/get_all_campaigns.json') }
|
13
|
+
let(:url) { build_url(client: client, path: 'campaign') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
stub_request(:get, url)
|
17
|
+
.with(query: params)
|
18
|
+
.to_return(
|
19
|
+
body: response
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'requests the correct resource' do
|
24
|
+
client.campaigns(params: params)
|
25
|
+
expect(
|
26
|
+
a_request(:get, url)
|
27
|
+
.with(query: params)
|
28
|
+
).to have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns the campaigns' do
|
32
|
+
campaigns = client.campaigns(
|
33
|
+
params: params)
|
34
|
+
expect(campaigns['collection']).to be_a(Array)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns the campaigns with details' do
|
38
|
+
campaigns = client.campaigns(
|
39
|
+
params: params)
|
40
|
+
campaign = campaigns['collection'].first
|
41
|
+
expect(campaign['id']).not_to be_empty
|
42
|
+
expect(campaign['account']).not_to be_empty
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#create_campaign' do
|
47
|
+
let(:params) { Hash.new name: 'Test Campaign' }
|
48
|
+
let(:response) { fixture('campaigns/create_campaign.json') }
|
49
|
+
let(:url) { build_url(client: client, path: 'campaign') }
|
50
|
+
|
51
|
+
before do
|
52
|
+
stub_request(:post, url)
|
53
|
+
.with(body: params)
|
54
|
+
.to_return(
|
55
|
+
body: response
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'requests the correct resource' do
|
60
|
+
client.create_campaign(params)
|
61
|
+
expect(
|
62
|
+
a_request(:post, url)
|
63
|
+
.with(body: params)
|
64
|
+
).to have_been_made
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns the created campaign' do
|
68
|
+
campaign = client.create_campaign(params)
|
69
|
+
expect(campaign['id']).not_to be_empty
|
70
|
+
expect(campaign['name']).to eq('Test Campaign')
|
71
|
+
expect(campaign['startDate']).not_to be_empty
|
72
|
+
expect(campaign['mobileFlows']).to be_a(Array)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
describe '#update_campaign' do
|
76
|
+
let(:params) { { id: '5493568f0cb2fcad2e35ecb5', name: 'Test Campaign' } }
|
77
|
+
let(:url) { build_url(client: client, path: 'campaign/5493568f0cb2fcad2e35ecb5') }
|
78
|
+
|
79
|
+
before do
|
80
|
+
stub_request(:put, url)
|
81
|
+
.with(body: params)
|
82
|
+
.to_return(
|
83
|
+
status: 204
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'requests the correct resource' do
|
88
|
+
client.update_campaign(params)
|
89
|
+
expect(
|
90
|
+
a_request(:put, url)
|
91
|
+
.with(body: params)
|
92
|
+
).to have_been_made
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'returns with with an empty string' do
|
96
|
+
# Revere Mobile comes back with No Content here
|
97
|
+
response = client.update_campaign(params)
|
98
|
+
expect(
|
99
|
+
response
|
100
|
+
).to eq('')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
class Client
|
7
|
+
RSpec.describe MobileFlow do
|
8
|
+
let(:client) { RevereMobile::Client.new }
|
9
|
+
|
10
|
+
describe "#mobileflows" do
|
11
|
+
let(:params) { Hash.new }
|
12
|
+
let(:response) { fixture('mobile_flows/get_all_mobile_flows.json') }
|
13
|
+
let(:url) { build_url(client: client, path: 'mobileflow') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
stub_request(:get, url)
|
17
|
+
.with(query: params)
|
18
|
+
.to_return(
|
19
|
+
body: response
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'requests the correct resource' do
|
24
|
+
client.mobileflows(params: params)
|
25
|
+
expect(
|
26
|
+
a_request(:get, url)
|
27
|
+
.with(query: params)
|
28
|
+
).to have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns the mobileflows' do
|
32
|
+
mobileflows = client.mobileflows(
|
33
|
+
params: params)
|
34
|
+
expect(mobileflows['collection']).to be_a(Array)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns the mobileflows with details' do
|
38
|
+
mobileflows = client.mobileflows(
|
39
|
+
params: params)
|
40
|
+
mobileflow = mobileflows['collection'].first
|
41
|
+
expect(mobileflow['id']).not_to be_empty
|
42
|
+
expect(mobileflow['campaign']).not_to be_empty
|
43
|
+
expect(mobileflow['shortCode']).not_to be_empty
|
44
|
+
expect(mobileflow['name']).not_to be_empty
|
45
|
+
expect(mobileflow['lists']).not_to be_empty
|
46
|
+
expect(mobileflow['lists']).to be_a(Array)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
class Client
|
7
|
+
RSpec.describe Shortcode do
|
8
|
+
let(:client) { RevereMobile::Client.new }
|
9
|
+
|
10
|
+
describe "#shortcodes" do
|
11
|
+
let(:params) { Hash.new }
|
12
|
+
let(:response) { fixture('shortcodes/get_all_shortcodes.json') }
|
13
|
+
let(:url) { build_url(client: client, path: 'shortcode') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
stub_request(:get, url)
|
17
|
+
.with(query: params)
|
18
|
+
.to_return(
|
19
|
+
body: response
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'requests the correct resource' do
|
24
|
+
client.shortcodes(params: params)
|
25
|
+
expect(
|
26
|
+
a_request(:get, url)
|
27
|
+
.with(query: params)
|
28
|
+
).to have_been_made
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns the shortcodes' do
|
32
|
+
shortcodes = client.shortcodes(
|
33
|
+
params: params)
|
34
|
+
expect(shortcodes['collection']).to be_a(Array)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns the shortcodes with details' do
|
38
|
+
shortcodes = client.shortcodes(
|
39
|
+
params: params)
|
40
|
+
shortcode = shortcodes['collection'].first
|
41
|
+
expect(shortcode['id']).not_to be_empty
|
42
|
+
expect(shortcode['country']).not_to be_empty
|
43
|
+
expect(shortcode['status']).not_to be_empty
|
44
|
+
expect(shortcode['shortcode']).not_to be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
RSpec.describe Client do
|
7
|
+
describe 'initialization' do
|
8
|
+
describe 'with a specified configuration' do
|
9
|
+
let(:config) { RevereMobile::Configuration.new }
|
10
|
+
|
11
|
+
subject { RevereMobile::Client.new(config) }
|
12
|
+
|
13
|
+
it 'should accept and store as config' do
|
14
|
+
expect(subject.config).to eq(config)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'without a specified configuration' do
|
19
|
+
it 'should get the default' do
|
20
|
+
expect(subject.config).to eq(RevereMobile.configuration)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'useage' do
|
26
|
+
it 'should be possible to a config and use it with the client' do
|
27
|
+
configuration = RevereMobile::Configuration.new
|
28
|
+
configuration.user_agent = 'Test Agent'
|
29
|
+
configuration.username = 'Test Username'
|
30
|
+
client = RevereMobile::Client.new(configuration)
|
31
|
+
expect(client.config.user_agent).to eq('Test Agent')
|
32
|
+
expect(client.config.username).to eq('Test Username')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
RSpec.describe Configuration do
|
7
|
+
before(:each) { RevereMobile.configuration.reset! }
|
8
|
+
after(:each) { RevereMobile.configuration.reset! }
|
9
|
+
|
10
|
+
describe '#api_endpoint' do
|
11
|
+
context 'when no api_endpoint is specified' do
|
12
|
+
it 'sets a default value' do
|
13
|
+
expect(RevereMobile.configuration.api_endpoint)
|
14
|
+
.to eq(RevereMobile::Default.api_endpoint)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when a custom value is supplied' do
|
19
|
+
let(:url) { Faker::Internet.url }
|
20
|
+
|
21
|
+
before do
|
22
|
+
RevereMobile.configure do |config|
|
23
|
+
config.api_endpoint = url
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns the custom value' do
|
28
|
+
expect(RevereMobile.configuration.api_endpoint).to eq(url)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#username' do
|
34
|
+
context 'when no username is specified' do
|
35
|
+
it 'sets a default value' do
|
36
|
+
expect(RevereMobile.configuration.username)
|
37
|
+
.to eq(RevereMobile::Default.username)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when a custom value is supplied' do
|
42
|
+
let(:username) { Faker::Internet.username }
|
43
|
+
|
44
|
+
before do
|
45
|
+
RevereMobile.configure do |config|
|
46
|
+
config.username = username
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns the custom value' do
|
51
|
+
expect(RevereMobile.configuration.username).to eq(username)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#user_agent' do
|
57
|
+
context 'when no user_agent is specified' do
|
58
|
+
it 'sets a default value' do
|
59
|
+
expect(RevereMobile.configuration.user_agent)
|
60
|
+
.to eq(RevereMobile::Default.user_agent)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when a custom value is supplied' do
|
65
|
+
let(:user_agent) { Faker::Internet.user_agent }
|
66
|
+
|
67
|
+
before do
|
68
|
+
RevereMobile.configure do |config|
|
69
|
+
config.user_agent = user_agent
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns the custom value' do
|
74
|
+
expect(RevereMobile.configuration.user_agent).to eq(user_agent)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#shortcode_id' do
|
80
|
+
context 'when no shortcode_id is specified' do
|
81
|
+
it 'sets a default value' do
|
82
|
+
expect(RevereMobile.configuration.shortcode_id)
|
83
|
+
.to eq(RevereMobile::Default.shortcode_id)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when a custom value is supplied' do
|
88
|
+
let(:shortcode_id) { Faker::Crypto.md5 }
|
89
|
+
|
90
|
+
before do
|
91
|
+
RevereMobile.configure do |config|
|
92
|
+
config.shortcode_id = shortcode_id
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'returns the custom value' do
|
97
|
+
expect(RevereMobile.configuration.shortcode_id).to eq(shortcode_id)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#query_size" do
|
103
|
+
context 'when no query_size is specified' do
|
104
|
+
it 'sets a default value' do
|
105
|
+
expect(RevereMobile.configuration.query_size)
|
106
|
+
.to eq(RevereMobile::Default.query_size)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when a custom value is supplied' do
|
111
|
+
let(:query_size) { Faker::Number.between(1, 10) }
|
112
|
+
|
113
|
+
before do
|
114
|
+
RevereMobile.configure do |config|
|
115
|
+
config.query_size = query_size
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'returns the custom value' do
|
120
|
+
expect(RevereMobile.configuration.query_size).to eq(query_size)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
describe '#inspect' do
|
127
|
+
it 'masks the password' do
|
128
|
+
password = Faker::Internet.password
|
129
|
+
RevereMobile.configuration.password = password
|
130
|
+
expect(RevereMobile.configuration.inspect).to_not include(password)
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'masks the api_key' do
|
134
|
+
api_key = Faker::Internet.password
|
135
|
+
RevereMobile.configuration.api_key = api_key
|
136
|
+
expect(RevereMobile.configuration.inspect).to_not include(api_key)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
RSpec.describe RevereMobile::Error do
|
7
|
+
let(:client) { RevereMobile::Client.new }
|
8
|
+
|
9
|
+
context 'when a resource is not found' do
|
10
|
+
let(:url) { build_url(client: client, path: '/nowhere') }
|
11
|
+
|
12
|
+
before do
|
13
|
+
stub_request(:get, url)
|
14
|
+
.to_return(status: 404)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'rasies the RevereMobile::NotFound' do
|
18
|
+
expect {
|
19
|
+
client.get(path: '/nowhere')
|
20
|
+
}.to raise_error(RevereMobile::NotFound)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when a bad request is made' do
|
25
|
+
let(:url) { build_url(client: client, path: '/badrequest') }
|
26
|
+
|
27
|
+
before do
|
28
|
+
stub_request(:get, url)
|
29
|
+
.to_return(status: 400)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'rasies the RevereMobile::BadRequest' do
|
33
|
+
expect {
|
34
|
+
client.get(path: '/badrequest')
|
35
|
+
}.to raise_error(RevereMobile::BadRequest)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when an unkown bad request is made' do
|
40
|
+
let(:url) { build_url(client: client, path: '/badrequest') }
|
41
|
+
|
42
|
+
before do
|
43
|
+
stub_request(:get, url)
|
44
|
+
.to_return(status: 455)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'rasies the RevereMobile::ClientError' do
|
48
|
+
expect {
|
49
|
+
client.get(path: '/badrequest')
|
50
|
+
}.to raise_error(RevereMobile::ClientError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when a server error ocurs' do
|
55
|
+
let(:url) { build_url(client: client, path: '/serverError') }
|
56
|
+
|
57
|
+
before do
|
58
|
+
stub_request(:get, url)
|
59
|
+
.to_return(status: 500)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'rasies the RevereMobile::InternalServerError' do
|
63
|
+
expect {
|
64
|
+
client.get(path: '/serverError')
|
65
|
+
}.to raise_error(RevereMobile::InternalServerError)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when an unknown server error ocurs' do
|
70
|
+
let(:url) { build_url(client: client, path: '/serverError') }
|
71
|
+
|
72
|
+
before do
|
73
|
+
stub_request(:get, url)
|
74
|
+
.to_return(status: 555)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'rasies the RevereMobile::ServerError' do
|
78
|
+
expect {
|
79
|
+
client.get(path: '/serverError')
|
80
|
+
}.to raise_error(RevereMobile::ServerError)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module RevereMobile
|
6
|
+
RSpec.describe Request do
|
7
|
+
let(:client) { RevereMobile::Client.new }
|
8
|
+
let(:params) { { id: 1 } }
|
9
|
+
|
10
|
+
describe '#get' do
|
11
|
+
let(:url) { build_url(client: client, path: '/mobile/resource') }
|
12
|
+
|
13
|
+
context 'when making a request' do
|
14
|
+
before do
|
15
|
+
stub_request(:get, url)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'makes a get request' do
|
19
|
+
RevereMobile.get(path:'/mobile/resource')
|
20
|
+
expect(a_request(:get, url)).to have_been_made
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when passing parameters to the request' do
|
25
|
+
before do
|
26
|
+
stub_request(:get, url).with(query: params)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'passes params with the request' do
|
30
|
+
RevereMobile.get(path: '/mobile/resource', params: params)
|
31
|
+
expect(a_request(:get, url).with(query: params)).to have_been_made
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#post' do
|
37
|
+
let(:url) { build_url(client: client, path: '/some/resource') }
|
38
|
+
let(:body) do
|
39
|
+
{
|
40
|
+
username: 'Test Username',
|
41
|
+
password: 'Test Password',
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when making a request' do
|
46
|
+
before do
|
47
|
+
stub_request(:post, url)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'makes a post request' do
|
51
|
+
RevereMobile.post(path: '/some/resource')
|
52
|
+
expect(a_request(:post, url)).to have_been_made
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when passing a body to the request' do
|
57
|
+
before do
|
58
|
+
stub_request(:post, url).with(body: JSON.generate(body))
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'makes a post request with a body' do
|
62
|
+
RevereMobile.post(path: '/some/resource', body: body)
|
63
|
+
expect(a_request(:post, url).with(body: body)).to have_been_made
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#put' do
|
69
|
+
let(:url) { build_url(client: client, path: '/some/resource') }
|
70
|
+
let(:body) do
|
71
|
+
{
|
72
|
+
name: 'Test List'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when making a put request' do
|
77
|
+
before do
|
78
|
+
stub_request(:put, url)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'makes a put request' do
|
82
|
+
RevereMobile.put(path: '/some/resource')
|
83
|
+
expect(a_request(:put, url)).to have_been_made
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when making a put request with a body' do
|
88
|
+
before do
|
89
|
+
stub_request(:put, url).with(body: JSON.generate(body))
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'makes a put request with the body' do
|
93
|
+
RevereMobile.put(path: '/some/resource', body: body)
|
94
|
+
expect(a_request(:put, url).with(body: body)).to have_been_made
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context '#delete' do
|
100
|
+
let(:url) { build_url(client: client, path: '/mobile/resource') }
|
101
|
+
|
102
|
+
context 'when making a request' do
|
103
|
+
before do
|
104
|
+
stub_request(:delete, url)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'makes a get request' do
|
108
|
+
RevereMobile.delete(path:'/mobile/resource')
|
109
|
+
expect(a_request(:delete, url)).to have_been_made
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when passing parameters to the request' do
|
114
|
+
before do
|
115
|
+
stub_request(:delete, url).with(query: params)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'passes params with the request' do
|
119
|
+
RevereMobile.delete(path: '/mobile/resource', params: params)
|
120
|
+
expect(a_request(:delete, url).with(query: params)).to have_been_made
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "RevereMobile" do
|
4
|
+
it 'has a version number equal to 0.1.0' do
|
5
|
+
expect(RevereMobile::VERSION).to_not be nil
|
6
|
+
expect(RevereMobile::VERSION).to eq('0.1.0')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".client" do
|
10
|
+
it 'creates a new RevereMobile client' do
|
11
|
+
expect(RevereMobile.client).to be_instance_of(RevereMobile::Client)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when @client has been already assigned' do
|
15
|
+
it 'returns the @client' do
|
16
|
+
client = RevereMobile.client
|
17
|
+
expect(RevereMobile.client).to eq(client)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"account": "546239d10cf25fdcf0aea9b2",
|
3
|
+
"endDate": null,
|
4
|
+
"group": "54623a230cf25fdcf0zeaa5c",
|
5
|
+
"id": "5493568f0cb2fcad2e35ecb5",
|
6
|
+
"mobileFlows": [],
|
7
|
+
"name": "Test Campaign",
|
8
|
+
"shortCode": "515b0768cw10e4ec580fcc60",
|
9
|
+
"startDate": "Fri Jan 01 10:00:00 PDT 2018",
|
10
|
+
"status": "ACTIVE"
|
11
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"page": 1,
|
3
|
+
"size": -1,
|
4
|
+
"total": 3,
|
5
|
+
"collection": [
|
6
|
+
{
|
7
|
+
"id": "570e19afe4b0fddd97d6754f",
|
8
|
+
"account": "416fa6177a475eefd68fb5ef",
|
9
|
+
"group": "4e6fa6187a475eefd68fb5f4",
|
10
|
+
"shortCode": "4e8b4b5afda5efeeec370e8a",
|
11
|
+
"name": "Test Campaign",
|
12
|
+
"startDate": "Wed Apr 13 11:02:23 PDT 2016",
|
13
|
+
"endDate": "Wed Apr 13 11:02:23 PDT 2017",
|
14
|
+
"status": "ACTIVE",
|
15
|
+
"mobileFlows": []
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"id": "56ccdc90e4b087593e734bca",
|
19
|
+
"account": "4e6fa6177a475eefd68fb5ef",
|
20
|
+
"group": "56ccdbb9e4b087593e734b23",
|
21
|
+
"shortCode": "4e8b4b5afdn5efeeec370e8a",
|
22
|
+
"name": "Another Test Campaign",
|
23
|
+
"startDate": "Tue Feb 23 14:26:24 PST 2016",
|
24
|
+
"endDate": null,
|
25
|
+
"status": "ACTIVE",
|
26
|
+
"mobileFlows": [
|
27
|
+
"56ccdccfe4b0875932734bde",
|
28
|
+
"56e0ae7fe4b052c006b6374e",
|
29
|
+
"56e99881e4b024f1336a19d8",
|
30
|
+
"583c54cee4b0e8e03b886a2b"
|
31
|
+
]
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"id": "502520fd0cf236b8a154bf8b",
|
35
|
+
"account": "4e6fa61772475eefd68fb5ef",
|
36
|
+
"group": "50251a010cfr36b8a1545e98",
|
37
|
+
"shortCode": "4e8b1b5afda5efeeec370e8a",
|
38
|
+
"name": "Test Vote",
|
39
|
+
"startDate": "Fri Aug 10 07:55:57 PDT 2012",
|
40
|
+
"endDate": null,
|
41
|
+
"status": "ACTIVE",
|
42
|
+
"mobileFlows": [
|
43
|
+
"502525030cf236b8a154bfc2",
|
44
|
+
"509430b101f280bc6a98bff8",
|
45
|
+
"58c1accde4b0369e60c920fb"
|
46
|
+
]
|
47
|
+
}
|
48
|
+
]
|
49
|
+
}
|