zuora_connect 1.4.0c → 1.4.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ac3e691c387b162c6b0266f6cee43a8ab95dabf
|
4
|
+
data.tar.gz: 48918306c16420b83a42a9a12b6c4d26bacd9b32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a3be57abe25f5d5997d81690d29a22540df3448db123e6392c725ecadd2ce9b92d459844323e482b4a1c41fd35106a2bce931a1b535828d63c33c9a9ef15f07
|
7
|
+
data.tar.gz: 78e378daa61b7731691d578b995034c5e6ca4fbae24c85d2702e310c705b1f7292dcb268e4dd8ee15fdbaa3d2db3e9bb0167037d709f607f7025d0b217b37e67
|
@@ -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(
|
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
|
@@ -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.4.
|
4
|
+
version: 1.4.0
|
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-05-
|
11
|
+
date: 2017-05-12 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.3.
|
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.3.
|
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
|
@@ -280,9 +281,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
281
|
version: '0'
|
281
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
283
|
requirements:
|
283
|
-
- - "
|
284
|
+
- - ">="
|
284
285
|
- !ruby/object:Gem::Version
|
285
|
-
version:
|
286
|
+
version: '0'
|
286
287
|
requirements: []
|
287
288
|
rubyforge_project:
|
288
289
|
rubygems_version: 2.5.1
|