chargify2 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,7 +3,9 @@ Chargify API V2 Ruby Wrapper [![build status](https://travis-ci.org/chargify/cha
3
3
 
4
4
  This gem is meant to be used with the [Chargify Direct API](http://docs.chargify.com/chargify-direct-introduction).
5
5
 
6
- You'll need Chargify Direct credentials to interact with the Chargify V2 API, which you can get by [opening a support ticket](http://help.chargify.com/anonymous_requests/new).
6
+ You'll need Chargify Direct credentials to interact with the Chargify V2
7
+ API, which you can get by visiting your site settings page, such as:
8
+ https://your-site-subdomain.chargify.com/settings#chargify-direct
7
9
 
8
10
  Getting Started
9
11
  ---------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -4,11 +4,11 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.6.2'
5
5
 
6
6
  s.name = 'chargify2'
7
- s.version = '0.2.5'
7
+ s.version = '0.2.6'
8
8
  s.date = '2011-10-28'
9
9
  s.summary = %q{Chargify API V2 Ruby Wrapper}
10
10
  s.description = ''
11
- s.authors = ["Michael Klett", "Shay Frendt"]
11
+ s.authors = ["Michael Klett", "Shay Frendt", "Jeremy W. Rowe"]
12
12
  s.email = %q{michael@webadvocate.com}
13
13
  s.homepage = %q{http://github.com/chargify/chargify2}
14
14
  s.licenses = ["MIT"]
@@ -18,7 +18,7 @@ module Chargify2
18
18
  attr_reader :base_uri
19
19
 
20
20
  def initialize(args = {})
21
- options = args.symbolize_keys
21
+ options = args.recursive_symbolize_keys
22
22
 
23
23
  @api_id = options[:api_id]
24
24
  @api_password = options[:api_password]
@@ -37,7 +37,7 @@ module Chargify2
37
37
  attr_reader :secret
38
38
 
39
39
  def initialize(hash, client)
40
- args = hash.symbolize_keys
40
+ args = hash.recursive_symbolize_keys
41
41
 
42
42
  @api_id = client.api_id
43
43
  @secret = client.api_secret
@@ -105,7 +105,7 @@ module Chargify2
105
105
  attr_reader :signature
106
106
 
107
107
  def initialize(params, client)
108
- args = params.symbolize_keys
108
+ args = params.recursive_symbolize_keys
109
109
 
110
110
  @api_id = client.api_id
111
111
  @secret = client.api_secret
@@ -0,0 +1,2 @@
1
+ module Chargify2
2
+ end
@@ -0,0 +1,4 @@
1
+ module Chargify2
2
+ class Representation < Hashie::Trash
3
+ end
4
+ end
@@ -7,13 +7,18 @@ module Chargify2
7
7
  property :success
8
8
  property :request
9
9
  property :response
10
+
11
+ Request = Class.new(Hashery::OpenCascade)
12
+ Response = Class.new(Hashery::OpenCascade)
10
13
 
11
14
  def request
12
- Request[self[:request] || {}]
15
+ h = self[:request] || {}
16
+ Request[h.recursive_symbolize_keys]
13
17
  end
14
18
 
15
19
  def response
16
- Response[self[:response] || {}]
20
+ h = self[:response] || {}
21
+ Response[h.recursive_symbolize_keys]
17
22
  end
18
23
 
19
24
  def successful?
@@ -21,10 +26,8 @@ module Chargify2
21
26
  end
22
27
 
23
28
  def errors
24
- (response.result.errors || []).map {|e| Hashery::OpenCascade[e.symbolize_keys]}
29
+ (response.result.errors || []).map {|e| Hashery::OpenCascade[e.recursive_symbolize_keys]}
25
30
  end
26
31
 
27
- class Request < Hashery::OpenCascade; end
28
- class Response < Hashery::OpenCascade; end
29
32
  end
30
33
  end
@@ -37,7 +37,7 @@ module Chargify2
37
37
  response = get("/#{path}/#{id}", options)
38
38
 
39
39
  response_hash = response[representation.to_s.downcase.split('::').last] || {}
40
- representation.new(response_hash.symbolize_keys)
40
+ representation.new(response_hash.recursive_symbolize_keys)
41
41
  end
42
42
 
43
43
  def read(id, query = {}, options = {})
@@ -1,16 +1,20 @@
1
1
  module Chargify2
2
2
  module Utils
3
3
  module HashExtensions
4
- # Symbolizes keys for flat or nested hashes (operates recursively on nested hashes)
5
- def symbolize_keys
6
- Hash[
7
- self.map { |key, value|
8
- k = key.to_sym
9
- v = value.is_a?(Hash) ? value.symbolize_keys : value
10
- [k,v]
11
- }
12
- ]
4
+ def recursive_symbolize_keys
5
+ self.inject({}){|result, (key, value)|
6
+ new_key = case key
7
+ when String then key.to_sym
8
+ else key
9
+ end
10
+ new_value = case value
11
+ when Hash then value.recursive_symbolize_keys
12
+ else value
13
+ end
14
+ result[new_key] = new_value
15
+ result
16
+ }
13
17
  end
14
18
  end
15
19
  end
16
- end
20
+ end
@@ -45,7 +45,7 @@ module Chargify2
45
45
 
46
46
  sp.timestamp.should == timestamp
47
47
  sp.nonce.should == nonce
48
- sp.data.should == data.symbolize_keys
48
+ sp.data.should == data.recursive_symbolize_keys
49
49
  end
50
50
  end
51
51
 
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe Chargify2::Call do
4
+ subject {
5
+ described_class.new({
6
+ "id" => 12,
7
+ "api_id" => 34,
8
+ "timestamp" => Time.now,
9
+ "nonce" => "sense",
10
+ "success" => true,
11
+ "request" => {
12
+ :foo => "bar",
13
+ "zoo" => "cow",
14
+ },
15
+ :response => {
16
+ "foo" => "bar",
17
+ :zoo => "cow",
18
+ :result => { }
19
+ }
20
+ })
21
+ }
22
+
23
+ # Note: Rspec does weird stuff
24
+ # with opencascade in should comparison
25
+ # hence the locals
26
+
27
+ describe "#request" do
28
+ it "allows dot notation method chaining" do
29
+ foo = subject.request.foo
30
+ zoo = subject.request.zoo
31
+
32
+ expect(foo).to eql("bar")
33
+ expect(zoo).to eql("cow")
34
+ end
35
+ end
36
+
37
+ describe "#response" do
38
+ it "allows dot notation method chaining" do
39
+ foo = subject.response.foo
40
+ zoo = subject.response.zoo
41
+
42
+ expect(foo).to eql("bar")
43
+ expect(zoo).to eql("cow")
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,11 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargify2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Michael Klett
8
9
  - Shay Frendt
10
+ - Jeremy W. Rowe
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
@@ -14,20 +16,23 @@ dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: rack
16
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
17
20
  requirements:
18
- - - '>='
21
+ - - ! '>='
19
22
  - !ruby/object:Gem::Version
20
23
  version: '0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
24
28
  requirements:
25
- - - '>='
29
+ - - ! '>='
26
30
  - !ruby/object:Gem::Version
27
31
  version: '0'
28
32
  - !ruby/object:Gem::Dependency
29
33
  name: hashery
30
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
31
36
  requirements:
32
37
  - - ~>
33
38
  - !ruby/object:Gem::Version
@@ -35,6 +40,7 @@ dependencies:
35
40
  type: :runtime
36
41
  prerelease: false
37
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
38
44
  requirements:
39
45
  - - ~>
40
46
  - !ruby/object:Gem::Version
@@ -42,34 +48,39 @@ dependencies:
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: hashie
44
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
45
52
  requirements:
46
- - - '>='
53
+ - - ! '>='
47
54
  - !ruby/object:Gem::Version
48
55
  version: '0'
49
56
  type: :runtime
50
57
  prerelease: false
51
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
52
60
  requirements:
53
- - - '>='
61
+ - - ! '>='
54
62
  - !ruby/object:Gem::Version
55
63
  version: '0'
56
64
  - !ruby/object:Gem::Dependency
57
65
  name: httparty
58
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
59
68
  requirements:
60
- - - '>='
69
+ - - ! '>='
61
70
  - !ruby/object:Gem::Version
62
71
  version: '0'
63
72
  type: :runtime
64
73
  prerelease: false
65
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
66
76
  requirements:
67
- - - '>='
77
+ - - ! '>='
68
78
  - !ruby/object:Gem::Version
69
79
  version: '0'
70
80
  - !ruby/object:Gem::Dependency
71
81
  name: rake
72
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
73
84
  requirements:
74
85
  - - ~>
75
86
  - !ruby/object:Gem::Version
@@ -77,6 +88,7 @@ dependencies:
77
88
  type: :development
78
89
  prerelease: false
79
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
80
92
  requirements:
81
93
  - - ~>
82
94
  - !ruby/object:Gem::Version
@@ -84,6 +96,7 @@ dependencies:
84
96
  - !ruby/object:Gem::Dependency
85
97
  name: rspec
86
98
  requirement: !ruby/object:Gem::Requirement
99
+ none: false
87
100
  requirements:
88
101
  - - ~>
89
102
  - !ruby/object:Gem::Version
@@ -91,6 +104,7 @@ dependencies:
91
104
  type: :development
92
105
  prerelease: false
93
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
94
108
  requirements:
95
109
  - - ~>
96
110
  - !ruby/object:Gem::Version
@@ -98,48 +112,55 @@ dependencies:
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: capybara
100
114
  requirement: !ruby/object:Gem::Requirement
115
+ none: false
101
116
  requirements:
102
- - - '>='
117
+ - - ! '>='
103
118
  - !ruby/object:Gem::Version
104
119
  version: '0'
105
120
  type: :development
106
121
  prerelease: false
107
122
  version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
108
124
  requirements:
109
- - - '>='
125
+ - - ! '>='
110
126
  - !ruby/object:Gem::Version
111
127
  version: '0'
112
128
  - !ruby/object:Gem::Dependency
113
129
  name: vcr
114
130
  requirement: !ruby/object:Gem::Requirement
131
+ none: false
115
132
  requirements:
116
- - - '>='
133
+ - - ! '>='
117
134
  - !ruby/object:Gem::Version
118
135
  version: '0'
119
136
  type: :development
120
137
  prerelease: false
121
138
  version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
122
140
  requirements:
123
- - - '>='
141
+ - - ! '>='
124
142
  - !ruby/object:Gem::Version
125
143
  version: '0'
126
144
  - !ruby/object:Gem::Dependency
127
145
  name: webmock
128
146
  requirement: !ruby/object:Gem::Requirement
147
+ none: false
129
148
  requirements:
130
- - - '>='
149
+ - - ! '>='
131
150
  - !ruby/object:Gem::Version
132
151
  version: '0'
133
152
  type: :development
134
153
  prerelease: false
135
154
  version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
136
156
  requirements:
137
- - - '>='
157
+ - - ! '>='
138
158
  - !ruby/object:Gem::Version
139
159
  version: '0'
140
160
  - !ruby/object:Gem::Dependency
141
161
  name: yard
142
162
  requirement: !ruby/object:Gem::Requirement
163
+ none: false
143
164
  requirements:
144
165
  - - ~>
145
166
  - !ruby/object:Gem::Version
@@ -147,6 +168,7 @@ dependencies:
147
168
  type: :development
148
169
  prerelease: false
149
170
  version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
150
172
  requirements:
151
173
  - - ~>
152
174
  - !ruby/object:Gem::Version
@@ -171,6 +193,8 @@ files:
171
193
  - lib/chargify2.rb
172
194
  - lib/chargify2/client.rb
173
195
  - lib/chargify2/direct.rb
196
+ - lib/chargify2/helpers.rb
197
+ - lib/chargify2/representation.rb
174
198
  - lib/chargify2/representations/call.rb
175
199
  - lib/chargify2/resource.rb
176
200
  - lib/chargify2/resources/call_resource.rb
@@ -180,29 +204,31 @@ files:
180
204
  - spec/direct_response_parameters_spec.rb
181
205
  - spec/direct_secure_parameters_spec.rb
182
206
  - spec/direct_spec.rb
207
+ - spec/representations/call_spec.rb
183
208
  - spec/spec_helper.rb
184
209
  - spec/support/spec_helper_methods.rb
185
210
  homepage: http://github.com/chargify/chargify2
186
211
  licenses:
187
212
  - MIT
188
- metadata: {}
189
213
  post_install_message:
190
214
  rdoc_options: []
191
215
  require_paths:
192
216
  - lib
193
217
  required_ruby_version: !ruby/object:Gem::Requirement
218
+ none: false
194
219
  requirements:
195
- - - '>='
220
+ - - ! '>='
196
221
  - !ruby/object:Gem::Version
197
222
  version: '0'
198
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
+ none: false
199
225
  requirements:
200
- - - '>='
226
+ - - ! '>='
201
227
  - !ruby/object:Gem::Version
202
228
  version: '0'
203
229
  requirements: []
204
230
  rubyforge_project:
205
- rubygems_version: 2.0.0
231
+ rubygems_version: 1.8.23
206
232
  signing_key:
207
233
  specification_version: 3
208
234
  summary: Chargify API V2 Ruby Wrapper
@@ -212,6 +238,7 @@ test_files:
212
238
  - spec/direct_response_parameters_spec.rb
213
239
  - spec/direct_secure_parameters_spec.rb
214
240
  - spec/direct_spec.rb
241
+ - spec/representations/call_spec.rb
215
242
  - spec/spec_helper.rb
216
243
  - spec/support/spec_helper_methods.rb
217
244
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 6920a74f0ebd8aa7b4fd70ed631e84bffcb8a90f
4
- data.tar.gz: c038127114e6c5175c39e09713a49af4371dcf21
5
- SHA512:
6
- metadata.gz: 07f2e1f040ff64ae1c4537e5a7cf00cd32d5561b513f1493cd9b40805787e8c84a9563424f59f513050ac0ab5be6da991ab8ab0a833a9052e59903e349571cbe
7
- data.tar.gz: 0da07436757d5d32df2d153b5c16e677d5a6360acf43ac1d0235d4b63fc16a53749179940ddf4a4475ab2fcbb565a208f9da8db4ce06e56aa7fb6ee38cc4ec73