marketing_api 0.0.1 → 0.0.2
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/README.md +7 -18
- data/Rakefile +1 -1
- data/marketing_api-0.0.1.gem +0 -0
- data/marketing_api.gemspec +18 -18
- data/spec/api_spec.rb +32 -11
- metadata +2 -1
data/README.md
CHANGED
@@ -3,16 +3,9 @@ marketing_api_gem
|
|
3
3
|
|
4
4
|
The gem is used as a remote API (using Net::HTTP) for the service called marketing (https://github.com/fess89/marketing).
|
5
5
|
|
6
|
-
Installation
|
7
|
-
|
8
|
-
|
9
|
-
mkdir marketing_api_gem
|
10
|
-
|
11
|
-
cd marketing_api_gem
|
12
|
-
|
13
|
-
git clone https://github.com/fess89/marketing_api_gem .
|
14
|
-
|
15
|
-
rake build
|
6
|
+
Installation for production
|
7
|
+
---------------------------
|
8
|
+
gem install marketing_api
|
16
9
|
|
17
10
|
Installation for testing
|
18
11
|
------------------------
|
@@ -22,19 +15,15 @@ cd marketing_api_gem
|
|
22
15
|
|
23
16
|
git clone https://github.com/fess89/marketing_api_gem .
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
rake dev (this doesn't work for me)
|
28
|
-
|
29
|
-
or
|
18
|
+
rake build
|
30
19
|
|
31
20
|
gem install rspec
|
32
21
|
|
33
22
|
gem install webmock
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
rake
|
24
|
+
Testing
|
25
|
+
-------
|
26
|
+
rake
|
38
27
|
|
39
28
|
|
40
29
|
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ task :build do
|
|
3
3
|
#getting gem info
|
4
4
|
gemspec = eval(File.read("marketing_api.gemspec"))
|
5
5
|
system "gem build marketing_api.gemspec"
|
6
|
-
|
6
|
+
system "gem install marketing_api-#{gemspec.version.to_s}.gem --no-ri --no-rdoc"
|
7
7
|
end
|
8
8
|
|
9
9
|
#installation for development purposes
|
Binary file
|
data/marketing_api.gemspec
CHANGED
@@ -2,29 +2,29 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
require 'marketing_api'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
s.name = 'marketing_api'
|
6
|
+
s.version = '0.0.2'
|
7
|
+
s.date = '2013-07-02'
|
8
|
+
s.summary = "Working with Marketing class by means of remote API"
|
9
|
+
s.description = "Test task given by Alexander Simonov"
|
10
|
+
s.authors = ["Oleksii Chyrkov"]
|
11
|
+
s.email = 'chyrkov@kth.se'
|
12
12
|
s.homepage = ""
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
s.license = "MIT"
|
20
|
+
s.platform = Gem::Platform::RUBY
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
#json is needed to interact with the remote API
|
23
|
+
s.add_runtime_dependency "json"
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
#rspec is only for testing
|
26
|
+
s.add_development_dependency "rspec", "~> 2.13.0"
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
#so is webmock
|
29
|
+
s.add_development_dependency "webmock"
|
30
30
|
end
|
data/spec/api_spec.rb
CHANGED
@@ -10,29 +10,35 @@ describe MarketingAPI, "#marketing_remote_api" do
|
|
10
10
|
|
11
11
|
success_reply =
|
12
12
|
{
|
13
|
-
"id"=>21, "email"=>"chyrkov@kth.se",
|
14
|
-
"mobile"=>"380632721593", "first_name"=>"Oleksii",
|
15
|
-
"last_name"=>"Chyrkov", "permission_type"=>"one-time",
|
16
|
-
"channel"=>"sms", "company_name"=>"Apple",
|
17
|
-
"message"=>"Found optin", "code"=>200
|
13
|
+
"id" => 21, "email" => "chyrkov@kth.se",
|
14
|
+
"mobile" => "380632721593", "first_name" => "Oleksii",
|
15
|
+
"last_name" => "Chyrkov", "permission_type" => "one-time",
|
16
|
+
"channel" => "sms", "company_name" => "Apple",
|
17
|
+
"message" => "Found optin", "code" => 200
|
18
18
|
}
|
19
19
|
|
20
20
|
not_found_reply =
|
21
21
|
{
|
22
|
-
"code"=> 404,
|
23
|
-
"message"=>"Optin not found"
|
22
|
+
"code" => 404,
|
23
|
+
"message" => "Optin not found"
|
24
24
|
}
|
25
25
|
|
26
26
|
bad_request_reply =
|
27
27
|
{
|
28
|
-
"code"=> 401,
|
29
|
-
"message"=>"Bad request"
|
28
|
+
"code" => 401,
|
29
|
+
"message" =>"Bad request"
|
30
30
|
}
|
31
31
|
|
32
32
|
already_exists_reply =
|
33
33
|
{
|
34
|
-
"code"=> 302,
|
35
|
-
"message"=>"Bad request"
|
34
|
+
"code" => 302,
|
35
|
+
"message" =>"Bad request"
|
36
|
+
}
|
37
|
+
|
38
|
+
internal_error_reply =
|
39
|
+
{
|
40
|
+
"code" => 503,
|
41
|
+
"message" => "Internal server error"
|
36
42
|
}
|
37
43
|
|
38
44
|
params =
|
@@ -181,4 +187,19 @@ describe MarketingAPI, "#marketing_remote_api" do
|
|
181
187
|
api.update_optin(params.to_json).should eq(nil)
|
182
188
|
end
|
183
189
|
|
190
|
+
it "should return nil when a create request returns 503 Internal Server Error" do
|
191
|
+
stub_request(:any, api.server+":80/create").to_return(:status => 503, :body => internal_error_reply)
|
192
|
+
api.create_optin(params.to_json).should eq(nil)
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should return nil when an update request returns 503 Internal Server Error" do
|
196
|
+
stub_request(:any, api.server+":80/update").to_return(:status => 503, :body => internal_error_reply)
|
197
|
+
api.update_optin(params.to_json).should eq(nil)
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should return nil when a deactivate request returns 503 Internal Server Error" do
|
201
|
+
stub_request(:any, api.server+":80/deactivate/#{params[:id]}").to_return(:status => 503, :body => internal_error_reply)
|
202
|
+
api.deactivate_optin(params[:id]).should eq(nil)
|
203
|
+
end
|
204
|
+
|
184
205
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marketing_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- Rakefile
|
73
73
|
- bin/marketing_api.rb
|
74
74
|
- lib/marketing_api.rb
|
75
|
+
- marketing_api-0.0.1.gem
|
75
76
|
- marketing_api.gemspec
|
76
77
|
- spec/api_spec.rb
|
77
78
|
- spec/spec_helper.rb
|