chargify 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.2.7
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{chargify}
8
- s.version = "0.2.6"
8
+ s.version = "0.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wynn Netherland", "Nash Kabbara"]
12
- s.date = %q{2010-05-27}
12
+ s.date = %q{2010-05-24}
13
13
  s.description = %q{Ruby wrapper for the chargify.com SAAS and billing API}
14
14
  s.email = %q{wynn.netherland@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -185,12 +185,26 @@ module Chargify
185
185
  end
186
186
 
187
187
  def update_subscription_component_allocated_quantity(subscription_id, component_id, quantity)
188
- response = put("/subscriptions/#{subscription_id}/components/#{component_id}.json", :body => {:component => {:allocated_quantity => quantity}})
188
+ update_subscription_component(subscription_id, component_id, :allocated_quantity => quantity)
189
+ end
190
+
191
+ def update_subscription_component_enabled(subscription_id, component_id, enabled)
192
+ update_subscription_component(subscription_id, component_id, :enabled => enabled)
193
+ end
194
+
195
+ def update_subscription_component(subscription_id, component_id, component = {})
196
+ component[:enabled] = (component[:enabled] ? 1 : 0) if component.keys.include?(:enabled)
197
+ response = put("/subscriptions/#{subscription_id}/components/#{component_id}.json",
198
+ :body => {:component => component})
189
199
  response[:success?] = response.code == 200
190
200
  Hashie::Mash.new(response)
191
- end
192
-
193
-
201
+ end
202
+
203
+ alias update_metered_component update_subscription_component_allocated_quantity
204
+ alias update_component_quantity update_subscription_component_allocated_quantity
205
+ alias update_on_off_component update_subscription_component_enabled
206
+ alias update_component update_subscription_component
207
+
194
208
 
195
209
  private
196
210
 
@@ -345,6 +345,55 @@ class ChargifyTest < Test::Unit::TestCase
345
345
  response.success?.should == true
346
346
  end
347
347
  end
348
+
349
+ context "for on/off components" do
350
+ should "update enabled with a 1 for component on" do
351
+ @client.expects(:put).
352
+ with("/subscriptions/123/components/16.json", :body => {:component => {:enabled => 1}}).
353
+ returns(Hashie::Mash.new(:code => 200)).at_most(3)
354
+ @client.update_subscription_component_enabled 123, 16, true
355
+ @client.update_subscription_component_enabled 123, 16, " "
356
+ @client.update_subscription_component_enabled 123, 16, 21
357
+ end
358
+
359
+ should "update enabled with a 0 for component off" do
360
+ @client.expects(:put).
361
+ with("/subscriptions/123/components/16.json", :body => {:component => {:enabled => 0}}).
362
+ returns(Hashie::Mash.new(:code => 200)).at_most(2)
363
+ @client.update_subscription_component_enabled 123, 16, false
364
+ @client.update_subscription_component_enabled 123, 16, nil
365
+ end
366
+
367
+ should "update enabled for a component" do
368
+ stub_put "https://OU812:x@pengwynn.chargify.com/subscriptions/123/components/16.json", "component.json"
369
+ response = @client.update_subscription_component_enabled 123, 16, true
370
+ response.success?.should == true
371
+ end
372
+ end
373
+
374
+ context "aliased methods" do
375
+ setup do
376
+ stub_put "https://OU812:x@pengwynn.chargify.com/subscriptions/123/components/16.json", "component.json"
377
+ end
378
+
379
+ should "expose #update_component" do
380
+ @client.update_component 123, 16, :enabled => true
381
+ @client.update_component 123, 16, :enabled => false
382
+ @client.update_component 123, 16, :funky => 'buttlovin'
383
+ end
384
+
385
+ should "expose #update_on_off_component" do
386
+ @client.update_on_off_component 123, 16, true
387
+ end
388
+
389
+ should "expose #update_component_quantity" do
390
+ @client.update_component_quantity 123, 16, 20_000
391
+ end
392
+
393
+ should "expose #update_metered_component" do
394
+ @client.update_metered_component 123, 16, 20_000
395
+ end
396
+ end
348
397
 
349
398
  end
350
399
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargify
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 25
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 6
9
- version: 0.2.6
9
+ - 7
10
+ version: 0.2.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - Wynn Netherland
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-05-27 00:00:00 -05:00
19
+ date: 2010-05-24 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: hashie
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ~>
27
29
  - !ruby/object:Gem::Version
30
+ hash: 29
28
31
  segments:
29
32
  - 0
30
33
  - 1
@@ -36,9 +39,11 @@ dependencies:
36
39
  name: httparty
37
40
  prerelease: false
38
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
44
  - - ~>
41
45
  - !ruby/object:Gem::Version
46
+ hash: 15
42
47
  segments:
43
48
  - 0
44
49
  - 5
@@ -50,9 +55,11 @@ dependencies:
50
55
  name: shoulda
51
56
  prerelease: false
52
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
53
59
  requirements:
54
60
  - - ">="
55
61
  - !ruby/object:Gem::Version
62
+ hash: 37
56
63
  segments:
57
64
  - 2
58
65
  - 10
@@ -64,9 +71,11 @@ dependencies:
64
71
  name: jnunemaker-matchy
65
72
  prerelease: false
66
73
  requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
67
75
  requirements:
68
76
  - - "="
69
77
  - !ruby/object:Gem::Version
78
+ hash: 15
70
79
  segments:
71
80
  - 0
72
81
  - 4
@@ -78,9 +87,11 @@ dependencies:
78
87
  name: mocha
79
88
  prerelease: false
80
89
  requirement: &id005 !ruby/object:Gem::Requirement
90
+ none: false
81
91
  requirements:
82
92
  - - ~>
83
93
  - !ruby/object:Gem::Version
94
+ hash: 43
84
95
  segments:
85
96
  - 0
86
97
  - 9
@@ -92,9 +103,11 @@ dependencies:
92
103
  name: fakeweb
93
104
  prerelease: false
94
105
  requirement: &id006 !ruby/object:Gem::Requirement
106
+ none: false
95
107
  requirements:
96
108
  - - ">="
97
109
  - !ruby/object:Gem::Version
110
+ hash: 21
98
111
  segments:
99
112
  - 1
100
113
  - 2
@@ -106,9 +119,11 @@ dependencies:
106
119
  name: redgreen
107
120
  prerelease: false
108
121
  requirement: &id007 !ruby/object:Gem::Requirement
122
+ none: false
109
123
  requirements:
110
124
  - - ">="
111
125
  - !ruby/object:Gem::Version
126
+ hash: 27
112
127
  segments:
113
128
  - 1
114
129
  - 2
@@ -158,23 +173,27 @@ rdoc_options:
158
173
  require_paths:
159
174
  - lib
160
175
  required_ruby_version: !ruby/object:Gem::Requirement
176
+ none: false
161
177
  requirements:
162
178
  - - ">="
163
179
  - !ruby/object:Gem::Version
180
+ hash: 3
164
181
  segments:
165
182
  - 0
166
183
  version: "0"
167
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
+ none: false
168
186
  requirements:
169
187
  - - ">="
170
188
  - !ruby/object:Gem::Version
189
+ hash: 3
171
190
  segments:
172
191
  - 0
173
192
  version: "0"
174
193
  requirements: []
175
194
 
176
195
  rubyforge_project:
177
- rubygems_version: 1.3.6
196
+ rubygems_version: 1.5.0
178
197
  signing_key:
179
198
  specification_version: 3
180
199
  summary: Ruby wrapper for the chargify.com SAAS and billing API