zuora-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.rubocop.yml +22 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +198 -0
- data/Rakefile +7 -0
- data/bin/console +21 -0
- data/bin/setup +7 -0
- data/circle.yml +3 -0
- data/lib/zuora.rb +33 -0
- data/lib/zuora/client.rb +113 -0
- data/lib/zuora/models.rb +10 -0
- data/lib/zuora/models/account.rb +53 -0
- data/lib/zuora/models/card_holder.rb +60 -0
- data/lib/zuora/models/contact.rb +44 -0
- data/lib/zuora/models/payment_method.rb +1 -0
- data/lib/zuora/models/payment_methods/credit_card.rb +37 -0
- data/lib/zuora/models/rate_plan.rb +21 -0
- data/lib/zuora/models/rate_plan_charge.rb +57 -0
- data/lib/zuora/models/subscription.rb +50 -0
- data/lib/zuora/models/tier.rb +27 -0
- data/lib/zuora/models/utils.rb +23 -0
- data/lib/zuora/resources.rb +17 -0
- data/lib/zuora/resources/accounts.rb +19 -0
- data/lib/zuora/resources/payment_methods.rb +1 -0
- data/lib/zuora/resources/payment_methods/credit_card.rb +26 -0
- data/lib/zuora/resources/subscriptions.rb +21 -0
- data/lib/zuora/serializers.rb +1 -0
- data/lib/zuora/serializers/attribute.rb +35 -0
- data/lib/zuora/serializers/noop.rb +18 -0
- data/lib/zuora/version.rb +6 -0
- data/zuora_ruby.gemspec +54 -0
- metadata +333 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Zuora
|
4
|
+
module Resources
|
5
|
+
module Subscriptions
|
6
|
+
RESOURCE_URI = '/rest/v1/subscriptions'
|
7
|
+
|
8
|
+
def self.create!(client, model, serializer = Zuora::Serializers::Noop)
|
9
|
+
Zuora::Resources.with_valid model do |mod|
|
10
|
+
client.post RESOURCE_URI, serializer.serialize(mod)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.update!(client, model, serializer = Zuora::Serializers::Noop)
|
15
|
+
Zuora::Resources.with_valid model do |mod|
|
16
|
+
client.post RESOURCE_URI, serializer.serialize(mod)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'serializers/attribute'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Zuora
|
2
|
+
module Serializers
|
3
|
+
module Attribute
|
4
|
+
# @param [Object] model: An object responding to .attributes
|
5
|
+
# for which each attr can be .send(attr)
|
6
|
+
# @param [Hash] { [String]: lowerCamelCased key =>
|
7
|
+
# [Any]: value }
|
8
|
+
def self.serialize(model)
|
9
|
+
attrs = model.attributes
|
10
|
+
attr_pairs = attrs.map { |attr| serialize_attr model, attr }
|
11
|
+
Hash[attr_pairs]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.serialize_attr(object, attr)
|
17
|
+
# Camelizes the stringified attribute name
|
18
|
+
|
19
|
+
# Note: This specific transformation (lowerCamelCase)
|
20
|
+
# could be passed in; decoupling recursive traversal
|
21
|
+
# from the end-node render / transformation.
|
22
|
+
key = attr.to_s.camelize(:lower)
|
23
|
+
|
24
|
+
# Get current attribute's property
|
25
|
+
val = object.send(attr)
|
26
|
+
|
27
|
+
# Recursively serialize this attribute's
|
28
|
+
# attributes, if they are defined
|
29
|
+
val = serialize val if val.respond_to?(:attributes)
|
30
|
+
|
31
|
+
[key, val]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Zuora
|
2
|
+
module Serializers
|
3
|
+
module Noop
|
4
|
+
def self.serialize(model)
|
5
|
+
attrs = model.attributes
|
6
|
+
attr_pairs = attrs.map { |attr| serialize_attr model, attr }
|
7
|
+
Hash[attr_pairs]
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def self.serialize_attr(object, attr)
|
13
|
+
val = object.send(attr)
|
14
|
+
[attr, val]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/zuora_ruby.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'zuora/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'zuora-ruby'
|
8
|
+
spec.version = Zuora::VERSION
|
9
|
+
spec.authors = ['Contactually Engineering']
|
10
|
+
spec.email = ['engineering@contactually.com']
|
11
|
+
|
12
|
+
spec.summary = 'A Ruby wrapper for Zuora API.'
|
13
|
+
spec.description = 'A Ruby wrapper for Zuora API.'
|
14
|
+
spec.homepage = 'https://github.com'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
fail 'RubyGems 2.0 or newer is required to prevent public gem pushes.'
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = 'exe'
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
# Runtime
|
33
|
+
spec.add_runtime_dependency 'faraday'
|
34
|
+
spec.add_runtime_dependency 'faraday_middleware', '~> 0.10'
|
35
|
+
spec.add_runtime_dependency 'activemodel', '~> 4.2'
|
36
|
+
|
37
|
+
spec.add_runtime_dependency 'active_model_serializers', '~> 0.8'
|
38
|
+
spec.add_runtime_dependency 'activesupport'
|
39
|
+
|
40
|
+
# Development
|
41
|
+
spec.add_development_dependency 'bundler'
|
42
|
+
spec.add_development_dependency 'rake'
|
43
|
+
spec.add_development_dependency 'rspec'
|
44
|
+
spec.add_development_dependency 'rspec-its'
|
45
|
+
spec.add_development_dependency 'byebug'
|
46
|
+
spec.add_development_dependency 'vcr'
|
47
|
+
spec.add_development_dependency 'webmock'
|
48
|
+
spec.add_development_dependency 'dotenv'
|
49
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
50
|
+
spec.add_development_dependency 'rspec_junit_formatter', '0.2.2'
|
51
|
+
spec.add_development_dependency 'rubocop'
|
52
|
+
spec.add_development_dependency 'factory_girl', '~> 4.0'
|
53
|
+
spec.add_development_dependency 'faker'
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,333 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zuora-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Contactually Engineering
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activemodel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: active_model_serializers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-its
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: byebug
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: vcr
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: webmock
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: dotenv
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: codeclimate-test-reporter
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rspec_junit_formatter
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 0.2.2
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - '='
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 0.2.2
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: rubocop
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: factory_girl
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '4.0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '4.0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: faker
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
265
|
+
description: A Ruby wrapper for Zuora API.
|
266
|
+
email:
|
267
|
+
- engineering@contactually.com
|
268
|
+
executables: []
|
269
|
+
extensions: []
|
270
|
+
extra_rdoc_files: []
|
271
|
+
files:
|
272
|
+
- ".gitignore"
|
273
|
+
- ".rspec"
|
274
|
+
- ".rubocop.yml"
|
275
|
+
- ".ruby-version"
|
276
|
+
- CODE_OF_CONDUCT.md
|
277
|
+
- Gemfile
|
278
|
+
- LICENSE.txt
|
279
|
+
- README.md
|
280
|
+
- Rakefile
|
281
|
+
- bin/console
|
282
|
+
- bin/setup
|
283
|
+
- circle.yml
|
284
|
+
- lib/zuora.rb
|
285
|
+
- lib/zuora/client.rb
|
286
|
+
- lib/zuora/models.rb
|
287
|
+
- lib/zuora/models/account.rb
|
288
|
+
- lib/zuora/models/card_holder.rb
|
289
|
+
- lib/zuora/models/contact.rb
|
290
|
+
- lib/zuora/models/payment_method.rb
|
291
|
+
- lib/zuora/models/payment_methods/credit_card.rb
|
292
|
+
- lib/zuora/models/rate_plan.rb
|
293
|
+
- lib/zuora/models/rate_plan_charge.rb
|
294
|
+
- lib/zuora/models/subscription.rb
|
295
|
+
- lib/zuora/models/tier.rb
|
296
|
+
- lib/zuora/models/utils.rb
|
297
|
+
- lib/zuora/resources.rb
|
298
|
+
- lib/zuora/resources/accounts.rb
|
299
|
+
- lib/zuora/resources/payment_methods.rb
|
300
|
+
- lib/zuora/resources/payment_methods/credit_card.rb
|
301
|
+
- lib/zuora/resources/subscriptions.rb
|
302
|
+
- lib/zuora/serializers.rb
|
303
|
+
- lib/zuora/serializers/attribute.rb
|
304
|
+
- lib/zuora/serializers/noop.rb
|
305
|
+
- lib/zuora/version.rb
|
306
|
+
- zuora_ruby.gemspec
|
307
|
+
homepage: https://github.com
|
308
|
+
licenses:
|
309
|
+
- MIT
|
310
|
+
metadata:
|
311
|
+
allowed_push_host: https://rubygems.org
|
312
|
+
post_install_message:
|
313
|
+
rdoc_options: []
|
314
|
+
require_paths:
|
315
|
+
- lib
|
316
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
317
|
+
requirements:
|
318
|
+
- - ">="
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: '0'
|
321
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
322
|
+
requirements:
|
323
|
+
- - ">="
|
324
|
+
- !ruby/object:Gem::Version
|
325
|
+
version: '0'
|
326
|
+
requirements: []
|
327
|
+
rubyforge_project:
|
328
|
+
rubygems_version: 2.4.5.1
|
329
|
+
signing_key:
|
330
|
+
specification_version: 4
|
331
|
+
summary: A Ruby wrapper for Zuora API.
|
332
|
+
test_files: []
|
333
|
+
has_rdoc:
|