biller_bot_resource 0.0.5 → 0.0.6

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.
@@ -1,5 +1,6 @@
1
1
  class BillerBotResource::Invoice < BillerBotResource::Resource
2
-
2
+ self.include_root_in_json = true
3
+
3
4
  class Status < BillerBotResource::Resource
4
5
  def display_name
5
6
  @attributes[:name].try(:capitalize)
@@ -10,19 +11,21 @@ class BillerBotResource::Invoice < BillerBotResource::Resource
10
11
  @attributes[:locations] ||= []
11
12
  @attributes[:locations]
12
13
  end
13
-
14
+
14
15
  def line_items
15
16
  @attributes[:line_items] ||= []
16
17
  @attributes[:line_items]
17
18
  end
18
-
19
+
19
20
  def save(*args)
20
- @attributes[:line_items_attributes] = @attributes.delete(:line_items)
21
- @attributes[:locations_attributes] = @attributes.delete(:locations)
21
+ line_items = Array.wrap(@attributes.delete(:line_items)).compact
22
+ locations = Array.wrap(@attributes.delete(:locations)).compact
23
+ @attributes[:line_items_attributes] = line_items unless line_items.empty?
24
+ @attributes[:locations_attributes] = locations unless locations.empty?
22
25
  super
23
26
  end
24
27
 
25
28
  def total_charge
26
- line_items.map(&:total_charge).inject(:+)
29
+ line_items.map(&:total_charge).inject(:+) || 0
27
30
  end
28
31
  end
@@ -2,17 +2,17 @@ class BillerBotResource::Resource < ActiveResource::Base
2
2
 
3
3
  self.include_root_in_json = false
4
4
  self.format = :json
5
-
5
+
6
6
  ##
7
- # Allow the resource to be configured via block style.
7
+ # Allow the resource to be configured via block style.
8
8
  def self.configure
9
9
  yield config
10
-
10
+
11
11
  self.site = config.site
12
12
  self.logger = config.logger if config.logger
13
13
  self.timeout = config.timeout
14
14
  end
15
-
15
+
16
16
  def self.config
17
17
  if defined?(@config)
18
18
  @config
@@ -23,7 +23,7 @@ class BillerBotResource::Resource < ActiveResource::Base
23
23
  @config
24
24
  end
25
25
  end
26
-
26
+
27
27
  ##
28
28
  # Append the auth token to all of our queries. The easiest way to do this
29
29
  # is to override the query string method and inject it.
@@ -32,7 +32,7 @@ class BillerBotResource::Resource < ActiveResource::Base
32
32
  options[:auth_token] = config.api_key
33
33
  super(options)
34
34
  end
35
-
35
+
36
36
  def self.instantiate_collection(collection, prefix_options = {})
37
37
  return super if collection.is_a? Array
38
38
  remote_collection = []
@@ -40,14 +40,20 @@ class BillerBotResource::Resource < ActiveResource::Base
40
40
  # TODO: Add additional keys to the remote collection
41
41
  remote_collection
42
42
  end
43
-
43
+
44
44
  def initialize(attributes = {}, persisted = false)
45
45
  attributes = enrich_attributes(attributes)
46
46
  super(attributes, persisted)
47
47
  end
48
48
 
49
+ def save(*args)
50
+ @attributes.delete :created_at
51
+ @attributes.delete :updated_at
52
+ super
53
+ end
54
+
49
55
  protected
50
-
56
+
51
57
  ##
52
58
  # Convert string values to more complex types such as Time.
53
59
  #
@@ -1,3 +1,3 @@
1
1
  module BillerBotResource
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biller_bot_resource
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.5
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 6
9
+ version: 0.0.6
6
10
  platform: ruby
7
11
  authors:
8
12
  - Brad Seefeld
@@ -10,7 +14,8 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2013-08-21 00:00:00 Z
17
+ date: 2013-12-14 00:00:00 -08:00
18
+ default_executable:
14
19
  dependencies: []
15
20
 
16
21
  description: Provides a set of Ruby classes for interacting with the BillerBot API
@@ -37,6 +42,7 @@ files:
37
42
  - lib/biller_bot_resource/product.rb
38
43
  - lib/biller_bot_resource/resource.rb
39
44
  - lib/biller_bot_resource/version.rb
45
+ has_rdoc: true
40
46
  homepage: https://github.com/bradseefeld/biller_bot_resource
41
47
  licenses: []
42
48
 
@@ -46,21 +52,23 @@ rdoc_options: []
46
52
  require_paths:
47
53
  - lib
48
54
  required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
55
  requirements:
51
56
  - - ">="
52
57
  - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
53
60
  version: "0"
54
61
  required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
62
  requirements:
57
63
  - - ">="
58
64
  - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
59
67
  version: "0"
60
68
  requirements: []
61
69
 
62
70
  rubyforge_project: biller_bot_resource
63
- rubygems_version: 1.8.25
71
+ rubygems_version: 1.3.6
64
72
  signing_key:
65
73
  specification_version: 3
66
74
  summary: Common resources for the BillerBot API