zuora-client 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,7 +7,7 @@ Client for Zuora API
7
7
  $ sudo gem install zuora-client
8
8
 
9
9
  == Usage
10
- zuora-client -u <username> -p <passowrd> <query>
10
+ zuora-client -u <username> -p <password> <query>
11
11
 
12
12
  == Note on Patches/Pull Requests
13
13
 
data/Rakefile CHANGED
@@ -5,12 +5,12 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "zuora-client"
8
- gem.version = "1.0.0"
8
+ gem.version = "1.0.1"
9
9
  gem.summary = "Zuora Client"
10
10
  gem.description = "A client for Zuora"
11
- gem.email = "brianm@ning.com"
11
+ gem.email = "gene@ning.com"
12
12
  gem.homepage = "http://github.com/ning/zuora-client"
13
- gem.authors = ["Brian McCallister"]
13
+ gem.authors = ["Cloocher"]
14
14
  gem.files = FileList["CHANGES", "zuora-client.gemspec", "Rakefile", "README", "VERSION",
15
15
  "lib/**/*", "bin/**/*"]
16
16
  gem.add_dependency "savon", ">= 0.7.9"
data/bin/zuora-client CHANGED
@@ -25,11 +25,13 @@ Savon::Request.log = false
25
25
 
26
26
  username = nil
27
27
  password = nil
28
+ environment = 'prod'
28
29
 
29
30
  opts = OptionParser.new do |opts|
30
31
  opts.banner = 'Usage: zuora -u <username> -p <password> <query>'
31
32
  opts.on('-u', '--user USER', 'username') { |u| username = u }
32
33
  opts.on('-p', '--pass PASSWORD', 'password') { |p| password = p }
34
+ opts.on('-e', '--env ENVIRONMENT', '[prod|sandbox]') { |e| environment = e }
33
35
  opts.on('-v', '--verbose', 'log harder') { Savon::Request.log = true }
34
36
  end
35
37
 
@@ -46,7 +48,14 @@ unless username and password
46
48
  exit 1
47
49
  end
48
50
 
49
- zuora_client = ZuoraClient.new(username, password)
51
+ url = case environment.downcase
52
+ when 'sandbox'
53
+ ZuoraClient::SANDBOX_URL
54
+ else
55
+ ZuoraClient::PROD_URL
56
+ end
57
+
58
+ zuora_client = ZuoraClient.new(username, password, url)
50
59
 
51
60
  result = zuora_client.query(query_string)
52
61
 
data/lib/zuora_client.rb CHANGED
@@ -17,31 +17,37 @@
17
17
  require 'savon'
18
18
 
19
19
  class ZuoraClient
20
+ PROD_URL = 'https://www.zuora.com/apps/services/a/21.0'
21
+ SANDBOX_URL = 'https://apisandbox.zuora.com/apps/services/a/23.0'
20
22
 
21
- def initialize(username, password, verbose=false)
23
+ def initialize(username, password, url=PROD_URL, verbose=false)
22
24
  @username = username
23
25
  @password = password
24
26
 
25
27
  Savon::Request.log = verbose
26
- @client = Savon::Client.new "https://www.zuora.com/apps/services/a/21.0"
27
- @client.request.http.ssl_client_auth :verify_mode => OpenSSL::SSL::VERIFY_NONE
28
+ login_client = Savon::Client.new url
29
+ login_client.request.http.ssl_client_auth :verify_mode => OpenSSL::SSL::VERIFY_NONE
28
30
 
29
- response = @client.login! do |soap|
30
- soap.namespace = "http://api.zuora.com/"
31
+ response = login_client.login! do |soap|
32
+ soap.namespace = 'http://api.zuora.com/'
31
33
  soap.body = {
32
- "wsdl:username" => username,
33
- "wsdl:password" => password
34
+ 'wsdl:username' => username,
35
+ 'wsdl:password' => password
34
36
  }
35
37
  end.to_hash
38
+
36
39
  @session = response[:login_response][:result][:session]
40
+ # apparently, the server url might change from the one called above - need to use the one returned
41
+ @client = Savon::Client.new response[:login_response][:result][:server_url]
42
+ @client.request.http.ssl_client_auth :verify_mode => OpenSSL::SSL::VERIFY_NONE
37
43
  end
38
44
 
39
45
  def query(query_string)
40
46
  begin
41
47
  response = @client.query! do |soap|
42
- soap.namespace = "http://api.zuora.com/"
43
- soap.header['wsdl:SessionHeader'] = {"wsdl:session" => @session}
44
- soap.body = {"wsdl:queryString" => query_string}
48
+ soap.namespace = 'http://api.zuora.com/'
49
+ soap.header['wsdl:SessionHeader'] = {'wsdl:session' => @session}
50
+ soap.body = {'wsdl:queryString' => query_string}
45
51
  end.to_hash
46
52
  rescue Savon::SOAPFault => e
47
53
  puts e.message
data/zuora-client.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zuora-client}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Brian McCallister"]
11
+ s.authors = ["Cloocher"]
12
12
  s.date = %q{2010-08-25}
13
13
  s.description = %q{A client for Zuora}
14
- s.email = %q{brianm@ning.com}
14
+ s.email = %q{gene@ning.com}
15
15
  s.executables = ["zuora-client", "zc"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE",
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
- - Brian McCallister
13
+ - Cloocher
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
@@ -51,7 +51,7 @@ dependencies:
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  description: A client for Zuora
54
- email: brianm@ning.com
54
+ email: gene@ning.com
55
55
  executables:
56
56
  - zuora-client
57
57
  - zc