spear-cb-api 0.0.9 → 0.0.10
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 +4 -4
- data/lib/spear/exceptions.rb +9 -1
- data/lib/spear/request.rb +2 -0
- data/lib/spear/resource/application.rb +1 -1
- data/lib/spear/structure/application/embeded_class.rb +24 -0
- data/lib/spear/structure/application/state.rb +6 -2
- data/lib/spear/version.rb +1 -1
- data/spec/spear_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9735511da1987a6ebf6037689ccc8bc1c558111d
|
4
|
+
data.tar.gz: e66ee281b2cda1bfc31e7d59c6e26801c9776307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b73ecf48f0b22dd010a6f0899f9636f270388bfcafe4af31cb5e1e59c927869d0f4c41176411c627584bb3ed5497a1ce9a2071a8681936b8daffd32bc5fe3a2b
|
7
|
+
data.tar.gz: 659f62673de00af1023aab7ce2bad3ce63341cb9bdbd6990999653687ec372d7a408b4ce9e66e39f5b854e0d5d0a50be9d6060ca110b1c34926593a7da73d125
|
data/lib/spear/exceptions.rb
CHANGED
@@ -15,7 +15,15 @@ module Spear
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
class ParametersNotValid < Error;
|
18
|
+
class ParametersNotValid < Error;
|
19
|
+
DEFAULT = 'The parameters is invalid.'
|
20
|
+
|
21
|
+
def initialize(message)
|
22
|
+
super(message || DEFAULT)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
19
26
|
class NetworkError < Error; end
|
27
|
+
class TimeoutError < Error; end
|
20
28
|
class ObjectTypeError < Error; end
|
21
29
|
end
|
data/lib/spear/request.rb
CHANGED
@@ -31,6 +31,30 @@ module Spear
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
class ApplicationObject
|
35
|
+
attr_accessor :app_did, :is_viewed, :view_date
|
36
|
+
|
37
|
+
def initialize(app_did, is_viewed, view_date)
|
38
|
+
@app_did = app_did
|
39
|
+
@is_viewed = 'true'.eql?(is_viewed)
|
40
|
+
@view_date = view_date unless view_date.blank?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def generate_apps(apps)
|
45
|
+
if !apps.nil?
|
46
|
+
if apps.kind_of?(Array)
|
47
|
+
apps.map {|app|
|
48
|
+
ApplicationObject.new(app['ApplicationDID'], app['Viewed'], app['ViewedDate'])
|
49
|
+
}
|
50
|
+
else # Hash
|
51
|
+
[] << ApplicationObject.new(apps['ApplicationDID'], apps['Viewed'], apps['ViewedDate'])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
[]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
34
58
|
end
|
35
59
|
end
|
36
60
|
end
|
@@ -2,13 +2,17 @@ module Spear
|
|
2
2
|
module Structure
|
3
3
|
module Application
|
4
4
|
class State < Structure::Base
|
5
|
-
|
5
|
+
include EmbededClass
|
6
|
+
|
7
|
+
attr_accessor :applications
|
6
8
|
|
7
9
|
def initialize(response)
|
8
10
|
super(response)
|
9
|
-
|
11
|
+
|
12
|
+
@applications = generate_apps(@root['ApplicationList']['Application']) rescue nil
|
10
13
|
end
|
11
14
|
end
|
15
|
+
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
data/lib/spear/version.rb
CHANGED
data/spec/spear_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
describe Spear do
|
2
2
|
before :each do
|
3
|
-
Spear.config({dev_key: '
|
3
|
+
Spear.config({dev_key: ENV['DEVELOPMENT_KEY'], project: 'ExampleApp', use_model: true})
|
4
4
|
end
|
5
5
|
|
6
6
|
it "check user existing" do
|
@@ -50,7 +50,7 @@ describe Spear do
|
|
50
50
|
|
51
51
|
it "get application status" do
|
52
52
|
# s = Spear.application_status(['JAWS4L16LFXD7ZL87LLC', 'JAWW63876DWNQGSWZ384', 'JA4M44C77CDSR0QHTRJ6'])
|
53
|
-
s = Spear.application_status('
|
53
|
+
s = Spear.application_status('J3H0YY6LLK553R3Z32Z', 'zhangfei@sina.com.cn')
|
54
54
|
puts s.response
|
55
55
|
end
|
56
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spear-cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CBluowei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|