chargify_api_ares 1.3.5 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/HISTORY.md +4 -0
- data/README.md +7 -0
- data/chargify_api_ares.gemspec +2 -2
- data/gemfiles/rails_3.gemfile.lock +4 -1
- data/gemfiles/rails_4.1.gemfile.lock +4 -1
- data/gemfiles/rails_4.gemfile.lock +4 -1
- data/lib/chargify_api_ares/resources/migration.rb +0 -13
- data/lib/chargify_api_ares/resources/statement.rb +8 -0
- data/spec/resources/statement_spec.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62367586e39de024a3245e8153701eea9e7dd851
|
4
|
+
data.tar.gz: 37ba219d0657aadc41105b87bde8296b5fc113a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4d9d6fc46fc921fc178c69a88d9e816a67b90546e9b1780e8eb1572d7afddd32446afad673c4878e88510d032c5366c347a14ce56b2b06da55c667ae1c6913
|
7
|
+
data.tar.gz: 4124335f71a4cfca894b5fd58e864926b32ecf4fb7785c3f26de7b7461af249672eb159b9d1155f73eae7202126256ca6ef4449ba8fe720e51d695d1f06db202
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -139,6 +139,13 @@ subscription = Chargify::Subscription.create(
|
|
139
139
|
)
|
140
140
|
```
|
141
141
|
|
142
|
+
### Statements PDF retrieving
|
143
|
+
```ruby
|
144
|
+
File.open(file_path, 'wb+') do |f|
|
145
|
+
f.write Chargify::Statement.find_pdf(statement.id)
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
142
149
|
### Compatibility
|
143
150
|
|
144
151
|
* Rails/ActiveResource 2.3.x, use 0.5.x
|
data/chargify_api_ares.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.7'
|
5
5
|
|
6
6
|
s.name = 'chargify_api_ares'
|
7
|
-
s.version = '1.
|
8
|
-
s.date = '2015-
|
7
|
+
s.version = '1.4.0'
|
8
|
+
s.date = '2015-10-06'
|
9
9
|
s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
|
10
10
|
s.description = ''
|
11
11
|
s.authors = ["Chargify Development Team"]
|
@@ -12,19 +12,6 @@ module Chargify
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
# Chargify returns a non-standard XML error response for Migration. Since the API wants to maintain
|
16
|
-
# backwards compatibility, we will work around that when we parse errors here by overriding the
|
17
|
-
# framework's `load_remote_errors` with our own for just XML
|
18
|
-
def load_remote_errors(remote_errors, save_cache = false)
|
19
|
-
case self.class.format
|
20
|
-
when ActiveResource::Formats[:xml]
|
21
|
-
array = [Hash.from_xml(remote_errors.response.body)["errors"]] rescue []
|
22
|
-
errors.from_array array, save_cache
|
23
|
-
else
|
24
|
-
super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
15
|
class Preview < Base
|
29
16
|
self.prefix = "/subscriptions/:subscription_id/migrations/"
|
30
17
|
|
@@ -1,4 +1,12 @@
|
|
1
1
|
module Chargify
|
2
2
|
class Statement < Base
|
3
|
+
|
4
|
+
# Returns raw PDF data. Usage example:
|
5
|
+
# File.open(file_path, 'wb+'){ |f| f.write Chargify::Statement.find_pdf(statement.id) }
|
6
|
+
def self.find_pdf(scope, options = {})
|
7
|
+
prefix_options, query_options = split_options(options[:params])
|
8
|
+
path = element_path(scope, prefix_options, query_options).gsub(/\.\w+$/, ".pdf")
|
9
|
+
connection.get(path, headers).body
|
10
|
+
end
|
3
11
|
end
|
4
12
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chargify::Statement, :fake_resource do
|
4
|
+
|
5
|
+
context '.find_pdf' do
|
6
|
+
before(:each) do
|
7
|
+
FakeWeb.register_uri(:get, "#{test_domain}/statements/1.pdf", :body => 'fake_pdf')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'downloads pdf statement' do
|
11
|
+
pdf = Chargify::Statement.find_pdf(1)
|
12
|
+
pdf.should == 'fake_pdf'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
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
|
+
version: 1.4.0
|
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: 2015-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- spec/resources/product_family_spec.rb
|
237
237
|
- spec/resources/product_spec.rb
|
238
238
|
- spec/resources/renewal_preview_spec.rb
|
239
|
+
- spec/resources/statement_spec.rb
|
239
240
|
- spec/resources/subscription_component_spec.rb
|
240
241
|
- spec/resources/subscription_metadata_spec.rb
|
241
242
|
- spec/resources/subscription_metafield_spec.rb
|
@@ -287,6 +288,7 @@ test_files:
|
|
287
288
|
- spec/resources/product_family_spec.rb
|
288
289
|
- spec/resources/product_spec.rb
|
289
290
|
- spec/resources/renewal_preview_spec.rb
|
291
|
+
- spec/resources/statement_spec.rb
|
290
292
|
- spec/resources/subscription_component_spec.rb
|
291
293
|
- spec/resources/subscription_metadata_spec.rb
|
292
294
|
- spec/resources/subscription_metafield_spec.rb
|