zuora4r 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +34 -7
- data/Rakefile +2 -2
- data/bin/zuora-create +71 -0
- data/zuora4r.gemspec +4 -3
- metadata +6 -4
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
== zuora4r
|
2
2
|
|
3
3
|
Client for Zuora API
|
4
4
|
|
@@ -6,18 +6,45 @@ 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 run arbitrary
|
9
|
+
It also provides scripts to create Zuora Objects, run arbitrary queries, and make payment & bill runs.
|
10
10
|
|
11
11
|
== Installing the Gem
|
12
12
|
$ sudo gem sources -a http://gemcutter.org
|
13
13
|
$ sudo gem install zuora4r
|
14
14
|
|
15
15
|
== Usage
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
zuora-query -u <username> -p <password> -e [prod|sandbox] <query>
|
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>
|
19
|
+
|
20
|
+
zuora-bill-run -u <username> -p <password> -e [prod|sandbox] -a <account id> -i <invoice date> -t <target date>
|
21
|
+
|
22
|
+
zuora-delete -u <username> -p <password> -e [prod|sandbox] -t [Account|Subscription|Payment|...] -i <id_1,...>
|
23
|
+
|
24
|
+
== Examples
|
25
|
+
export ZUSER=zuora_username
|
26
|
+
export ZPASS=zuora_password
|
27
|
+
|
28
|
+
# create new payment method
|
29
|
+
zuora-create -u $ZUSER -p ZPASS -e sandbox '{"PaymentMethod": {"accountId": "4028e6992a031d78012a1b132dba1c9b", "creditCardAddress1": "52 Vexford Lane", "creditCardCity": "United States", "creditCardExpirationMonth": "12", "creditCardExpirationYear": "2010", "creditCardHolderName": "Firstly Lastly", "creditCardNumber": "4111111111111111", "creditCardPostalCode": "22042", "creditCardState": "California", "creditCardType": "Visa", "type": "CreditCard"}}'
|
30
|
+
[
|
31
|
+
{
|
32
|
+
"success": true,
|
33
|
+
"id": "4028e6992b31191e012b3cf9a3b338c5"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
|
37
|
+
# find all payment methods for a given account
|
38
|
+
zuora-query -u $ZUSER -p $ZPASS -e sandbox "Select Id, CreditCardMaskNumber from PaymentMethod where AccountId = '4028e6992a031d78012a1b132dba1c9b'"
|
39
|
+
[
|
40
|
+
{
|
41
|
+
"creditCardMaskNumber": "************1111",
|
42
|
+
"id": "4028e6992b31191e012b3cf9a3b338c5"
|
43
|
+
},
|
44
|
+
]
|
45
|
+
|
46
|
+
# delete payment method
|
47
|
+
zuora-delete -u $ZUSER -p $ZPASS -e sandbox -t PaymentMethod -i 4028e6992b31191e012b3cf9a3b338c5
|
21
48
|
|
22
49
|
== Copyright
|
23
50
|
|
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.
|
8
|
+
gem.version = "1.0.3"
|
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-bill-run', 'zuora-payment-run', 'zuora-delete', 'zq']
|
18
|
+
gem.executables = ['zuora-query', 'zuora-create', '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-create
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-create -u <username> -p <password> -e [prod|sandbox] <json representing object to create>'
|
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.create([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.
|
8
|
+
s.version = "1.0.3"
|
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-
|
12
|
+
s.date = %q{2010-09-22}
|
13
13
|
s.description = %q{A client for Zuora API}
|
14
14
|
s.email = %q{gene@ning.com}
|
15
|
-
s.executables = ["zuora-query", "zuora-bill-run", "zuora-payment-run", "zuora-delete", "zq"]
|
15
|
+
s.executables = ["zuora-query", "zuora-create", "zuora-bill-run", "zuora-payment-run", "zuora-delete", "zq"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
18
|
"README.rdoc"
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
"Rakefile",
|
22
22
|
"bin/zq",
|
23
23
|
"bin/zuora-bill-run",
|
24
|
+
"bin/zuora-create",
|
24
25
|
"bin/zuora-delete",
|
25
26
|
"bin/zuora-payment-run",
|
26
27
|
"bin/zuora-query",
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
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-
|
18
|
+
date: 2010-09-22 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +54,7 @@ description: A client for Zuora API
|
|
54
54
|
email: gene@ning.com
|
55
55
|
executables:
|
56
56
|
- zuora-query
|
57
|
+
- zuora-create
|
57
58
|
- zuora-bill-run
|
58
59
|
- zuora-payment-run
|
59
60
|
- zuora-delete
|
@@ -67,6 +68,7 @@ files:
|
|
67
68
|
- Rakefile
|
68
69
|
- bin/zq
|
69
70
|
- bin/zuora-bill-run
|
71
|
+
- bin/zuora-create
|
70
72
|
- bin/zuora-delete
|
71
73
|
- bin/zuora-payment-run
|
72
74
|
- bin/zuora-query
|