zuora_api 1.0.2 → 1.0.3

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: daa72c28936f7cc79bea9eb9b9e582080ad6721c
4
- data.tar.gz: ed92237fb7c80a733922db3c33203b8be39d4d89
3
+ metadata.gz: 3519744d15acf7d302117624b6cddc11c9b1b029
4
+ data.tar.gz: 0636d89e841e13da8a2736ffd41f17f033527df6
5
5
  SHA512:
6
- metadata.gz: d7573ebb6e0b2affa89490a8560f6f72d9601ef19a421a56ed5ed9c4c5c66104775d4c3c446f9cd24fe6f2e89e654e49261f333e4c39b361d0fe41be0bd21640
7
- data.tar.gz: c28cab00aacdeb65daba3279904b0f2432da82aa97c8819af80fd955a4410fb6284dbcdf685df168c7723f5355ed2e81a6e7f09a1e98153637a7ce0c305d98a0
6
+ metadata.gz: f407d285e5e902c94723b152f60978656798826b208c003a37cab039063f96b7d9ade77c434807700ad603dd914a4c75fddf0206e5576ab59eb190a53a7c8614
7
+ data.tar.gz: 73582f5e5f6c3cc4701790b46302eefe8f430dbbbb133e5d06bb629e621191505253672debbd348095b1cea3d452978f8b5d41268c9f02cd77867af3a3ad2c66
@@ -5,7 +5,7 @@ module ZuoraAPI
5
5
  class Login
6
6
  ENVIRONMENTS = [SANDBOX = 'Sandbox', PRODUCTION = 'Production', PREFORMANCE = 'Preformance', SERVICES = 'Services', UNKNOWN = 'Unknown' ]
7
7
 
8
- attr_accessor :username, :password, :url, :wsdl_number, :status, :current_session, :environment, :status, :errors, :current_error, :user_info, :tenant_id, :tenant_name, :entity_id, :export_progress, :export_size
8
+ attr_accessor :username, :password, :url, :wsdl_number, :status, :current_session, :environment, :status, :errors, :current_error, :user_info, :tenant_id, :tenant_name, :entity_id
9
9
 
10
10
  def initialize(username: nil, password: nil, url: nil, entity_id: nil, session: nil, **keyword_args)
11
11
  @username = username
@@ -99,6 +99,7 @@ module ZuoraAPI
99
99
  xml['api'].login do
100
100
  xml['api'].username self.username
101
101
  xml['api'].password self.password
102
+ xml['api'].entityId self.entity_id if !self.entity_id.blank?
102
103
  end
103
104
  end
104
105
  end
@@ -239,7 +240,8 @@ module ZuoraAPI
239
240
  self.get_session
240
241
  base = self.url.include?(".com") ? self.url.split(".com")[0] : self.url.split(".eu")[0]
241
242
  url = object ? "#{base}.com/apps/api/describe/#{object}" : "#{base}.com/apps/api/describe/"
242
- response = HTTParty.get(url, :headers => {'Content-Type' => "text/xml; charset=utf-8"}, basic_auth: {:username => self.username, :password => self.password})
243
+ headers = !self.entity_id.nil? ? {"entityId" => self.entity_id, 'Content-Type' => "text/xml; charset=utf-8"} : {'Content-Type' => "text/xml; charset=utf-8"}
244
+ response = HTTParty.get(url, :headers => headers , basic_auth: {:username => self.username, :password => self.password})
243
245
  output_xml = Nokogiri::XML(response.body)
244
246
  des_hash = Hash.new
245
247
  if object == nil
@@ -267,6 +269,7 @@ module ZuoraAPI
267
269
 
268
270
  def rest_call(method: :get, body: {},headers: {}, url: rest_endpoint("catalog/products?pageSize=4") , debug: true, **keyword_args)
269
271
  tries ||= 2
272
+ headers["entityId"] = self.entity_id if !self.entity_id.nil?
270
273
  raise "Method not supported, supported methods include: :get, :post, :put, :delete, :patch, :head, :options" if ![:get, :post, :put, :delete, :patch, :head, :options].include?(method)
271
274
  response = HTTParty::Request.new("Net::HTTP::#{method.to_s.capitalize}".constantize, url, body: body, headers: {'Content-Type' => "application/json; charset=utf-8", "Authorization" => "ZSession #{self.get_session}"}.merge(headers)).perform
272
275
  Rails.logger.debug('Connect') { response.code} if debug
@@ -348,16 +351,16 @@ module ZuoraAPI
348
351
  temp_file = Tempfile.new([filename.rpartition('.').first, ".zip"], "#{Rails.root}/tmp")
349
352
  temp_file.binmode
350
353
 
351
- size, self.export_progress = [0, 0]
352
- self.export_size = response.header["Content-Length"].to_i
354
+ size, export_progress = [0, 0]
355
+ export_size = response.header["Content-Length"].to_i
353
356
  response.read_body do |chunk|
354
357
  temp_file << chunk.force_encoding("UTF-8")
355
358
  size += chunk.size
356
- new_progress = (size * 100) / self.export_size
357
- unless new_progress == self.export_progress
359
+ new_progress = (size * 100) / export_size
360
+ unless new_progress == export_progress
358
361
  Rails.logger.debug("Login: #{self.username} Export Downloading %s (%3d%%)" % [filename, new_progress])
359
362
  end
360
- self.export_progress = new_progress
363
+ export_progress = new_progress
361
364
  end
362
365
 
363
366
  temp_file.close
@@ -385,7 +388,7 @@ module ZuoraAPI
385
388
  xml['ns1'].create do
386
389
  xml['ns1'].zObjects('xsi:type' => "ns2:Export") do
387
390
  xml['ns2'].Format 'csv'
388
- xml['ns2'].Zip "#{zip}"
391
+ xml['ns2'].Zip zip
389
392
  xml['ns2'].Name 'googman'
390
393
  xml['ns2'].Query query
391
394
  xml['ns2'].Encrypted encrypted
@@ -429,6 +432,10 @@ module ZuoraAPI
429
432
  location = extract_zip(zip_file.path, "#{file_id}")
430
433
  File.delete(zip_file.path)
431
434
  return location
435
+ elsif !zip
436
+ file = get_file(:file_name => "#{file_id}.gpg" ,:url => "#{self.fileURL}#{file_id}?file-id=#{file_id}", headers: {"Authorization" => "ZSession " + self.current_session})
437
+ puts file.path
438
+ return file.path
432
439
  else
433
440
  return zip_file.path
434
441
  end
@@ -1,3 +1,3 @@
1
1
  module ZuoraAPI
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zuora Strategic Solutions Group
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-26 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler