spohlenz-freshbooksrb 0.3 → 0.4

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.
Files changed (2) hide show
  1. data/lib/freshbooks/base.rb +10 -5
  2. metadata +10 -1
@@ -1,3 +1,5 @@
1
+ require 'andand'
2
+
1
3
  module FreshBooks
2
4
  class Base
3
5
  def initialize(attributes={})
@@ -35,8 +37,8 @@ module FreshBooks
35
37
  end
36
38
 
37
39
  def self.get(id)
38
- result = call_api_with_id('get', id)
39
- new(result[prefix]) if result[prefix]
40
+ result = call_api_with_id('get', id).andand[prefix]
41
+ new(result) if result
40
42
  end
41
43
 
42
44
  def self.delete(id)
@@ -44,9 +46,12 @@ module FreshBooks
44
46
  end
45
47
 
46
48
  def self.list(params={})
47
- result = call_api('list', params)
48
- if result[prefix.pluralize] && result[prefix]
49
- result[prefix.pluralize][prefix].map { |p| new(p) }
49
+ result = call_api('list', params).andand[prefix.pluralize].andand[prefix]
50
+
51
+ if result && result.is_a?(Array)
52
+ result.map { |p| new(p) }
53
+ elsif result
54
+ new(result)
50
55
  else
51
56
  []
52
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spohlenz-freshbooksrb
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: "0.4"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pohlenz
@@ -39,6 +39,15 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.2
41
41
  version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: andand
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.3.1
50
+ version:
42
51
  description: FreshBooksRb is a Ruby library for integrating your apps with the FreshBooks API (http://developers.freshbooks.com/overview/)
43
52
  email: sam@sampohlenz.com
44
53
  executables: []