chargify_api_ares 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d122946e163261c491583b731f6ea5a573c33df
4
+ data.tar.gz: e125acbd900516438a642d6c36d72def8c1072f1
5
+ SHA512:
6
+ metadata.gz: f9e8fc0a59ff6bd917e2d7f65ee4a775d7f403c132378ad722bfb297f4907a686497d96b5dde261867cc6714134d549848bca5a07080100b0d8bceee34f6dfcf
7
+ data.tar.gz: 3f8a78dbb9a25403c828b6dfdd5e283bcd3a2c14b6b3170b23c7c0b160d5e6986a8bd6204e48354ed09c0b74d6b4c5f84422c7df9e5731ad99a963de04d69e65
data/README.md CHANGED
@@ -75,8 +75,8 @@ following. Please note that this step is required.
75
75
 
76
76
  Now you'll have access to classes the interact with the Chargify API, such as:
77
77
 
78
- * `Chargify::Product`
79
- * `Chargify::Customer`
78
+ * `Chargify::Product`
79
+ * `Chargify::Customer`
80
80
  * `Chargify::Subscription`
81
81
 
82
82
  It allows you to interface with the Chargify API using simple ActiveRecord-like syntax, i.e.:
@@ -197,3 +197,7 @@ sure someone already hasn't requested it and/or contributed it
197
197
  fine, but please isolate it to its own commit so we can cherry-pick
198
198
  around it.
199
199
 
200
+ ### Contributors
201
+
202
+ We would like to publicly thank [everyone who has contributed](https://github.com/chargify/chargify_api_ares/graphs/contributors) their time
203
+ and talents to developing this gem. Thank you!
@@ -1,16 +1,16 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.specification_version = 3 if s.respond_to? :specification_version=
3
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
- s.rubygems_version = '1.3.7'
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+ s.rubygems_version = '1.3.7'
5
5
 
6
- s.name = 'chargify_api_ares'
7
- s.version = '1.3.4'
8
- s.date = '2015-05-14'
9
- s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
6
+ s.name = 'chargify_api_ares'
7
+ s.version = '1.3.5'
8
+ s.date = '2015-08-12'
9
+ s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
10
10
  s.description = ''
11
- s.authors = ["Michael Klett", "Nathan Verni", "Eric Farkas", "Wendy Smoak"]
12
- s.email = 'support@chargify.com'
13
- s.homepage = 'http://github.com/chargify/chargify_api_ares'
11
+ s.authors = ["Chargify Development Team"]
12
+ s.email = 'dev@chargify.com'
13
+ s.homepage = 'http://github.com/chargify/chargify_api_ares'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/examples/metadata.rb CHANGED
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  subscription = Chargify::Subscription.last
9
9
 
10
- ## Listing all of your customer metafields
10
+ ## Listing all of this subscription's metadata
11
11
  metadata = subscription.metadata
12
12
  # => [#<Chargify::SubscriptionMetadata resource_id: 22, current_name: favorite color, name: favorite color, value: red>]
13
13
 
@@ -56,3 +56,12 @@ data.persisted? # => true
56
56
 
57
57
  data
58
58
  # => #<Chargify::SubscriptionMetadata resource_id: 22, current_name: job 1234, name: job 1234, value: 2014-08-21 02:10:46 UTC>
59
+
60
+ ##### Customer Metadata
61
+
62
+ customer = Chargify::Customer.last
63
+
64
+ ## Listing all of this customer's metadata
65
+ metadata = customer.metadata
66
+
67
+ # See above examples for subscription metadata; the same methods are available
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.3.3)
4
+ chargify_api_ares (1.3.4)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.3.3)
4
+ chargify_api_ares (1.3.4)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.3.3)
4
+ chargify_api_ares (1.3.4)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -8,6 +8,7 @@ require 'chargify_api_ares/resources/base'
8
8
  require 'chargify_api_ares/resources/charge'
9
9
  require 'chargify_api_ares/resources/component'
10
10
  require 'chargify_api_ares/resources/coupon'
11
+ require 'chargify_api_ares/resources/customer_metadata'
11
12
  require 'chargify_api_ares/resources/customer'
12
13
  require 'chargify_api_ares/resources/event'
13
14
  require 'chargify_api_ares/resources/migration'
@@ -19,5 +19,18 @@ module Chargify
19
19
  params.merge!({:customer_id => self.id})
20
20
  PaymentProfile.find(:all, :params => params)
21
21
  end
22
+
23
+ def build_metadata(params = {})
24
+ CustomerMetadata.new(params.reverse_merge({:resource_id => self.id}))
25
+ end
26
+
27
+ def create_metadata(params = {})
28
+ CustomerMetadata.create(params.reverse_merge({:resource_id => self.id}))
29
+ end
30
+
31
+ def metadata(params={})
32
+ params.merge!({:resource_id => self.id})
33
+ CustomerMetadata.find(:all, :params => params)
34
+ end
22
35
  end
23
36
  end
@@ -0,0 +1,17 @@
1
+ module Chargify
2
+ class CustomerMetadata < Base
3
+ include ::Chargify::Behaviors::Inspectable
4
+ include ::Chargify::Behaviors::Metadata
5
+
6
+ self.inspect_class = "resource_id: integer, current_name: string, name: string, value: string"
7
+ self.inspect_instance = Proc.new { |s| [[:resource_id, s.prefix_options[:resource_id]], [:current_name, s.current_name], [:name, s.name], [:value, s.value]] }
8
+ self.prefix = '/customers/:resource_id/'
9
+ self.endpoint_name = 'metadata'
10
+
11
+ schema do
12
+ attribute 'current_name', :string
13
+ attribute 'name', :string
14
+ attribute 'value', :string
15
+ end
16
+ end
17
+ end
@@ -768,6 +768,7 @@ describe "Remote" do
768
768
  context "metadata" do
769
769
  before { subscription_to_pro }
770
770
  let(:subscription) { Chargify::Subscription.last }
771
+ let(:customer) { Chargify::Customer.last }
771
772
 
772
773
  describe 'listing metadata for a subscription' do
773
774
  it 'returns a list of metadata' do
@@ -776,7 +777,7 @@ describe "Remote" do
776
777
  end
777
778
  end
778
779
 
779
- describe 'creating a piece of metadata' do
780
+ describe 'creating a piece of subscription metadata' do
780
781
  it 'can create a new metadata' do
781
782
  data = subscription.create_metadata(:name => 'favorite color', :value => 'red')
782
783
 
@@ -789,6 +790,27 @@ describe "Remote" do
789
790
  expect(list).to include(data)
790
791
  end
791
792
  end
793
+
794
+ describe 'listing metadata for a customer' do
795
+ it 'returns a list of metadata' do
796
+ list = customer.metadata
797
+ expect(list).to eql([])
798
+ end
799
+ end
800
+
801
+ describe 'creating a piece of customer metadata' do
802
+ it 'can create a new metadata' do
803
+ data = customer.create_metadata(:name => 'favorite color', :value => 'blue')
804
+
805
+ expect(data).to be_persisted
806
+ expect(data.name).to eql('favorite color')
807
+ expect(data.value).to eql('blue')
808
+
809
+ list = customer.metadata
810
+ expect(list.size).to eql(1)
811
+ expect(list).to include(data)
812
+ end
813
+ end
792
814
  end
793
815
 
794
816
  def clear_site_data
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chargify::CustomerMetadata do
4
+
5
+ describe '.inspect' do
6
+ specify { expect(described_class.inspect).to eql("Chargify::CustomerMetadata(resource_id: integer, current_name: string, name: string, value: string)") }
7
+ end
8
+
9
+ describe "#inspect" do
10
+ its(:inspect) { should eql("#<Chargify::CustomerMetadata resource_id: nil, current_name: nil, name: nil, value: nil>") }
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,189 +1,165 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargify_api_ares
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
5
- prerelease:
4
+ version: 1.3.5
6
5
  platform: ruby
7
6
  authors:
8
- - Michael Klett
9
- - Nathan Verni
10
- - Eric Farkas
11
- - Wendy Smoak
7
+ - Chargify Development Team
12
8
  autorequire:
13
9
  bindir: bin
14
10
  cert_chain: []
15
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2015-08-12 00:00:00.000000000 Z
16
12
  dependencies:
17
13
  - !ruby/object:Gem::Dependency
18
14
  name: activeresource
19
15
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
16
  requirements:
22
- - - ! '>='
17
+ - - ">="
23
18
  - !ruby/object:Gem::Version
24
19
  version: 3.2.16
25
20
  type: :runtime
26
21
  prerelease: false
27
22
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
23
  requirements:
30
- - - ! '>='
24
+ - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: 3.2.16
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
29
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
30
  requirements:
38
- - - ~>
31
+ - - "~>"
39
32
  - !ruby/object:Gem::Version
40
33
  version: 10.0.3
41
34
  type: :development
42
35
  prerelease: false
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
37
  requirements:
46
- - - ~>
38
+ - - "~>"
47
39
  - !ruby/object:Gem::Version
48
40
  version: 10.0.3
49
41
  - !ruby/object:Gem::Dependency
50
42
  name: rspec
51
43
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
44
  requirements:
54
- - - ~>
45
+ - - "~>"
55
46
  - !ruby/object:Gem::Version
56
47
  version: 2.12.0
57
48
  type: :development
58
49
  prerelease: false
59
50
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
51
  requirements:
62
- - - ~>
52
+ - - "~>"
63
53
  - !ruby/object:Gem::Version
64
54
  version: 2.12.0
65
55
  - !ruby/object:Gem::Dependency
66
56
  name: factory_girl
67
57
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
58
  requirements:
70
- - - ~>
59
+ - - "~>"
71
60
  - !ruby/object:Gem::Version
72
61
  version: '2.6'
73
62
  type: :development
74
63
  prerelease: false
75
64
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
65
  requirements:
78
- - - ~>
66
+ - - "~>"
79
67
  - !ruby/object:Gem::Version
80
68
  version: '2.6'
81
69
  - !ruby/object:Gem::Dependency
82
70
  name: fakeweb
83
71
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
72
  requirements:
86
- - - ~>
73
+ - - "~>"
87
74
  - !ruby/object:Gem::Version
88
75
  version: 1.3.0
89
76
  type: :development
90
77
  prerelease: false
91
78
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
79
  requirements:
94
- - - ~>
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: 1.3.0
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: faker
99
85
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
86
  requirements:
102
- - - ~>
87
+ - - "~>"
103
88
  - !ruby/object:Gem::Version
104
89
  version: 1.1.2
105
90
  type: :development
106
91
  prerelease: false
107
92
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
93
  requirements:
110
- - - ~>
94
+ - - "~>"
111
95
  - !ruby/object:Gem::Version
112
96
  version: 1.1.2
113
97
  - !ruby/object:Gem::Dependency
114
98
  name: pry
115
99
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
100
  requirements:
118
- - - ! '>='
101
+ - - ">="
119
102
  - !ruby/object:Gem::Version
120
103
  version: '0'
121
104
  type: :development
122
105
  prerelease: false
123
106
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
107
  requirements:
126
- - - ! '>='
108
+ - - ">="
127
109
  - !ruby/object:Gem::Version
128
110
  version: '0'
129
111
  - !ruby/object:Gem::Dependency
130
112
  name: vcr
131
113
  requirement: !ruby/object:Gem::Requirement
132
- none: false
133
114
  requirements:
134
- - - ! '>='
115
+ - - ">="
135
116
  - !ruby/object:Gem::Version
136
117
  version: '0'
137
118
  type: :development
138
119
  prerelease: false
139
120
  version_requirements: !ruby/object:Gem::Requirement
140
- none: false
141
121
  requirements:
142
- - - ! '>='
122
+ - - ">="
143
123
  - !ruby/object:Gem::Version
144
124
  version: '0'
145
125
  - !ruby/object:Gem::Dependency
146
126
  name: dotenv
147
127
  requirement: !ruby/object:Gem::Requirement
148
- none: false
149
128
  requirements:
150
- - - ! '>='
129
+ - - ">="
151
130
  - !ruby/object:Gem::Version
152
131
  version: '0'
153
132
  type: :development
154
133
  prerelease: false
155
134
  version_requirements: !ruby/object:Gem::Requirement
156
- none: false
157
135
  requirements:
158
- - - ! '>='
136
+ - - ">="
159
137
  - !ruby/object:Gem::Version
160
138
  version: '0'
161
139
  - !ruby/object:Gem::Dependency
162
140
  name: appraisal
163
141
  requirement: !ruby/object:Gem::Requirement
164
- none: false
165
142
  requirements:
166
- - - ! '>='
143
+ - - ">="
167
144
  - !ruby/object:Gem::Version
168
145
  version: '0'
169
146
  type: :development
170
147
  prerelease: false
171
148
  version_requirements: !ruby/object:Gem::Requirement
172
- none: false
173
149
  requirements:
174
- - - ! '>='
150
+ - - ">="
175
151
  - !ruby/object:Gem::Version
176
152
  version: '0'
177
153
  description: ''
178
- email: support@chargify.com
154
+ email: dev@chargify.com
179
155
  executables: []
180
156
  extensions: []
181
157
  extra_rdoc_files: []
182
158
  files:
183
- - .env
184
- - .gitignore
185
- - .rspec
186
- - .travis.yml
159
+ - ".env"
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
187
163
  - Appraisals
188
164
  - Gemfile
189
165
  - Gemfile.lock
@@ -221,6 +197,7 @@ files:
221
197
  - lib/chargify_api_ares/resources/component.rb
222
198
  - lib/chargify_api_ares/resources/coupon.rb
223
199
  - lib/chargify_api_ares/resources/customer.rb
200
+ - lib/chargify_api_ares/resources/customer_metadata.rb
224
201
  - lib/chargify_api_ares/resources/customer_metafield.rb
225
202
  - lib/chargify_api_ares/resources/event.rb
226
203
  - lib/chargify_api_ares/resources/invoice.rb
@@ -250,6 +227,7 @@ files:
250
227
  - spec/resources/base_spec.rb
251
228
  - spec/resources/charge_spec.rb
252
229
  - spec/resources/coupon_spec.rb
230
+ - spec/resources/customer_metadata_spec.rb
253
231
  - spec/resources/customer_metafield_spec.rb
254
232
  - spec/resources/customer_spec.rb
255
233
  - spec/resources/migration_preview_spec.rb
@@ -267,25 +245,24 @@ files:
267
245
  - spec/support/fake_resource.rb
268
246
  homepage: http://github.com/chargify/chargify_api_ares
269
247
  licenses: []
248
+ metadata: {}
270
249
  post_install_message:
271
250
  rdoc_options: []
272
251
  require_paths:
273
252
  - lib
274
253
  required_ruby_version: !ruby/object:Gem::Requirement
275
- none: false
276
254
  requirements:
277
- - - ! '>='
255
+ - - ">="
278
256
  - !ruby/object:Gem::Version
279
257
  version: '0'
280
258
  required_rubygems_version: !ruby/object:Gem::Requirement
281
- none: false
282
259
  requirements:
283
- - - ! '>='
260
+ - - ">="
284
261
  - !ruby/object:Gem::Version
285
262
  version: '0'
286
263
  requirements: []
287
264
  rubyforge_project:
288
- rubygems_version: 1.8.23
265
+ rubygems_version: 2.2.3
289
266
  signing_key:
290
267
  specification_version: 3
291
268
  summary: A Chargify API wrapper for Ruby using ActiveResource
@@ -301,6 +278,7 @@ test_files:
301
278
  - spec/resources/base_spec.rb
302
279
  - spec/resources/charge_spec.rb
303
280
  - spec/resources/coupon_spec.rb
281
+ - spec/resources/customer_metadata_spec.rb
304
282
  - spec/resources/customer_metafield_spec.rb
305
283
  - spec/resources/customer_spec.rb
306
284
  - spec/resources/migration_preview_spec.rb
@@ -316,4 +294,3 @@ test_files:
316
294
  - spec/resources/usage_spec.rb
317
295
  - spec/spec_helper.rb
318
296
  - spec/support/fake_resource.rb
319
- has_rdoc: