zuora_connect 1.3.9 → 1.4.0a

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: e6d5f05b1b4f3c37602ba49c9745757106ccc1ef
4
- data.tar.gz: 51a55dd0baf20f50417d3297c5e2c243c6e880d6
3
+ metadata.gz: 5a2bce9917263f9e79e86e7f92b0eb3e7b208aa3
4
+ data.tar.gz: cef13fbb624e9d6ee81295e352766f9b2d5f9115
5
5
  SHA512:
6
- metadata.gz: c90ceda1f586db2589e88743584b2a9c264fdd360a4c902f86877cc31d18ebe05947ad2bd32a34a746d00095ba9946c3e7f7d05d724c922614af2f4fe6f7f13a
7
- data.tar.gz: c654907409adbb582b22e3b52c0655dbcafb137772d172f02abd843c462e417c3c8d12342512aca4d62ad037bd51e7ddd3a1b7df042f4c49be74dc7a424c5f9b
6
+ metadata.gz: d68a9eefa6b7139ae3b6ede62ceeb027cf6957fe458ff29e05f9227c61e55d15deaf645dc76491111d869d1034c8b1adf562f952042a60d1899f162f2090184e
7
+ data.tar.gz: cb18a44be8d166f1ef9f0a2d06ace9a99800b26c83267265164ace509c4d63ec634da84277131527ed61d0a83faf7eb6df0f963c2d28aae7f3c3634a950449fc
@@ -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::Migrator.needs_migration?)
14
+ if( ActiveRecord::Migration.check_pending! != nil)
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: nil)
21
+ return session.blank? ? {} : 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,59 +43,6 @@ 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
-
99
46
  def new_session(session: self.data_lookup, username: self.access_token, password: self.refresh_token)
100
47
  @api_version = (username.include?("@") ? "v1" : "v2")
101
48
  @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["Default"] = ::ZuoraAPI::Login.new(fields.map{|k,v| [k.to_sym, v]}.to_h)
7
+ @clients["none"] = ::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["Default"] = ::ZuoraAPI::Login.new(fields.map{|k,v| [k.to_sym, v]}.to_h)
15
+ @clients["none"] = ::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 ||= "Default"
23
+ @default_entity ||= "none"
24
24
  end
25
25
 
26
26
  def attr_builder(field,val)
@@ -34,3 +34,5 @@ module ZuoraConnect
34
34
 
35
35
  end
36
36
  end
37
+
38
+
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.3.9"
2
+ VERSION = "1.4.0a"
3
3
  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.9
4
+ version: 1.4.0a
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-03 00:00:00.000000000 Z
11
+ date: 2017-05-01 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.0
47
+ version: 1.3.0a
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.0
54
+ version: 1.3.0a
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: httparty
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +217,6 @@ 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
221
220
  - lib/tasks/zuora_connect_tasks.rake
222
221
  - lib/zuora_connect.rb
223
222
  - lib/zuora_connect/configuration.rb
@@ -281,9 +280,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
280
  version: '0'
282
281
  required_rubygems_version: !ruby/object:Gem::Requirement
283
282
  requirements:
284
- - - ">="
283
+ - - ">"
285
284
  - !ruby/object:Gem::Version
286
- version: '0'
285
+ version: 1.3.1
287
286
  requirements: []
288
287
  rubyforge_project:
289
288
  rubygems_version: 2.5.1
@@ -1,6 +0,0 @@
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