chargify_api_ares 1.4.4 → 1.4.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69aa3faec2b2f60e39558318a569ece38bb66187
4
- data.tar.gz: cb7a28a0c2fc9e08987403d00a129f77fe95956e
3
+ metadata.gz: 517070c73c5b29d20aa4e64911abf29ab10e29a5
4
+ data.tar.gz: 3c43ad57044a7ec35dca4c8ef2880fee801960ad
5
5
  SHA512:
6
- metadata.gz: bef28b56c1a06782277d81435154ab1eb9e920b8dcc31c483d95024ae183e75e3b45b6b44c9a5b63be5a839f9426b81b4fed99b7157bed9eb555e9fdc163597f
7
- data.tar.gz: e3b8d2728765d432d5ef3dde3378af5ab8bfc97b52e28d98b8899917b94d9d3fa99f8e8d86ecd3ab4993d607a4e5b8987160a480102478d40e446be24012276a
6
+ metadata.gz: 631f7b0c2d48cd712c8fdd5a59494b2821e2414ac61d9f94694297626dc78a8b544f8593bbc6a471517cca025b9f78e81a02af525aa66d5f5d5d7917a2773df8
7
+ data.tar.gz: a86e0a7db2d4f7dc0e069860d3f45719aec38abd2c85ec4146e056acb1df5a9dc2279e8e186b901065971b1c4dc8efeba3667493d9c945f09130785a34d23264
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chargify_api_ares (1.4.4)
4
+ chargify_api_ares (1.4.5)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -67,4 +67,4 @@ DEPENDENCIES
67
67
  vcr
68
68
 
69
69
  BUNDLED WITH
70
- 1.11.2
70
+ 1.12.5
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.4.5 / July 14 2016
2
+
3
+ * Adds ability to find pdfs from invoices, show subscription invoices [PR 135] (https://github.com/chargify/chargify_api_ares/pull/135)
4
+
5
+
1
6
  ## 1.4.4 / Jun 3 2016
2
7
 
3
8
  * Adds support for External Payments [PR 128](https://github.com/chargify/chargify_api_ares/pull/128)
@@ -1,11 +1,11 @@
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=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
  s.rubygems_version = '1.3.7'
5
5
 
6
6
  s.name = 'chargify_api_ares'
7
- s.version = '1.4.4'
8
- s.date = '2016-06-03'
7
+ s.version = '1.4.5'
8
+ s.date = '2016-07-14'
9
9
  s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
10
10
  s.description = ''
11
11
  s.authors = ["Chargify Development Team"]
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.4.4)
4
+ chargify_api_ares (1.4.5)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -128,4 +128,4 @@ DEPENDENCIES
128
128
  vcr
129
129
 
130
130
  BUNDLED WITH
131
- 1.11.2
131
+ 1.12.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.4.4)
4
+ chargify_api_ares (1.4.5)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -27,10 +27,10 @@ GEM
27
27
  activemodel (= 4.1.6)
28
28
  activesupport (= 4.1.6)
29
29
  arel (~> 5.0.0)
30
- activeresource (4.0.0)
30
+ activeresource (4.1.0)
31
31
  activemodel (~> 4.0)
32
32
  activesupport (~> 4.0)
33
- rails-observers (~> 0.1.1)
33
+ rails-observers (~> 0.1.2)
34
34
  activesupport (4.1.6)
35
35
  i18n (~> 0.6, >= 0.6.9)
36
36
  json (~> 1.7, >= 1.7.7)
@@ -128,4 +128,4 @@ DEPENDENCIES
128
128
  vcr
129
129
 
130
130
  BUNDLED WITH
131
- 1.11.2
131
+ 1.12.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.4.4)
4
+ chargify_api_ares (1.4.5)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -25,10 +25,10 @@ GEM
25
25
  activesupport (= 4.0.12)
26
26
  arel (~> 4.0.0)
27
27
  activerecord-deprecated_finders (1.0.3)
28
- activeresource (4.0.0)
28
+ activeresource (4.1.0)
29
29
  activemodel (~> 4.0)
30
30
  activesupport (~> 4.0)
31
- rails-observers (~> 0.1.1)
31
+ rails-observers (~> 0.1.2)
32
32
  activesupport (4.0.12)
33
33
  i18n (~> 0.6, >= 0.6.9)
34
34
  minitest (~> 4.2)
@@ -122,4 +122,4 @@ DEPENDENCIES
122
122
  vcr
123
123
 
124
124
  BUNDLED WITH
125
- 1.11.2
125
+ 1.12.5
@@ -16,5 +16,13 @@ module Chargify
16
16
  def self.unpaid
17
17
  find(:all, {:params => {:state => "unpaid"}})
18
18
  end
19
+
20
+ # Returns raw PDF data. Usage example:
21
+ # File.open(file_path, 'wb+'){ |f| f.write Chargify::Invoice.find_pdf(invoice.id) }
22
+ def self.find_pdf(scope, options = {})
23
+ prefix_options, query_options = split_options(options[:params])
24
+ path = element_path(scope, prefix_options, query_options).gsub(/\.\w+$/, ".pdf")
25
+ connection.get(path, headers).body
26
+ end
19
27
  end
20
28
  end
@@ -123,6 +123,17 @@ module Chargify
123
123
  Statement.find(:all, :params => params)
124
124
  end
125
125
 
126
+ def invoices(params = {})
127
+ params.merge!(subscription_id: self.id)
128
+ Invoice.find(:all, params: params)
129
+ end
130
+
131
+ def invoice(id)
132
+ invoice = Chargify::Invoice.find(id)
133
+ raise ActiveResource::ResourceNotFound.new(nil) if (invoice.subscription_id != self.id)
134
+ invoice
135
+ end
136
+
126
137
  def transactions(params = {})
127
138
  params.merge!(:subscription_id => self.id)
128
139
  Transaction.find(:all, :params => params)
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chargify::Invoice, :fake_resource do
4
+
5
+ describe '.find_pdf' do
6
+ before do
7
+ FakeWeb.register_uri(:get, "#{test_domain}/invoices/1.pdf", body: 'fake_pdf')
8
+ end
9
+
10
+ it 'downloads pdf statement' do
11
+ pdf = Chargify::Invoice.find_pdf(1)
12
+ pdf.should == 'fake_pdf'
13
+ end
14
+ end
15
+
16
+ end
@@ -145,4 +145,113 @@ describe Chargify::Subscription, :fake_resource do
145
145
  end
146
146
  end
147
147
  end
148
+
149
+ describe "#statements" do
150
+ let(:subscription_id) {1}
151
+ let(:statements) do
152
+ [{id: 1234}, {id: 5678}]
153
+ end
154
+
155
+ before do
156
+ FakeWeb.register_uri(
157
+ :get,
158
+ "#{test_domain}/subscriptions/#{subscription_id}/statements.xml",
159
+ status: 201,
160
+ body: statements.to_xml
161
+ )
162
+ end
163
+
164
+ it "lists statements" do
165
+ subscription = build(:subscription, id: subscription_id)
166
+ expect(subscription.statements.first.id).to eq(1234)
167
+ expect(subscription.statements.last.id).to eq(5678)
168
+ end
169
+ end
170
+
171
+ describe "#statement" do
172
+ let(:statement_id) {1234}
173
+ let(:subscription_id) {4242}
174
+ let(:statement) do
175
+ {id: statement_id, subscription_id: subscription_id}
176
+ end
177
+
178
+ before do
179
+ FakeWeb.register_uri(
180
+ :get,
181
+ "#{test_domain}/statements/#{statement_id}.xml",
182
+ status: 201,
183
+ body: statement.to_xml
184
+ )
185
+ end
186
+
187
+ it "finds a statement" do
188
+ subscription = build(:subscription, id: subscription_id)
189
+ found = subscription.statement(statement_id)
190
+ expect(found.id).to eql(statement_id)
191
+ expect(found.subscription_id).to eql(subscription_id)
192
+ end
193
+
194
+ context "when attempting to query a statement not under this subscription" do
195
+ it "raises an error" do
196
+ subscription = build(:subscription, id: 9999)
197
+ expect {subscription.statement(statement_id)}.to raise_error(ActiveResource::ResourceNotFound)
198
+ end
199
+ end
200
+ end
201
+
202
+
203
+ describe "#invoices" do
204
+ let(:subscription_id) {1}
205
+ let(:invoices) do
206
+ [{id: 1234}, {id: 5678}]
207
+ end
208
+
209
+ before do
210
+ # Note this uses the invoices endpoint, passing subscription id as a param
211
+ FakeWeb.register_uri(
212
+ :get,
213
+ "#{test_domain}/invoices.xml?subscription_id=#{subscription_id}",
214
+ status: 201,
215
+ body: invoices.to_xml
216
+ )
217
+ end
218
+
219
+ it "lists invoices" do
220
+ subscription = build(:subscription, id: subscription_id)
221
+ expect(subscription.invoices.first.id).to eq(1234)
222
+ expect(subscription.invoices.last.id).to eq(5678)
223
+ end
224
+ end
225
+
226
+ describe "#invoice" do
227
+ let(:invoice_id) {1234}
228
+ let(:subscription_id) {4242}
229
+ let(:invoice) do
230
+ {id: invoice_id, subscription_id: subscription_id}
231
+ end
232
+
233
+ before do
234
+ FakeWeb.register_uri(
235
+ :get,
236
+ "#{test_domain}/invoices/#{invoice_id}.xml",
237
+ status: 201,
238
+ body: invoice.to_xml
239
+ )
240
+ end
241
+
242
+ it "finds an invoice" do
243
+ subscription = build(:subscription, id: subscription_id)
244
+ found = subscription.invoice(invoice_id)
245
+ expect(found.id).to eql(invoice_id)
246
+ expect(found.subscription_id).to eql(subscription_id)
247
+ end
248
+
249
+ context "when attempting to query an invoice not under this subscription" do
250
+ it "raises an error" do
251
+ subscription = build(:subscription, id: 9999)
252
+ expect {subscription.invoice(invoice_id)}.to raise_error(ActiveResource::ResourceNotFound)
253
+ end
254
+ end
255
+ end
256
+
148
257
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargify_api_ares
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chargify Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -233,6 +233,7 @@ files:
233
233
  - spec/resources/customer_metadata_spec.rb
234
234
  - spec/resources/customer_metafield_spec.rb
235
235
  - spec/resources/customer_spec.rb
236
+ - spec/resources/invoice_spec.rb
236
237
  - spec/resources/migration_preview_spec.rb
237
238
  - spec/resources/migration_spec.rb
238
239
  - spec/resources/product_family_component_spec.rb
@@ -266,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
267
  version: '0'
267
268
  requirements: []
268
269
  rubyforge_project:
269
- rubygems_version: 2.2.3
270
+ rubygems_version: 2.4.8
270
271
  signing_key:
271
272
  specification_version: 3
272
273
  summary: A Chargify API wrapper for Ruby using ActiveResource
@@ -286,6 +287,7 @@ test_files:
286
287
  - spec/resources/customer_metadata_spec.rb
287
288
  - spec/resources/customer_metafield_spec.rb
288
289
  - spec/resources/customer_spec.rb
290
+ - spec/resources/invoice_spec.rb
289
291
  - spec/resources/migration_preview_spec.rb
290
292
  - spec/resources/migration_spec.rb
291
293
  - spec/resources/product_family_component_spec.rb