opera-mobile-store-sdk 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opera-mobile-store-sdk.rb +2 -1
- data/lib/opera-mobile-store-sdk/version.rb +1 -1
- data/lib/opera/mobile_store/build.rb +97 -101
- data/lib/opera/mobile_store/build_file.rb +24 -27
- data/lib/opera/mobile_store/category.rb +17 -19
- data/lib/opera/mobile_store/developer.rb +61 -59
- data/lib/opera/mobile_store/inspectable_attributes.rb +13 -0
- data/lib/opera/mobile_store/payment_info.rb +76 -82
- data/lib/opera/mobile_store/product.rb +172 -177
- data/lib/opera/mobile_store/product_image.rb +30 -32
- data/lib/opera/mobile_store/product_localization.rb +21 -23
- data/lib/opera/mobile_store_sdk/identity_mapable.rb +11 -3
- metadata +3 -3
- data/lib/opera/mobile_store/author.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7580c98f69eaa74be9332b97b6c508f6189b5e0e
|
4
|
+
data.tar.gz: 0aa75ee6c1c38dcf970acd47116ec627bec85549
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9565ba3b577af06ec4a9532d1982ebb90c42152dd7f8f6ef66a977934b5d593a183534dd0420900c27cfb42409aceaca2d174fae3a0d62f021a6ee281f87f3e2
|
7
|
+
data.tar.gz: bfed336b46f33cf1aabf435807b77fafdcd54229c2d078c3465fb81a55438a4e486ccb86e5d98a537a4e6f6f0ff3a8cddaedb5c1d3baf722cc5fdaa4260f84e3
|
@@ -9,11 +9,12 @@ module Opera
|
|
9
9
|
autoload :ProductLocalization
|
10
10
|
autoload :ProductImage
|
11
11
|
autoload :Category
|
12
|
-
autoload :Author
|
13
12
|
autoload :Build
|
14
13
|
autoload :BuildFile
|
15
14
|
autoload :Developer
|
16
15
|
autoload :PaymentInfo
|
16
|
+
|
17
|
+
autoload :InspectableAttributes
|
17
18
|
end
|
18
19
|
|
19
20
|
module MobileStoreSDK
|
@@ -1,129 +1,125 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
module Opera::MobileStore
|
4
|
+
class Build
|
5
|
+
|
6
|
+
include ActiveModel::Model
|
7
|
+
include ActiveModel::Serialization
|
8
|
+
|
9
|
+
include Opera::MobileStore::InspectableAttributes
|
10
|
+
|
11
|
+
# All attributes are Read-Only...
|
12
|
+
attr_accessor :id,
|
13
|
+
:name,
|
14
|
+
:platform,
|
15
|
+
:type,
|
16
|
+
:installer_type,
|
17
|
+
:package_name,
|
18
|
+
:version_name,
|
19
|
+
:version_code,
|
20
|
+
:build_update_date,
|
21
|
+
:files,
|
22
|
+
:billing,
|
23
|
+
:languages
|
24
|
+
|
25
|
+
def files
|
26
|
+
@files ||= []
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def languages
|
30
|
+
@languages ||= []
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def billing
|
34
|
+
@billing ||= false
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
37
|
+
def attributes
|
38
|
+
[
|
39
|
+
:id, :name, :platform, :type, :installer_type, :package_name,
|
40
|
+
:version_name, :version_code, :build_update_date, :files, :billing,
|
41
|
+
:languages
|
42
|
+
].inject({}) do |hash, field_name|
|
43
|
+
field_value = self.public_send field_name
|
44
|
+
hash[field_name.to_s] = field_value if field_value.present?
|
45
|
+
hash
|
46
46
|
end
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
# Override of serializable_hash:
|
50
|
+
#
|
51
|
+
# This override will prevent dumping special objects to the hash:
|
52
|
+
def serializable_hash(options = nil)
|
53
|
+
attributes.inject({}) do |shsh, keyval|
|
54
|
+
field_name, field_value = keyval
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
shsh[field_name] = field_value
|
60
|
-
shsh
|
56
|
+
if field_name == 'files' # Array of special objects
|
57
|
+
field_value = field_value.map(&:serializable_hash)
|
61
58
|
end
|
62
|
-
end
|
63
59
|
|
64
|
-
|
60
|
+
shsh[field_name] = field_value
|
61
|
+
shsh
|
62
|
+
end
|
63
|
+
end
|
65
64
|
|
66
|
-
|
65
|
+
def self.build_from_nokogiri_node(node)
|
67
66
|
|
68
|
-
|
69
|
-
id: node.xpath("string(@id)").to_i,
|
70
|
-
name: node.xpath("string(name)").strip,
|
71
|
-
platform: node.xpath("string(platform)").strip,
|
72
|
-
type: node.xpath("string(type)").strip,
|
73
|
-
installer_type: node.xpath("string(installer_type)").strip,
|
74
|
-
package_name: node.xpath("string(package_name)").strip,
|
75
|
-
version_name: node.xpath("string(version_name)").strip,
|
76
|
-
version_code: version_code.present? ? version_code.to_i : nil,
|
77
|
-
build_update_date: Time.parse(node.xpath "string(build_update_date)"),
|
78
|
-
}.select { |key, val| val.present? }
|
67
|
+
version_code = node.xpath("string(version_code)")
|
79
68
|
|
80
|
-
|
81
|
-
|
82
|
-
|
69
|
+
data = {
|
70
|
+
id: node.xpath("string(@id)").to_i,
|
71
|
+
name: node.xpath("string(name)").strip,
|
72
|
+
platform: node.xpath("string(platform)").strip,
|
73
|
+
type: node.xpath("string(type)").strip,
|
74
|
+
installer_type: node.xpath("string(installer_type)").strip,
|
75
|
+
package_name: node.xpath("string(package_name)").strip,
|
76
|
+
version_name: node.xpath("string(version_name)").strip,
|
77
|
+
version_code: version_code.present? ? version_code.to_i : nil,
|
78
|
+
build_update_date: Time.parse(node.xpath "string(build_update_date)"),
|
79
|
+
}.select { |key, val| val.present? }
|
83
80
|
|
84
|
-
|
81
|
+
data[:files] = node.xpath("files/file").map do |f|
|
82
|
+
BuildFile.build_from_nokogiri_node f
|
83
|
+
end
|
85
84
|
|
86
|
-
|
87
|
-
language.attributes["code"].to_s.strip
|
88
|
-
end
|
85
|
+
data[:billing] = node.xpath("string(billing)").to_i > 0
|
89
86
|
|
90
|
-
|
87
|
+
data[:languages] = node.xpath("languages/language").map do |language|
|
88
|
+
language.attributes["code"].to_s.strip
|
91
89
|
end
|
92
90
|
|
93
|
-
|
94
|
-
|
95
|
-
:id, :name, :platform, :type, :installer_type, :package_name,
|
96
|
-
:version_name, :version_code, :build_update_date, :files, :billing,
|
97
|
-
:languages
|
98
|
-
].inject({}) do |hash, field_name|
|
99
|
-
field_value = self.public_send field_name
|
100
|
-
hash[field_name.to_s] = field_value if field_value.present?
|
101
|
-
hash
|
102
|
-
end
|
103
|
-
end
|
91
|
+
self.new data
|
92
|
+
end
|
104
93
|
|
105
|
-
|
106
|
-
|
94
|
+
def attributes
|
95
|
+
[
|
96
|
+
:id, :name, :platform, :type, :installer_type, :package_name,
|
97
|
+
:version_name, :version_code, :build_update_date, :files, :billing,
|
98
|
+
:languages
|
99
|
+
].inject({}) do |hash, field_name|
|
100
|
+
field_value = self.public_send field_name
|
101
|
+
hash[field_name.to_s] = field_value if field_value.present?
|
102
|
+
hash
|
107
103
|
end
|
104
|
+
end
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
def self.deserialize(serializable_hash)
|
107
|
+
attributes_hash = serializable_hash.inject({}) do |hsh, keyval|
|
108
|
+
field_name, field_value = keyval
|
112
109
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
110
|
+
case field_name
|
111
|
+
when 'files'
|
112
|
+
field_value = field_value.map do |item_serializable_hash|
|
113
|
+
BuildFile.deserialize item_serializable_hash
|
118
114
|
end
|
119
|
-
|
120
|
-
hsh[field_name] = field_value
|
121
|
-
hsh
|
122
115
|
end
|
123
116
|
|
124
|
-
|
117
|
+
hsh[field_name] = field_value
|
118
|
+
hsh
|
125
119
|
end
|
126
120
|
|
121
|
+
self.new attributes_hash
|
127
122
|
end
|
123
|
+
|
128
124
|
end
|
129
125
|
end
|
@@ -1,38 +1,35 @@
|
|
1
|
-
|
2
|
-
module MobileStore
|
3
|
-
class BuildFile
|
4
|
-
|
5
|
-
include ActiveModel::Model
|
6
|
-
include ActiveModel::Serialization
|
7
|
-
|
8
|
-
# All attributes are Read-Only...
|
9
|
-
attr_accessor :size, :url
|
10
|
-
|
11
|
-
def attributes
|
12
|
-
[:size, :url].inject({}) do |hash, field_name|
|
13
|
-
field_value = self.public_send field_name
|
14
|
-
hash[field_name.to_s] = field_value if field_value.present?
|
15
|
-
hash
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require "active_model"
|
18
2
|
|
19
|
-
|
3
|
+
module Opera::MobileStore
|
4
|
+
class BuildFile
|
20
5
|
|
21
|
-
|
6
|
+
include ActiveModel::Model
|
7
|
+
include ActiveModel::Serialization
|
8
|
+
include Opera::MobileStore::InspectableAttributes
|
22
9
|
|
23
|
-
|
24
|
-
|
25
|
-
data[:size] = file_size.to_i if file_size.present?
|
10
|
+
# All attributes are Read-Only...
|
11
|
+
attr_accessor :size, :url
|
26
12
|
|
27
|
-
|
13
|
+
def attributes
|
14
|
+
[:size, :url].inject({}) do |hash, field_name|
|
15
|
+
field_value = self.public_send field_name
|
16
|
+
hash[field_name.to_s] = field_value if field_value.present?
|
17
|
+
hash
|
28
18
|
end
|
19
|
+
end
|
29
20
|
|
30
|
-
|
31
|
-
"<#{self.class.name} #{attributes.inspect}>"
|
32
|
-
end
|
21
|
+
def self.build_from_nokogiri_node(node)
|
33
22
|
|
34
|
-
|
23
|
+
data = { url: node.text.strip }
|
35
24
|
|
25
|
+
# Extract width + height data:
|
26
|
+
file_size = node.xpath("string(@size)")
|
27
|
+
data[:size] = file_size.to_i if file_size.present?
|
28
|
+
|
29
|
+
self.new data
|
36
30
|
end
|
31
|
+
|
32
|
+
self.singleton_class.send :alias_method, :deserialize, :new
|
33
|
+
|
37
34
|
end
|
38
35
|
end
|
@@ -1,29 +1,27 @@
|
|
1
|
-
|
2
|
-
module MobileStore
|
3
|
-
class Category
|
1
|
+
require "active_model"
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
module Opera::MobileStore
|
4
|
+
class Category
|
7
5
|
|
8
|
-
|
6
|
+
include ActiveModel::Model
|
7
|
+
include ActiveModel::Serialization
|
9
8
|
|
10
|
-
|
11
|
-
attr_accessor :id, :code, :name
|
9
|
+
include Opera::MobileStore::InspectableAttributes
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
hash
|
18
|
-
end
|
19
|
-
end
|
11
|
+
include Opera::MobileStoreSDK::IdentityMapable
|
12
|
+
|
13
|
+
# All attributes are Read-Only...
|
14
|
+
attr_accessor :id, :code, :name
|
20
15
|
|
21
|
-
|
22
|
-
|
16
|
+
def attributes
|
17
|
+
[:id, :code, :name].inject({}) do |hash, field_name|
|
18
|
+
field_value = self.public_send field_name
|
19
|
+
hash[field_name.to_s] = field_value unless field_value.nil?
|
20
|
+
hash
|
23
21
|
end
|
22
|
+
end
|
24
23
|
|
25
|
-
|
24
|
+
self.singleton_class.send :alias_method, :deserialize, :new
|
26
25
|
|
27
|
-
end
|
28
26
|
end
|
29
27
|
end
|
@@ -1,70 +1,72 @@
|
|
1
1
|
require "active_model"
|
2
2
|
|
3
|
-
module Opera
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
data[:address2] = node.xpath("string(address2)").strip
|
29
|
-
|
30
|
-
[
|
31
|
-
:city, :state, :zip, :country_code, :website_url,
|
32
|
-
:orders_email, :contact_email
|
33
|
-
].each do |attribute_name|
|
34
|
-
value = node.xpath("string(#{attribute_name})").strip
|
35
|
-
data[attribute_name] = value if value.present?
|
36
|
-
end
|
37
|
-
|
38
|
-
phones = node.xpath("phones").text
|
39
|
-
byebug if phones.present?
|
40
|
-
|
41
|
-
payment_info = PaymentInfo.build_from_nokogiri_node node.xpath("payment").first
|
42
|
-
data[:payment_info] = payment_info if payment_info.present?
|
43
|
-
|
44
|
-
|
45
|
-
self.new data
|
3
|
+
module Opera::MobileStore
|
4
|
+
class Developer
|
5
|
+
|
6
|
+
include ActiveModel::Model
|
7
|
+
include ActiveModel::Serialization
|
8
|
+
|
9
|
+
include Opera::MobileStore::InspectableAttributes
|
10
|
+
|
11
|
+
include Opera::MobileStoreSDK::APIAccessible
|
12
|
+
include Opera::MobileStoreSDK::IdentityMapable
|
13
|
+
|
14
|
+
# All attributes are Read-Only...
|
15
|
+
attr_accessor :id, :login, :email, :name,
|
16
|
+
:address1, :address2,
|
17
|
+
:city, :state, :zip, :country_code, :website_url,
|
18
|
+
:orders_email, :contact_email, :phones, :payment_info
|
19
|
+
|
20
|
+
def attributes
|
21
|
+
[
|
22
|
+
:id, :login, :email, :name, :address1, :address2, :city, :state, :zip,
|
23
|
+
:country_code, :website_url, :orders_email, :contact_email, :payment_info
|
24
|
+
].inject({}) do |attributes_hash, field_name|
|
25
|
+
field_value = public_send field_name
|
26
|
+
attributes_hash[field_name.to_s] = field_value if field_value.present?
|
27
|
+
attributes_hash
|
46
28
|
end
|
29
|
+
end
|
47
30
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
hash[method] = value if value.present?
|
55
|
-
hash
|
56
|
-
end
|
57
|
-
end
|
31
|
+
# Override of serializable_hash:
|
32
|
+
#
|
33
|
+
# This override will prevent dumping special objects to the hash:
|
34
|
+
def serializable_hash(options = nil)
|
35
|
+
attributes.inject({}) do |shsh, keyval|
|
36
|
+
field_name, field_value = keyval
|
58
37
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
attributes + ["#{key}:#{val}"]
|
63
|
-
end.join(", ")
|
38
|
+
# Get the payment_info serializable hash:
|
39
|
+
field_value = field_value.serializable_hash \
|
40
|
+
if field_name == 'payment_info'
|
64
41
|
|
65
|
-
|
42
|
+
shsh[field_name] = field_value
|
43
|
+
shsh
|
66
44
|
end
|
45
|
+
end
|
67
46
|
|
47
|
+
def self.build_from_nokogiri_node(node)
|
48
|
+
data = {
|
49
|
+
id: node.xpath("string(@id)").to_i,
|
50
|
+
login: node.xpath("string(@login)").strip,
|
51
|
+
email: node.xpath("string(email)").strip,
|
52
|
+
name: node.xpath("string(name)").strip,
|
53
|
+
address1: node.xpath("string(address1)").strip,
|
54
|
+
address2: node.xpath("string(address2)").strip,
|
55
|
+
city: node.xpath("string(city)").strip,
|
56
|
+
state: node.xpath("string(state)").strip,
|
57
|
+
zip: node.xpath("string(zip)").strip,
|
58
|
+
country_code: node.xpath("string(country_code)").strip,
|
59
|
+
website_url: node.xpath("string(website_url)").strip,
|
60
|
+
orders_email: node.xpath("string(orders_email)").strip,
|
61
|
+
contact_email: node.xpath("string(contact_email)").strip,
|
62
|
+
phones: node.xpath("phones").text
|
63
|
+
}.select { |key, value| value.present? }
|
64
|
+
|
65
|
+
payment_info = PaymentInfo.build_from_nokogiri_node node.xpath("payment").first
|
66
|
+
data[:payment_info] = payment_info if payment_info.present?
|
67
|
+
|
68
|
+
self.new data
|
68
69
|
end
|
70
|
+
|
69
71
|
end
|
70
72
|
end
|