zuora_connect 2.0.60n → 2.0.60o

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
  SHA256:
3
- metadata.gz: 97f4f62548850bb29aa5afe9dabfd967279d0900771599bac82cc67ea44b73f2
4
- data.tar.gz: cebd295e51df06156e5e054e15c681b83cdec69d39a42dfd267fcd2d6f094f42
3
+ metadata.gz: 7d82918ec805d77782d6697f71fa0e28c85c75d243632207a2930046aeacdc60
4
+ data.tar.gz: 9f2341b491fbb516259cd0ace04482da657f688000609ba6cca99a9d85437fc6
5
5
  SHA512:
6
- metadata.gz: a77a8dacf8c09f5dd3aec37fe1cbb597574588e44ead312d3af0d42d2f80c59ee3fd4d123aeca5d5c60d5faf73d9d5dbe57575d2c83aa37b58f303efc6b502ca
7
- data.tar.gz: 49123c079c3561c3a406358192c9289dbe438d4f9b4687c8686a92b10d828825d47dfbe939f0c84eab89e15ee2662ecea5b0c4b47af08326897e7f2bcfb30887
6
+ metadata.gz: '059e06f6514b2580a013cedf8e37843936465f44c1b55020d0fc790862b3f983b6ecac6696c2b899db8eba94bfccf6fe431b8ae7422c1ef241b1c833652b87a1'
7
+ data.tar.gz: 0174a924a7291780e970718d2c98a6bf43819eae85f4b71afd43f5f4214b357587967cd3072d7f9996d21fe97897903f5e4da9d0bcce7b4915421982dcef3d72
@@ -21,6 +21,7 @@ module ZuoraConnect
21
21
  HOLDING_PATTERN_SLEEP = 5.seconds
22
22
  CONNECT_APPLICATION_ID = 0
23
23
  CONNECT_COMMUNICATION_SLEEP = Rails.env.test? ? 0.seconds : 5.seconds
24
+ CATALOG_LOOKUP_PAGE_SIZE = 10_000
24
25
  IGNORED_LOCALS = ['fr', 'ja', 'es', 'zh', 'de']
25
26
  INTERNAL_HOSTS = []
26
27
  LOGIN_TENANT_DESTINATION = 'target_login'
@@ -1006,13 +1007,67 @@ module ZuoraConnect
1006
1007
  # object_id: The id or id's of the object/objects to be returned.
1007
1008
  # child_objects: Whether to include child objects of the object in question.
1008
1009
  # cache: Store individual "1" object lookup in redis for caching.
1009
- def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false)
1010
+ def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false, source: 'DB')
1010
1011
  entity_reference = entity_id.blank? ? 'Default' : entity_id
1011
1012
 
1012
1013
  if object_id.present? && ![Array, String].include?(object_id.class)
1013
1014
  raise "Object Id can only be a string or an array of strings"
1014
1015
  end
1015
1016
 
1017
+ if source == 'API'
1018
+ zuora_login = self.login_lookup(type: 'Zuora').first
1019
+ login = zuora_login.client(entity_reference)
1020
+
1021
+ catalog_container = {}
1022
+ response = {
1023
+ 'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{CATALOG_LOOKUP_PAGE_SIZE}")
1024
+ }
1025
+ while response['nextPage'].present?
1026
+ url = login.rest_endpoint(response['nextPage'].split('/v1/').last)
1027
+ output_json, response = login.rest_call(debug: false, url: url, timeout_retry: true)
1028
+
1029
+ case object
1030
+ when :product
1031
+ output_json.fetch('products', []).each do |product|
1032
+ if object_id.nil?
1033
+ catalog_container[product['id']] = product.except('productRatePlans')
1034
+ elsif object_id.is_a?(String)
1035
+ next unless product['id'] == object_id
1036
+
1037
+ rate_plans = {}
1038
+ product['productRatePlans'].each do |rate_plan|
1039
+ charges = {}
1040
+ rate_plan['productRatePlanCharges'].each do |charge|
1041
+ charges[charge['id']] = charge.merge(
1042
+ {
1043
+ 'productId' => product['id'],
1044
+ 'productName' => product['name'],
1045
+ 'productRatePlanId' => rate_plan['id'],
1046
+ 'productRatePlanName' => rate_plan['name'],
1047
+ }
1048
+ )
1049
+ end
1050
+
1051
+ rate_plan['productRatePlanCharges'] = charges
1052
+ rate_plans[rate_plan['id']] = rate_plan.merge(
1053
+ {
1054
+ 'productId' => product['id'],
1055
+ 'productName' => product['name']
1056
+ }
1057
+ )
1058
+ end
1059
+
1060
+ product['productRatePlans'] = rate_plans
1061
+ catalog_container = product
1062
+ end
1063
+ end
1064
+ else
1065
+ raise "Available objects include [:product]"
1066
+ end
1067
+ end
1068
+ return catalog_container
1069
+ end
1070
+
1016
1071
  if defined?(Redis.current) && object_id.present? && object_id.class == String && object_id.present?
1017
1072
  stub_catalog = cache ? decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Children:#{child_objects}")) : nil
1018
1073
  object_hierarchy = decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Hierarchy"))
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "2.0.60n"
2
+ VERSION = "2.0.60o"
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: 2.0.60n
4
+ version: 2.0.60o
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-10 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment