sklik-api 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -2
- data/VERSION +1 -1
- data/lib/sklik-api/access.rb +19 -1
- data/lib/sklik-api/connection.rb +18 -3
- data/sklik-api.gemspec +2 -2
- metadata +3 -3
data/README.markdown
CHANGED
@@ -25,9 +25,13 @@ SklikApi.use_rollback = true
|
|
25
25
|
|
26
26
|
# you can set it before every action to sklik api, if you have multiple accounts :-)
|
27
27
|
SklikApi::Access.set(
|
28
|
-
:email
|
28
|
+
:email => "your_email@seznam.cz",
|
29
29
|
:password => "password",
|
30
|
-
|
30
|
+
:session => "123456789000000000", # optional when you store session (14 days expiration)
|
31
|
+
# outside your running code (in database etc.)
|
32
|
+
# this will lower your request numbers (no need for getting new session for every call)
|
33
|
+
# :customer_id => 1112 # (optional) - this will switch you into connected account
|
34
|
+
# and all creation will be performed there
|
31
35
|
)
|
32
36
|
#this setting can be changed on the fly!
|
33
37
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/sklik-api/access.rb
CHANGED
@@ -10,7 +10,10 @@ class SklikApi::Access
|
|
10
10
|
|
11
11
|
#save argument to right places
|
12
12
|
@args = args
|
13
|
-
|
13
|
+
|
14
|
+
#save session if present
|
15
|
+
@session = args.has_key?(:session) ? args[:session] : nil
|
16
|
+
|
14
17
|
#return this object!
|
15
18
|
return self
|
16
19
|
end
|
@@ -38,6 +41,21 @@ class SklikApi::Access
|
|
38
41
|
def self.password
|
39
42
|
@args[:password].to_s
|
40
43
|
end
|
44
|
+
|
45
|
+
#Set session
|
46
|
+
def self.session= session
|
47
|
+
session
|
48
|
+
end
|
49
|
+
|
50
|
+
#Get session
|
51
|
+
def self.session
|
52
|
+
@session
|
53
|
+
end
|
54
|
+
|
55
|
+
#Has setted session
|
56
|
+
def self.session?
|
57
|
+
!@session.nil?
|
58
|
+
end
|
41
59
|
|
42
60
|
#if you change Access credentials change uniq identifier ->
|
43
61
|
#used for stroing sessions for multiple logins
|
data/lib/sklik-api/connection.rb
CHANGED
@@ -34,21 +34,36 @@ class SklikApi
|
|
34
34
|
#every taxonomy has its own session!
|
35
35
|
def get_session force = false
|
36
36
|
@session ||= {}
|
37
|
+
#try to get session from cache
|
37
38
|
if @session.has_key?(SklikApi::Access.uniq_identifier) && !force
|
38
39
|
@session[SklikApi::Access.uniq_identifier]
|
40
|
+
|
41
|
+
#try to use session from Access settings
|
42
|
+
elsif SklikApi::Access.session? && !force
|
43
|
+
return @session[SklikApi::Access.uniq_identifier] = SklikApi::Access.session
|
44
|
+
|
45
|
+
#else retrive new session
|
39
46
|
else
|
40
47
|
begin
|
41
48
|
SklikApi.log(:debug, "Getting session for #{SklikApi::Access.email}")
|
42
49
|
param = connection.call("client.login", SklikApi::Access.email, SklikApi::Access.password).symbolize_keys
|
43
50
|
SklikApi.log(:debug, "Session received: #{param.inspect}")
|
44
51
|
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
#good session
|
53
|
+
if param[:status] == 200
|
54
|
+
#SET NEW SESSION
|
55
|
+
SklikApi::Access.session = param[:session]
|
48
56
|
return @session[SklikApi::Access.uniq_identifier] = param[:session]
|
57
|
+
|
58
|
+
#bad login
|
59
|
+
elsif param[:status] == 401
|
60
|
+
raise ArgumentError, "Invalid login for: #{SklikApi::Access.email}"
|
61
|
+
|
62
|
+
#Something else went wrong
|
49
63
|
else
|
50
64
|
raise ArgumentError, param[:statusMessage]
|
51
65
|
end
|
66
|
+
|
52
67
|
rescue XMLRPC::FaultException => e
|
53
68
|
raise ArgumentError, "#{e.faultString}, #{e.faultCode}"
|
54
69
|
rescue Exception => e
|
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.6"
|
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-
|
12
|
+
s.date = "2013-08-08"
|
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 = [
|
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.6
|
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-
|
12
|
+
date: 2013-08-08 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: -3972173860568696425
|
308
308
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
309
309
|
none: false
|
310
310
|
requirements:
|