bill_forward 1.2016.26 → 1.2016.101
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/bill_forward/client.rb +12 -12
- data/lib/bill_forward/entities/account.rb +16 -0
- data/lib/bill_forward/entities/invoice.rb +38 -0
- data/lib/bill_forward/entities/payment_method.rb +19 -19
- data/lib/bill_forward/entities/refund.rb +15 -3
- data/lib/bill_forward/entities/subscription_charge.rb +30 -0
- data/lib/bill_forward/version.rb +1 -1
- data/lib/bill_forward.rb +4 -1
- metadata +2 -12
- data/.idea/.name +0 -1
- data/.idea/compiler.xml +0 -23
- data/.idea/copyright/profiles_settings.xml +0 -3
- data/.idea/encodings.xml +0 -5
- data/.idea/inspectionProfiles/Project_Default.xml +0 -11
- data/.idea/inspectionProfiles/profiles_settings.xml +0 -7
- data/.idea/misc.xml +0 -23
- data/.idea/modules.xml +0 -9
- data/.idea/scopes/scope_settings.xml +0 -5
- data/.idea/vcs.xml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e86289afd1ad019c031eae000a90ff9cd4686dc
|
4
|
+
data.tar.gz: 4a04471c774a0eb5e75b0733be5f07c13d853ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f6a317aac25f6da99b5a6d1e4b3e153ca2b3bb7e6946697c9be51e432928e6b7a54c9e7501913274013452e3e8465bc0be7e2f374341722dacf04fbf87f2abf
|
7
|
+
data.tar.gz: f65efc1fedcc4f40794da77e903006111df96b8441fc159c76a5305f3834835560e362c01bc75ca620d2aa7f2e60fe1a13600a915c91cca493bd304220d974f9
|
data/.gitignore
CHANGED
data/lib/bill_forward/client.rb
CHANGED
@@ -46,8 +46,9 @@ module BillForward
|
|
46
46
|
@@all_verbs = @@payload_verbs + @@no_payload_verbs
|
47
47
|
|
48
48
|
attr_accessor :host
|
49
|
-
attr_accessor :use_logging
|
50
49
|
attr_accessor :api_token
|
50
|
+
attr_accessor :use_logging
|
51
|
+
attr_accessor :logger
|
51
52
|
|
52
53
|
# provide access to self statics
|
53
54
|
class << self
|
@@ -87,13 +88,14 @@ module BillForward
|
|
87
88
|
def initialize(options={})
|
88
89
|
TypeCheck.verifyObj(Hash, options, 'options')
|
89
90
|
@use_logging = options[:use_logging]
|
91
|
+
@logger = options[:logger] || Logger.new(STDOUT)
|
90
92
|
|
91
93
|
if options[:host]
|
92
94
|
@host = options[:host]
|
93
95
|
else
|
94
96
|
raise ClientInstantiationException.new "Failed to initialize BillForward API Client\n" +
|
95
|
-
|
96
|
-
|
97
|
+
"Required parameters: :host and either [:api_token] or all of [:client_id, :client_secret, :username, :password].\n" +
|
98
|
+
"Supplied Parameters: #{options}"
|
97
99
|
end
|
98
100
|
|
99
101
|
if options[:use_proxy]
|
@@ -112,10 +114,9 @@ module BillForward
|
|
112
114
|
@password = options[:password]
|
113
115
|
else
|
114
116
|
raise ClientException.new "Failed to initialize BillForward API Client\n"+
|
115
|
-
|
116
|
-
|
117
|
+
"Required parameters: :host and either [:api_token] or all of [:client_id, :client_secret, :username, :password].\n" +
|
118
|
+
"Supplied Parameters: #{options}"
|
117
119
|
end
|
118
|
-
|
119
120
|
end
|
120
121
|
|
121
122
|
@authorization = nil
|
@@ -144,6 +145,10 @@ module BillForward
|
|
144
145
|
args = [url, options]
|
145
146
|
args.insert(1, payload) if haspayload
|
146
147
|
|
148
|
+
log "#{verb.upcase} #{url}"
|
149
|
+
log "headers: #{JSON.pretty_generate(options)}"
|
150
|
+
log "payload: #{payload}" if haspayload
|
151
|
+
|
147
152
|
RestClient.send(verb.intern, *args)
|
148
153
|
end
|
149
154
|
|
@@ -221,9 +226,6 @@ module BillForward
|
|
221
226
|
|
222
227
|
token = get_token
|
223
228
|
|
224
|
-
log "#{verb} #{url}"
|
225
|
-
log "token: #{token}"
|
226
|
-
|
227
229
|
begin
|
228
230
|
response = execute_request(verb, full_url, token, payload)
|
229
231
|
|
@@ -311,9 +313,7 @@ module BillForward
|
|
311
313
|
end
|
312
314
|
|
313
315
|
def log(*args)
|
314
|
-
if @use_logging
|
315
|
-
puts *args
|
316
|
-
end
|
316
|
+
@logger.info *args if @use_logging
|
317
317
|
end
|
318
318
|
|
319
319
|
def get_token
|
@@ -7,6 +7,22 @@ module BillForward
|
|
7
7
|
class Account < MutableEntity
|
8
8
|
@resource_path = BillForward::ResourcePath.new("accounts", "account")
|
9
9
|
|
10
|
+
class << self
|
11
|
+
def credit(id, request_object = {}, custom_client = nil)
|
12
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
13
|
+
|
14
|
+
endpoint = sprintf('%s/credit',
|
15
|
+
ERB::Util.url_encode(id)
|
16
|
+
)
|
17
|
+
|
18
|
+
request_entity = BillForward::GenericEntity.new(
|
19
|
+
request_object
|
20
|
+
)
|
21
|
+
|
22
|
+
self.request_first_heterotyped(BillForward::CreditNote, 'post', endpoint, request_entity, nil, custom_client)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
protected
|
11
27
|
def unserialize_all(hash)
|
12
28
|
super
|
@@ -35,6 +35,44 @@ module BillForward
|
|
35
35
|
|
36
36
|
self.request_many('get', endpoint, query_params, custom_client)
|
37
37
|
end
|
38
|
+
|
39
|
+
def recalculate(id, request_object = {}, custom_client = nil)
|
40
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
41
|
+
|
42
|
+
endpoint = sprintf('%s/recalculate',
|
43
|
+
ERB::Util.url_encode(id)
|
44
|
+
)
|
45
|
+
|
46
|
+
request_entity = BillForward::GenericEntity.new(
|
47
|
+
request_object
|
48
|
+
)
|
49
|
+
|
50
|
+
self.request_first('post', endpoint, request_entity, nil, custom_client)
|
51
|
+
end
|
52
|
+
|
53
|
+
def execute(id, request_object = {}, custom_client = nil)
|
54
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
55
|
+
|
56
|
+
endpoint = sprintf('%s/execute',
|
57
|
+
ERB::Util.url_encode(id)
|
58
|
+
)
|
59
|
+
|
60
|
+
request_entity = BillForward::GenericEntity.new(
|
61
|
+
request_object
|
62
|
+
)
|
63
|
+
|
64
|
+
self.request_first('post', endpoint, request_entity, nil, custom_client)
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_charges(id, query_params = {}, custom_client = nil)
|
68
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
69
|
+
|
70
|
+
endpoint = sprintf('%s/charges',
|
71
|
+
ERB::Util.url_encode(id)
|
72
|
+
)
|
73
|
+
|
74
|
+
self.request_many_heterotyped(BillForward::SubscriptionCharge, 'get', endpoint, query_params, custom_client)
|
75
|
+
end
|
38
76
|
end
|
39
77
|
|
40
78
|
protected
|
@@ -1,27 +1,27 @@
|
|
1
1
|
module BillForward
|
2
|
-
|
3
|
-
|
2
|
+
class PaymentMethod < MutableEntity
|
3
|
+
@resource_path = BillForward::ResourcePath.new("payment-methods", "paymentMethod")
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class << self
|
6
|
+
def get_by_link_id(id, query_params = {}, custom_client = nil)
|
7
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
endpoint = sprintf('link-id/%s',
|
10
|
+
ERB::Util.url_encode(id)
|
11
|
+
)
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
self.request_first('get', endpoint, query_params, custom_client)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
def get_by_account_id(id, query_params = {}, custom_client = nil)
|
17
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
endpoint = sprintf('account/%s',
|
20
|
+
ERB::Util.url_encode(id)
|
21
|
+
)
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
self.request_many('get', endpoint, query_params, custom_client)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
@@ -1,5 +1,17 @@
|
|
1
1
|
module BillForward
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Refund < MutableEntity
|
3
|
+
@resource_path = BillForward::ResourcePath.new("refunds", "refund")
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def get_by_invoice_id(id, query_params = {}, custom_client = nil)
|
7
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
8
|
+
|
9
|
+
endpoint = sprintf('invoice/%s',
|
10
|
+
ERB::Util.url_encode(id)
|
11
|
+
)
|
12
|
+
|
13
|
+
self.request_many('get', endpoint, query_params, custom_client)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
5
17
|
end
|
@@ -5,6 +5,36 @@ module BillForward
|
|
5
5
|
class SubscriptionCharge < MutableEntity
|
6
6
|
@resource_path = BillForward::ResourcePath.new('charges', 'subscriptionCharge')
|
7
7
|
|
8
|
+
class << self
|
9
|
+
def recalculate(id, request_object = {}, custom_client = nil)
|
10
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
11
|
+
|
12
|
+
endpoint = sprintf('%s/recalculate',
|
13
|
+
ERB::Util.url_encode(id)
|
14
|
+
)
|
15
|
+
|
16
|
+
request_entity = BillForward::GenericEntity.new(
|
17
|
+
request_object
|
18
|
+
)
|
19
|
+
|
20
|
+
self.request_first('post', endpoint, request_entity, nil, custom_client)
|
21
|
+
end
|
22
|
+
|
23
|
+
def batch_recalculate(id, request_object = {}, custom_client = nil)
|
24
|
+
raise ArgumentError.new("id cannot be nil") if id.nil?
|
25
|
+
|
26
|
+
endpoint = sprintf('recalculate',
|
27
|
+
ERB::Util.url_encode(id)
|
28
|
+
)
|
29
|
+
|
30
|
+
request_entity = BillForward::GenericEntity.new(
|
31
|
+
request_object
|
32
|
+
)
|
33
|
+
|
34
|
+
self.request_first('post', endpoint, request_entity, nil, custom_client)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
8
38
|
protected
|
9
39
|
def unserialize_all(hash)
|
10
40
|
super
|
data/lib/bill_forward/version.rb
CHANGED
data/lib/bill_forward.rb
CHANGED
@@ -3,6 +3,9 @@ require 'json'
|
|
3
3
|
# used for escaping query parameters
|
4
4
|
require 'erb'
|
5
5
|
|
6
|
+
# This is in the Ruby stdlib. It is probably possible for us to make this an optional dependency (required only if you enable logging and want to use default logger).
|
7
|
+
require 'logger'
|
8
|
+
|
6
9
|
# Rails extensions
|
7
10
|
# 'indifferent hashes' are used to enable string access to entities unserialized with symbol keys
|
8
11
|
require 'active_support/core_ext/hash/indifferent_access'
|
@@ -15,4 +18,4 @@ require 'active_support/core_ext/string'
|
|
15
18
|
require 'require_all'
|
16
19
|
|
17
20
|
# require all ruby files in relative directory 'bill_forward' and all its subdirectories
|
18
|
-
require_rel 'bill_forward'
|
21
|
+
require_rel 'bill_forward'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bill_forward
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2016.
|
4
|
+
version: 1.2016.101
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BillForward
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-11 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -79,16 +79,6 @@ extra_rdoc_files: []
|
|
79
79
|
|
80
80
|
files:
|
81
81
|
- .gitignore
|
82
|
-
- .idea/.name
|
83
|
-
- .idea/compiler.xml
|
84
|
-
- .idea/copyright/profiles_settings.xml
|
85
|
-
- .idea/encodings.xml
|
86
|
-
- .idea/inspectionProfiles/Project_Default.xml
|
87
|
-
- .idea/inspectionProfiles/profiles_settings.xml
|
88
|
-
- .idea/misc.xml
|
89
|
-
- .idea/modules.xml
|
90
|
-
- .idea/scopes/scope_settings.xml
|
91
|
-
- .idea/vcs.xml
|
92
82
|
- .rspec
|
93
83
|
- Gemfile
|
94
84
|
- LICENSE.md
|
data/.idea/.name
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
bill_forward_api_client
|
data/.idea/compiler.xml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="CompilerConfiguration">
|
4
|
-
<option name="DEFAULT_COMPILER" value="Javac" />
|
5
|
-
<resourceExtensions />
|
6
|
-
<wildcardResourcePatterns>
|
7
|
-
<entry name="!?*.java" />
|
8
|
-
<entry name="!?*.form" />
|
9
|
-
<entry name="!?*.class" />
|
10
|
-
<entry name="!?*.groovy" />
|
11
|
-
<entry name="!?*.scala" />
|
12
|
-
<entry name="!?*.flex" />
|
13
|
-
<entry name="!?*.kt" />
|
14
|
-
<entry name="!?*.clj" />
|
15
|
-
</wildcardResourcePatterns>
|
16
|
-
<annotationProcessing>
|
17
|
-
<profile default="true" name="Default" enabled="false">
|
18
|
-
<processorPath useClasspath="true" />
|
19
|
-
</profile>
|
20
|
-
</annotationProcessing>
|
21
|
-
</component>
|
22
|
-
</project>
|
23
|
-
|
data/.idea/encodings.xml
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
2
|
-
<profile version="1.0" is_locked="false">
|
3
|
-
<option name="myName" value="Project Default" />
|
4
|
-
<option name="myLocal" value="false" />
|
5
|
-
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
|
6
|
-
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
|
7
|
-
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
|
8
|
-
</inspection_tool>
|
9
|
-
<inspection_tool class="RubyQuotedStringsInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
10
|
-
</profile>
|
11
|
-
</component>
|
data/.idea/misc.xml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="ruby-2.0.0-p451" project-jdk-type="RUBY_SDK">
|
4
|
-
<output url="file://$PROJECT_DIR$/out" />
|
5
|
-
</component>
|
6
|
-
<component name="masterDetails">
|
7
|
-
<states>
|
8
|
-
<state key="ProjectJDKs.UI">
|
9
|
-
<settings>
|
10
|
-
<last-edited>1.7</last-edited>
|
11
|
-
<splitter-proportions>
|
12
|
-
<option name="proportions">
|
13
|
-
<list>
|
14
|
-
<option value="0.2" />
|
15
|
-
</list>
|
16
|
-
</option>
|
17
|
-
</splitter-proportions>
|
18
|
-
</settings>
|
19
|
-
</state>
|
20
|
-
</states>
|
21
|
-
</component>
|
22
|
-
</project>
|
23
|
-
|
data/.idea/modules.xml
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/bill_forward_api_client.iml" filepath="$PROJECT_DIR$/bill_forward_api_client.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
9
|
-
|