zuora4r 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +31 -3
  2. data/Rakefile +2 -2
  3. data/bin/zuora-update +71 -0
  4. data/zuora4r.gemspec +4 -3
  5. metadata +6 -4
data/README.rdoc CHANGED
@@ -6,7 +6,7 @@ This is a wrapper for sample code provided by {Zuora}[http://developer.zuora.com
6
6
 
7
7
  It contains minor changes as well as added support for 'generate' API call
8
8
 
9
- It also provides scripts to create Zuora Objects, run arbitrary queries, and make payment & bill runs.
9
+ It also provides scripts to query, create, update, delete Zuora Objects, as well as make payment & bill runs.
10
10
 
11
11
  == Installing the Gem
12
12
  $ sudo gem sources -a http://gemcutter.org
@@ -15,12 +15,16 @@ It also provides scripts to create Zuora Objects, run arbitrary queries, and mak
15
15
  == Usage
16
16
  zuora-query -u <username> -p <password> -e [prod|sandbox] <query>
17
17
 
18
- zuora-payment-run -u <username> -p <password> -e [prod|sandbox] -a <account id> -i <invoice id> -d <effective date> -m <payment method id>
18
+ zuora-create -u <username> -p <password> -e [prod|sandbox] <json representing object to create>
19
19
 
20
- zuora-bill-run -u <username> -p <password> -e [prod|sandbox] -a <account id> -i <invoice date> -t <target date>
20
+ zuora-update -u <username> -p <password> -e [prod|sandbox] <json representing object to update>
21
21
 
22
22
  zuora-delete -u <username> -p <password> -e [prod|sandbox] -t [Account|Subscription|Payment|...] -i <id_1,...>
23
23
 
24
+ zuora-payment-run -u <username> -p <password> -e [prod|sandbox] -a <account id> -i <invoice id> -d <effective date> -m <payment method id>
25
+
26
+ zuora-bill-run -u <username> -p <password> -e [prod|sandbox] -a <account id> -i <invoice date> -t <target date>
27
+
24
28
  == Examples
25
29
  export ZUSER=zuora_username
26
30
  export ZPASS=zuora_password
@@ -43,8 +47,32 @@ It also provides scripts to create Zuora Objects, run arbitrary queries, and mak
43
47
  },
44
48
  ]
45
49
 
50
+ # make above added payment method to be default for the account
51
+ zuora-update -u $ZUSER -p $ZPASS -e sandbox '{"Account": {"id": "4028e6992a031d78012a1b132dba1c9b", "defaultPaymentMethodId": "4028e6992b31191e012b3cf9a3b338c5"}}'
52
+ [
53
+ {
54
+ "success": true,
55
+ "id": "4028e6992a031d78012a1b132dba1c9b"
56
+ }
57
+ ]
58
+
59
+ # check account's default payment method
60
+ zuora-query -u $ZUSER -p $ZPASS -e sandbox "Select DefaultPaymentMethodId from Account where Id = '4028e6992a031d78012a1b132dba1c9b'"
61
+ [
62
+ {
63
+ "defaultPaymentMethodId": "4028e6992b31191e012b3cf9a3b338c5"
64
+ }
65
+ ]
66
+
46
67
  # delete payment method
47
68
  zuora-delete -u $ZUSER -p $ZPASS -e sandbox -t PaymentMethod -i 4028e6992b31191e012b3cf9a3b338c5
69
+ [
70
+ {
71
+ "success": true,
72
+ "id": "4028e6992b31191e012b3cf9a3b338c5"
73
+ }
74
+ ]
75
+
48
76
 
49
77
  == Copyright
50
78
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "zuora4r"
8
- gem.version = "1.0.3"
8
+ gem.version = "1.0.4"
9
9
  gem.summary = "Zuora4r"
10
10
  gem.description = "A client for Zuora API"
11
11
  gem.email = "gene@ning.com"
@@ -15,7 +15,7 @@ begin
15
15
  "lib/**/*", "bin/**/*"]
16
16
  gem.add_dependency "soap4r", ">= 1.5.8"
17
17
  gem.add_dependency "json_pure", ">= 1.4.6"
18
- gem.executables = ['zuora-query', 'zuora-create', 'zuora-bill-run', 'zuora-payment-run', 'zuora-delete', 'zq']
18
+ gem.executables = ['zuora-query', 'zuora-create', 'zuora-update', 'zuora-bill-run', 'zuora-payment-run', 'zuora-delete', 'zq']
19
19
  gem.requirements = ["none"]
20
20
  gem.bindir = "bin"
21
21
  end
data/bin/zuora-update ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright 2010 Ning
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), 'lib'))
18
+
19
+ require 'rubygems'
20
+ require 'optparse'
21
+ require 'json/pure'
22
+ require 'zuora_client'
23
+
24
+ username = nil
25
+ password = nil
26
+ environment = 'prod'
27
+
28
+ opts = OptionParser.new do |opts|
29
+ opts.banner = 'Usage: zuora-update -u <username> -p <password> -e [prod|sandbox] <json representing object to update>'
30
+ opts.on('-u', '--user USERNAME', 'username') { |u| username = u }
31
+ opts.on('-p', '--pass PASSWORD', 'password') { |p| password = p }
32
+ opts.on('-e', '--env ENVIRONMENT', '[prod|sandbox] (default: prod)') { |e| environment = e }
33
+ opts.on('-v', '--verbose', 'log harder') { $ZUORA_VERBOSE = true }
34
+ end
35
+
36
+ if ARGV.empty?
37
+ puts opts
38
+ exit
39
+ end
40
+
41
+ remainder = opts.parse!(ARGV)
42
+ json_string = remainder.join ' '
43
+
44
+ unless username and password
45
+ puts opts
46
+ exit 1
47
+ end
48
+
49
+ url = case environment.downcase
50
+ when 'sandbox'
51
+ ZuoraClient::SANDBOX_URL
52
+ else
53
+ ZuoraClient::PROD_URL
54
+ end
55
+
56
+ zuora_client = ZuoraClient.new(username, password, url)
57
+
58
+ hash = JSON(json_string)
59
+
60
+ type = hash.keys.first
61
+
62
+ obj = Object.const_get('ZUORA').const_get(type).new
63
+
64
+ hash[type].each do |name, value|
65
+ setter = "#{name}=".to_sym
66
+ obj.send(setter, value)
67
+ end
68
+
69
+ result = zuora_client.update([obj])
70
+
71
+ puts JSON.pretty_generate(result) if result
data/zuora4r.gemspec CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zuora4r}
8
- s.version = "1.0.3"
8
+ s.version = "1.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cloocher"]
12
- s.date = %q{2010-09-22}
12
+ s.date = %q{2010-09-23}
13
13
  s.description = %q{A client for Zuora API}
14
14
  s.email = %q{gene@ning.com}
15
- s.executables = ["zuora-query", "zuora-create", "zuora-bill-run", "zuora-payment-run", "zuora-delete", "zq"]
15
+ s.executables = ["zuora-query", "zuora-create", "zuora-update", "zuora-bill-run", "zuora-payment-run", "zuora-delete", "zq"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE",
18
18
  "README.rdoc"
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "bin/zuora-delete",
26
26
  "bin/zuora-payment-run",
27
27
  "bin/zuora-query",
28
+ "bin/zuora-update",
28
29
  "lib/zuora/ZUORA.rb",
29
30
  "lib/zuora/ZUORADriver.rb",
30
31
  "lib/zuora/ZUORAMappingRegistry.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora4r
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 3
10
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Cloocher
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-22 00:00:00 -07:00
18
+ date: 2010-09-23 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,7 @@ email: gene@ning.com
55
55
  executables:
56
56
  - zuora-query
57
57
  - zuora-create
58
+ - zuora-update
58
59
  - zuora-bill-run
59
60
  - zuora-payment-run
60
61
  - zuora-delete
@@ -72,6 +73,7 @@ files:
72
73
  - bin/zuora-delete
73
74
  - bin/zuora-payment-run
74
75
  - bin/zuora-query
76
+ - bin/zuora-update
75
77
  - lib/zuora/ZUORA.rb
76
78
  - lib/zuora/ZUORADriver.rb
77
79
  - lib/zuora/ZUORAMappingRegistry.rb