pipedrive-ruby 0.2.2 → 0.2.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -32,14 +32,17 @@ module Pipedrive
32
32
  # @param [HTTParty::Response] response
33
33
  def self.bad_response(response)
34
34
  if response.class == HTTParty::Response
35
- raise response.inspect
36
35
  raise ResponseError, response
37
36
  end
38
37
  raise StandardError, "Unkown error"
39
38
  end
40
-
39
+
40
+ def self.new_list( attrs )
41
+ attrs['data'].is_a?(Array) ? attrs['data'].map {|data| self.new( 'data' => data ) } : []
42
+ end
43
+
41
44
  attr_reader :data
42
-
45
+
43
46
  # Create a new CloudApp::Base object.
44
47
  #
45
48
  # Only used internally
@@ -47,7 +50,7 @@ module Pipedrive
47
50
  # @param [Hash] attributes
48
51
  # @return [CloudApp::Base]
49
52
  def initialize(attrs = {})
50
- super( attrs['data'].is_a?(Hash) ? attrs['data'] : (attrs['data'].first unless attrs['data'].nil?) )
53
+ super( attrs['data'] )
51
54
  end
52
55
 
53
56
  end
@@ -21,10 +21,10 @@ module Pipedrive
21
21
  end
22
22
  end
23
23
 
24
- def self.find_by_name(opts = {})
25
- res = get "/organizations/find", :query => opts
24
+ def self.find_by_name(name, opts={})
25
+ res = get "/organizations/find", :query => { :term => name }.merge(opts)
26
26
  if res.ok?
27
- Organization.new(res)
27
+ Organization.new_list(res)
28
28
  else
29
29
  bad_response(res)
30
30
  end
@@ -21,10 +21,10 @@ module Pipedrive
21
21
  end
22
22
  end
23
23
 
24
- def self.find_by_name(opts = {})
25
- res = get "/persons/find", :query => opts
24
+ def self.find_by_name(name, opts={})
25
+ res = get "/persons/find", :query => { :term => name }.merge(opts)
26
26
  if res.ok?
27
- Person.new(res)
27
+ Person.new_list(res)
28
28
  else
29
29
  bad_response(res)
30
30
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pipedrive-ruby"
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Waldemar Kusnezow", "Jan Schwenzien", "Patrick Kozma"]
12
- s.date = "2012-11-02"
12
+ s.date = "2012-11-04"
13
13
  s.description = "Ruby wrapper for the Pipedrive API"
14
14
  s.email = "jan@general-scripting.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipedrive-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-02 00:00:00.000000000 Z
14
+ date: 2012-11-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: -3661717696348220238
148
+ hash: -274804402541556327
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements: