chargify_api_ares 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcbd78797c225cef3292433dc0e2bb4d945d15a8
4
- data.tar.gz: ffd3b68cc14dc3fabbc3e565c40221b25054d646
3
+ metadata.gz: 3b4fea9191725abc5d611228e64fc1d1c73e85f9
4
+ data.tar.gz: b9d5ff10e502d79443298f550a39abce9fca60e4
5
5
  SHA512:
6
- metadata.gz: 839fd752a315359cda9cfdb113db5bc2f38c2000523d997cc138c87778d4db199c9ad68655d1a7cd768f2d2177766991f05bb4555140f3370b3baa832e6fb2b1
7
- data.tar.gz: 824899b30d8ba53ad8d5aa20d87c6a9dd106d3fe4786fbde563d627d6324281633a9571df19c62b376f11de25bf379a75b507b06ad6a4598bfe279d92a0cca4c
6
+ metadata.gz: f087abf32692cdcd9fd417a549f9521dd5fb1f32cc83cddff01209928bd518e78eb5ca5eae237802916d2b9f3a5d403fa15859af3f2a57bc1a6014f41f1e8ee6
7
+ data.tar.gz: 04218486fb72dcede36967a1bf49a677203387ee896209149e6d9f944ead7f12e2bf57e1f2c4e020323e3b9910cd40cb04d69ab51c5ab527c09289bd1b9ecc9a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chargify_api_ares (1.4.2)
4
+ chargify_api_ares (1.4.3)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.4.3 / Jan 5 2016
2
+
3
+ * Force json format for bulk allocations endpoints [PR 126](https://github.com/chargify/chargify_api_ares/pull/126) by @ryansch
4
+
1
5
  ## 1.4.2 / Jan 4 2016
2
6
 
3
7
  * Adds `Chargify::Allocations.bulk_create` to work with https://docs.chargify.com/api-allocations#create-multiple-allocations. [PR 125](https://github.com/chargify/chargify_api_ares/pull/125) by @ryansch
@@ -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.4.2'
8
- s.date = '2016-01-04'
7
+ s.version = '1.4.3'
8
+ s.date = '2016-01-05'
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.2)
4
+ chargify_api_ares (1.4.3)
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.4.2)
4
+ chargify_api_ares (1.4.3)
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.4.2)
4
+ chargify_api_ares (1.4.3)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -15,12 +15,26 @@ module Chargify
15
15
  subscription_id = opts.delete(:subscription_id)
16
16
  raise ArgumentError, 'subscription_id required' if subscription_id.nil?
17
17
 
18
- response = connection.post(
19
- bulk_create_prefix(subscription_id: subscription_id),
20
- format.encode(opts),
21
- headers
22
- )
23
- instantiate_collection(format.decode(response.body))
18
+ with_json_format do |format|
19
+ response = connection.post(
20
+ bulk_create_prefix(subscription_id: subscription_id),
21
+ format.encode(opts),
22
+ headers
23
+ )
24
+ instantiate_collection(format.decode(response.body))
25
+ end
26
+ end
27
+
28
+ def self.with_json_format(&block)
29
+ # Force json processing for this api request
30
+ json_format = ActiveResource::Formats[:json]
31
+ orig_format = connection.format
32
+ begin
33
+ connection.format = json_format
34
+ block.call(json_format)
35
+ ensure
36
+ connection.format = orig_format
37
+ end
24
38
  end
25
39
  end
26
40
  end
@@ -88,4 +88,26 @@ describe Chargify::Allocation do
88
88
  end
89
89
  end
90
90
  end
91
+
92
+ describe '.with_json_format' do
93
+ before do
94
+ Chargify.configure do |config|
95
+ config.format = :xml
96
+ end
97
+ end
98
+
99
+ it 'forces json format' do
100
+ ran = false
101
+ block_format = nil
102
+ block = proc do |format|
103
+ ran = true
104
+ block_format = format
105
+ end
106
+
107
+ Chargify::Allocation.with_json_format(&block)
108
+ expect(ran).to be_true
109
+ expect(block_format).to be_an ActiveResource::Formats[:json]
110
+ expect(Chargify::Allocation.connection.format).to be_an ActiveResource::Formats[:xml]
111
+ end
112
+ end
91
113
  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.2
4
+ version: 1.4.3
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-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource