sklik-api 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sklik-api.rb +4 -0
- data/lib/sklik-api/connection.rb +3 -0
- data/lib/sklik-api/sklik_object.rb +0 -3
- data/sklik-api.gemspec +2 -2
- data/test/integration/campaign_test.rb +16 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/sklik-api.rb
CHANGED
data/lib/sklik-api/connection.rb
CHANGED
@@ -68,6 +68,9 @@ class SklikApi
|
|
68
68
|
SklikApi.log(:debug, "Response from api: #{param.inspect}") unless method == "client.login"
|
69
69
|
if [200].include?(param[:status])
|
70
70
|
return yield(param)
|
71
|
+
elsif param[:status] == 204 #Already removed
|
72
|
+
SklikApi.log(:info, "Trying to #{method} of #{args.inspect} but object is already in this status")
|
73
|
+
return true
|
71
74
|
elsif param[:status] == 400
|
72
75
|
raise SklikApi::InvalidArguments, "Calling method: #{method} with invalid arguments: #{args}, #{param.inspect}"
|
73
76
|
elsif param[:status] == 404
|
@@ -54,9 +54,6 @@ class SklikApi
|
|
54
54
|
begin
|
55
55
|
connection.call("#{self.class::NAME}.restore", @args["#{self.class.to_s.downcase.split(":").last}_id".to_sym] ) { |param| true }
|
56
56
|
rescue Exception => e
|
57
|
-
# if there is a problem but returned Not removed
|
58
|
-
# return true, becasue it says it is restored
|
59
|
-
return true if e.message == "Rescuing from request by: ArgumentError - There is error from sklik #{self.class.to_s.downcase}.restore: Not removed"
|
60
57
|
raise e
|
61
58
|
end
|
62
59
|
end
|
data/sklik-api.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "sklik-api"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ondrej Bartas"]
|
12
|
-
s.date = "2013-06-
|
12
|
+
s.date = "2013-06-26"
|
13
13
|
s.description = "Sklik advertising PPC api for creating campaigns and updating them when they runs"
|
14
14
|
s.email = "ondrej@bartas.cz"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -44,6 +44,22 @@ class CampaignIntegrationTest < Test::Unit::TestCase
|
|
44
44
|
assert_equal SklikApi::Campaign.get(campaign.args[:campaign_id]).args[:status], :stopped
|
45
45
|
end
|
46
46
|
|
47
|
+
should "remove and restore multiple times" do
|
48
|
+
campaign = SklikApi::Campaign.new(@only_campaign_hash)
|
49
|
+
assert campaign.save, "Problem with creating campaing: #{campaign.errors}"
|
50
|
+
assert_nothing_raised do
|
51
|
+
assert SklikApi::Campaign.get(campaign.args[:campaign_id]).remove, "Campaign should be removed"
|
52
|
+
assert_equal SklikApi::Campaign.get(campaign.args[:campaign_id]).args[:status], :stopped, "Campaign should have stopped status"
|
53
|
+
assert SklikApi::Campaign.get(campaign.args[:campaign_id]).remove, "Campaign should be removed second time without exception"
|
54
|
+
assert_equal SklikApi::Campaign.get(campaign.args[:campaign_id]).args[:status], :stopped, "Campaign should have stopped status for second time"
|
55
|
+
assert SklikApi::Campaign.get(campaign.args[:campaign_id]).restore, "Campaign should be restored"
|
56
|
+
assert_equal SklikApi::Campaign.get(campaign.args[:campaign_id]).args[:status], :running, "Campaign should have running status"
|
57
|
+
assert SklikApi::Campaign.get(campaign.args[:campaign_id]).restore, "Campaign should be restored second time without exception"
|
58
|
+
assert_equal SklikApi::Campaign.get(campaign.args[:campaign_id]).args[:status], :running, "Campaign should have running status for second time"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
47
63
|
should "find" do
|
48
64
|
assert_equal SklikApi::Campaign.find(@campaign.args[:campaign_id]).to_hash.to_a.sort, @only_campaign_hash.to_a.sort
|
49
65
|
assert_equal SklikApi::Campaign.find(campaign_id: @campaign.args[:campaign_id]).first.to_hash.to_a.sort, @only_campaign_hash.to_a.sort
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sklik-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -304,7 +304,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
304
304
|
version: '0'
|
305
305
|
segments:
|
306
306
|
- 0
|
307
|
-
hash:
|
307
|
+
hash: -67005859409429857
|
308
308
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
309
309
|
none: false
|
310
310
|
requirements:
|