bill_forward 1.2016.26 → 1.2016.101

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: 61e73dfe374b644506689c0f003fff265a555c1b
4
- data.tar.gz: d061d247a53d91d6f02bf6cf211a67e508f554e4
3
+ metadata.gz: 9e86289afd1ad019c031eae000a90ff9cd4686dc
4
+ data.tar.gz: 4a04471c774a0eb5e75b0733be5f07c13d853ffb
5
5
  SHA512:
6
- metadata.gz: f60e60c2416ba69e636fb9d1dbd9e38bb538e1f164b6b16624757934b8ca80c8a99024a7c2c5a5864a316b4e6cf4f4dd2aa10721c7b88f68ec4bd39b754732a5
7
- data.tar.gz: d357954097bf7a6db634db33b6d00eb11d62a4905158470e0f455575c7eb04f5e88291905b8f86d7ce5b643c639b8a6a7fc67ed4762a71241f0756ca3c318949
6
+ metadata.gz: 8f6a317aac25f6da99b5a6d1e4b3e153ca2b3bb7e6946697c9be51e432928e6b7a54c9e7501913274013452e3e8465bc0be7e2f374341722dacf04fbf87f2abf
7
+ data.tar.gz: f65efc1fedcc4f40794da77e903006111df96b8441fc159c76a5305f3834835560e362c01bc75ca620d2aa7f2e60fe1a13600a915c91cca493bd304220d974f9
data/.gitignore CHANGED
@@ -21,6 +21,8 @@ tmp
21
21
  *.a
22
22
  mkmf.log
23
23
  .idea/dictionaries
24
+ .idea
25
+ *.iml
24
26
  .rakeTasks
25
27
  onelinechange.bat
26
28
  twolinechange.bat
@@ -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
- "Required parameters: :host, and either [:api_token] or all of [:client_id, :client_secret, :username, :password].\n" +
96
- "Supplied Parameters: #{options}"
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
- "Required parameters: :host and :use_logging, and either [:api_token] or all of [:client_id, :client_secret, :username, :password].\n" +
116
- "Supplied Parameters: #{options}"
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
- class PaymentMethod < MutableEntity
3
- @resource_path = BillForward::ResourcePath.new("payment-methods", "paymentMethod")
2
+ class PaymentMethod < MutableEntity
3
+ @resource_path = BillForward::ResourcePath.new("payment-methods", "paymentMethod")
4
4
 
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?
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
- endpoint = sprintf('link-id/%s',
10
- ERB::Util.url_encode(id)
11
- )
9
+ endpoint = sprintf('link-id/%s',
10
+ ERB::Util.url_encode(id)
11
+ )
12
12
 
13
- self.request_first('get', endpoint, query_params, custom_client)
14
- end
13
+ self.request_first('get', endpoint, query_params, custom_client)
14
+ end
15
15
 
16
- def get_by_account_id(id, query_params = {}, custom_client = nil)
17
- raise ArgumentError.new("id cannot be nil") if id.nil?
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
- endpoint = sprintf('account/%s',
20
- ERB::Util.url_encode(id)
21
- )
19
+ endpoint = sprintf('account/%s',
20
+ ERB::Util.url_encode(id)
21
+ )
22
22
 
23
- self.request_many('get', endpoint, query_params, custom_client)
24
- end
25
- end
26
- end
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
- class Refund < MutableEntity
3
- @resource_path = BillForward::ResourcePath.new("refunds", "refund")
4
- end
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
@@ -1,4 +1,4 @@
1
1
  module BillForward
2
2
  # in an rspec run, the gemspec and bill_forward.rb loader will both visit this
3
- VERSION = "1.2016.26" unless const_defined?(:VERSION)
3
+ VERSION = "1.2016.101" unless const_defined?(:VERSION)
4
4
  end
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.26
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-01-27 00:00:00 Z
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
-
@@ -1,3 +0,0 @@
1
- <component name="CopyrightManager">
2
- <settings default="" />
3
- </component>
data/.idea/encodings.xml DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
- </project>
5
-
@@ -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>
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <settings>
3
- <option name="PROJECT_PROFILE" value="Project Default" />
4
- <option name="USE_PROJECT_PROFILE" value="true" />
5
- <version value="1.0" />
6
- </settings>
7
- </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
-
@@ -1,5 +0,0 @@
1
- <component name="DependencyValidationManager">
2
- <state>
3
- <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
- </state>
5
- </component>
data/.idea/vcs.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>
7
-