zuora_connect 1.3.8.1 → 1.3.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6d5f05b1b4f3c37602ba49c9745757106ccc1ef
|
4
|
+
data.tar.gz: 51a55dd0baf20f50417d3297c5e2c243c6e880d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c90ceda1f586db2589e88743584b2a9c264fdd360a4c902f86877cc31d18ebe05947ad2bd32a34a746d00095ba9946c3e7f7d05d724c922614af2f4fe6f7f13a
|
7
|
+
data.tar.gz: c654907409adbb582b22e3b52c0655dbcafb137772d172f02abd843c462e417c3c8d12342512aca4d62ad037bd51e7ddd3a1b7df042f4c49be74dc7a424c5f9b
|
@@ -11,14 +11,14 @@ module ZuoraConnect
|
|
11
11
|
self.attr_builder("timezone", ZuoraConnect.configuration.default_time_zone)
|
12
12
|
self.attr_builder("locale", ZuoraConnect.configuration.default_locale)
|
13
13
|
Apartment::Tenant.switch!(self.id)
|
14
|
-
if( ActiveRecord::
|
14
|
+
if( ActiveRecord::Migrator.needs_migration?)
|
15
15
|
Apartment::Migrator.migrate(self.id)
|
16
16
|
end
|
17
17
|
Thread.current[:appinstance] = self
|
18
18
|
end
|
19
19
|
|
20
|
-
def data_lookup(session:
|
21
|
-
return session
|
20
|
+
def data_lookup(session: {})
|
21
|
+
return session
|
22
22
|
end
|
23
23
|
|
24
24
|
def cache_app_instance
|
@@ -27,12 +27,12 @@ module ZuoraConnect
|
|
27
27
|
$redis.del("Deleted:#{self.id}")
|
28
28
|
end
|
29
29
|
|
30
|
-
def decrypt_data(data)
|
30
|
+
def decrypt_data(data)
|
31
31
|
return Rails.env == 'development' ? JSON.parse(data) : JSON.parse(encryptor.decrypt_and_verify(CGI::unescape(data)))
|
32
32
|
end
|
33
33
|
|
34
|
-
def encrypt_data(data)
|
35
|
-
return Rails.env == 'development' ? data : encryptor.encrypt_and_sign(data)
|
34
|
+
def encrypt_data(data)
|
35
|
+
return Rails.env == 'development' ? data : encryptor.encrypt_and_sign(data)
|
36
36
|
end
|
37
37
|
|
38
38
|
def encryptor
|
@@ -43,6 +43,59 @@ module ZuoraConnect
|
|
43
43
|
return ActiveSupport::MessageEncryptor.new(secret, sign_secret)
|
44
44
|
end
|
45
45
|
|
46
|
+
def catalog_outdated?
|
47
|
+
return self.catalog_updated_at.blank? || (self.catalog_updated_at < Time.now - 12.hours)
|
48
|
+
end
|
49
|
+
|
50
|
+
def catalog_lookup(entity_id: nil, object: :product, map_lower_objects: true)
|
51
|
+
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
52
|
+
stub_catalog = ((self.catalog || {})[entity_reference] || {})
|
53
|
+
case object
|
54
|
+
when :product
|
55
|
+
if !map_lower_objects
|
56
|
+
stub_catalog = stub_catalog.map{|k,v| [k,v.except("productRatePlans").merge({"productRatePlans" => v["productRatePlans"].map {|k,v| v.except("productRatePlanCharges").merge({"productRatePlanCharges" => v["productRatePlanCharges"].map {|k,v| v}})}})]}.to_h
|
57
|
+
end
|
58
|
+
when :rateplan
|
59
|
+
stub_catalog = stub_catalog.map {|k,x| x["productRatePlans"] }.reduce({}, :merge)
|
60
|
+
|
61
|
+
if !map_lower_objects
|
62
|
+
stub_catalog = stub_catalog.map {|k,v| [k,v.except("productRatePlanCharges").merge({"productRatePlanCharges" => v["productRatePlanCharges"].map {|k,v| v}})]}.to_h
|
63
|
+
end
|
64
|
+
when :charge
|
65
|
+
stub_catalog = stub_catalog.map {|k,x| x["productRatePlans"].map{|k,x| x["productRatePlanCharges"] }.reduce({}, :merge)}.reduce({}, :merge)
|
66
|
+
end
|
67
|
+
|
68
|
+
return stub_catalog
|
69
|
+
end
|
70
|
+
|
71
|
+
def instance_failure(failure)
|
72
|
+
raise failure
|
73
|
+
end
|
74
|
+
|
75
|
+
def login_lookup(type: "Zuora")
|
76
|
+
results = []
|
77
|
+
self.logins.each do |name, login|
|
78
|
+
results << login if login.tenant_type == type
|
79
|
+
end
|
80
|
+
return results
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_catalog(zuora_login: self.login_lookup.first, force_update: false, entity_id: nil)
|
84
|
+
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
85
|
+
Rails.logger.debug("Fetching catalog for default") if entity_id.blank?
|
86
|
+
Rails.logger.debug("Fetching catalog for entity #{entity_id}") if !entity_id.blank?
|
87
|
+
if catalog_outdated? || force_update
|
88
|
+
Rails.logger.debug("Fetch Catalog")
|
89
|
+
self.update_column(:catalog_updated_at, Time.now.utc)
|
90
|
+
products = zuora_login.client(entity_reference).get_catalog
|
91
|
+
self.catalog = {} if self.catalog.blank? || self.catalog.class == Array
|
92
|
+
self.catalog[entity_reference] = products.blank? ? {} : products
|
93
|
+
self.update_column(:catalog, self.catalog)
|
94
|
+
self.touch
|
95
|
+
end
|
96
|
+
return self.catalog[entity_reference]
|
97
|
+
end
|
98
|
+
|
46
99
|
def new_session(session: self.data_lookup, username: self.access_token, password: self.refresh_token)
|
47
100
|
@api_version = (username.include?("@") ? "v1" : "v2")
|
48
101
|
@username = username
|
@@ -4,7 +4,7 @@ module ZuoraConnect
|
|
4
4
|
def initialize (fields)
|
5
5
|
@clients = {}
|
6
6
|
if fields["tenant_type"] == "Zuora" && fields["entities"] && fields["entities"].size > 0
|
7
|
-
@clients["
|
7
|
+
@clients["Default"] = ::ZuoraAPI::Login.new(fields.map{|k,v| [k.to_sym, v]}.to_h)
|
8
8
|
@default_entity = fields["entities"][0]["id"] if fields["entities"].size == 1
|
9
9
|
fields["entities"].each do |entity|
|
10
10
|
login_fields = fields.map{|k,v| [k.to_sym, v]}.to_h
|
@@ -12,7 +12,7 @@ module ZuoraConnect
|
|
12
12
|
@clients[entity["id"]] = ::ZuoraAPI::Login.new(login_fields)
|
13
13
|
end
|
14
14
|
elsif fields["tenant_type"] == "Zuora"
|
15
|
-
@clients["
|
15
|
+
@clients["Default"] = ::ZuoraAPI::Login.new(fields.map{|k,v| [k.to_sym, v]}.to_h)
|
16
16
|
end
|
17
17
|
|
18
18
|
self.attr_builder("available_entities",@clients.keys) if fields["tenant_type"] == "Zuora"
|
@@ -20,7 +20,7 @@ module ZuoraConnect
|
|
20
20
|
fields.each do |k,v|
|
21
21
|
self.attr_builder(k,v)
|
22
22
|
end
|
23
|
-
@default_entity ||= "
|
23
|
+
@default_entity ||= "Default"
|
24
24
|
end
|
25
25
|
|
26
26
|
def attr_builder(field,val)
|
@@ -34,5 +34,3 @@ module ZuoraConnect
|
|
34
34
|
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
38
|
-
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class AddCatalogDataToAppInstance < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :zuora_connect_app_instances, :catalog_updated_at, :datetime unless column_exists? :zuora_connect_app_instances, :catalog_updated_at
|
4
|
+
add_column :zuora_connect_app_instances, :catalog, :jsonb unless column_exists? :zuora_connect_app_instances, :catalog
|
5
|
+
end
|
6
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-session_store
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.3.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: httparty
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- db/migrate/20110131211919_add_sessions_table.rb
|
218
218
|
- db/migrate/20110411200303_add_expiration_to_app_instance.rb
|
219
219
|
- db/migrate/20110413191512_add_new_api_token.rb
|
220
|
+
- db/migrate/20110503003602_add_catalog_data_to_app_instance.rb
|
220
221
|
- lib/tasks/zuora_connect_tasks.rake
|
221
222
|
- lib/zuora_connect.rb
|
222
223
|
- lib/zuora_connect/configuration.rb
|