pipedrive.rb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 11021dff174077aefb3589a979112cedc1677918
4
- data.tar.gz: 76c18fb73b4f56968d580352c6b7590959570bdc
2
+ SHA256:
3
+ metadata.gz: 174f47371cadbd8c2b38b1df1b578b4b2a51d26047e0cd276a6cd775e2269b84
4
+ data.tar.gz: '0887f64ee16bea1c672d666b6b6039e907b0494de309f017e6e9aedaff75cf9b'
5
5
  SHA512:
6
- metadata.gz: 96a28445400ffc9cb4a59da4ed0a300c7a2aab5df6a81081dcfeca4b4d2daf0446372fa5608b0f631ee4feff20412c5ac8c8bc9488df29ed9a04714e7ab91056
7
- data.tar.gz: fcffc1f3a0b89de8a9b5a7b99c180964645007fef72972e57dbf20e1d3ad8cda0002684acc1b993f809d4b458ab996c23416520e2b8b4ae1faedb735949421df
6
+ metadata.gz: d1c4295874a4652eda241e363bebc5f5efe7b877f8a124d066febef50616ae580b50ef29c21cb05d684c4ceabad4988f8d8ea974f3c5de0a2916c73aa6e094d4
7
+ data.tar.gz: 830f1e1829b68811fcb0dd73369a44e015e6a2844b073928b2456c5799b9f224cf0dafc26ddbe587db07bbdeddb027f2d2d5965399d7d93b43ccb8c5dccff58d
@@ -3,9 +3,9 @@ AllCops:
3
3
  - '**/Rakefile'
4
4
  Exclude:
5
5
  - 'spec/**/*'
6
- Style/LineLength:
6
+ Metrics/LineLength:
7
7
  Max: 99
8
- Style/FileName:
8
+ Naming/FileName:
9
9
  Enabled: false
10
10
  Style/ModuleFunction:
11
11
  Enabled: false
@@ -13,5 +13,5 @@ Style/Encoding:
13
13
  Enabled: false
14
14
  Documentation:
15
15
  Enabled: false
16
- Style/MethodLength:
16
+ Metrics/MethodLength:
17
17
  Max: 15
@@ -1,10 +1,21 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1
5
3
  - ruby-head
6
4
  - jruby-19mode
7
5
  - rbx-2
6
+ - 2.1.10
7
+ - 2.2.10
8
+ - 2.3.8
9
+ - 2.4.6
10
+ - 2.5.5
11
+ - 2.6.3
12
+
8
13
  matrix:
9
14
  allow_failures:
10
15
  - rvm: ruby-head
16
+ - rvm: jruby-19mode
17
+ - rvm: rbx-2
18
+
19
+ bundler_args: --without local_development
20
+
21
+ before_install: gem install bundler -v 1.17.3
data/Gemfile CHANGED
@@ -12,9 +12,6 @@ group :local_development do
12
12
  gem 'terminal-notifier-guard', require: false if RUBY_PLATFORM.downcase.include?('darwin')
13
13
  gem 'guard-rspec', '>= 4.3.1' ,require: false
14
14
  gem 'guard-bundler', require: false
15
- gem 'guard-preek', require: false
16
15
  gem 'guard-rubocop', require: false
17
- gem 'guard-cane', require: false
18
- gem 'guard-reek', github: 'pericles/guard-reek', require: false
19
16
  gem 'pry'
20
- end
17
+ end
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Pipedrive
2
2
 
3
- [![Build Status](https://travis-ci.org/dotpromo/pipedrive.rb.svg?branch=master)](https://travis-ci.org/dotpromo/pipedrive.rb)
4
- [![Code Climate](https://codeclimate.com/github/dotpromo/pipedrive.rb.png)](https://codeclimate.com/github/dotpromo/pipedrive.rb)
5
- [![Coverage Status](https://img.shields.io/coveralls/dotpromo/pipedrive.rb.svg)](https://coveralls.io/r/dotpromo/pipedrive.rb)
3
+ [![Build Status](https://travis-ci.org/amoniacou/pipedrive.rb.svg?branch=master)](https://travis-ci.org/amoniacou/pipedrive.rb)
4
+ [![Code Climate](https://codeclimate.com/github/amoniacou/pipedrive.rb.png)](https://codeclimate.com/github/amoniacou/pipedrive.rb)
6
5
 
7
6
  Pipedrive.com API wrapper
8
7
 
@@ -33,7 +32,7 @@ client = ::Pipedrive::Person.new('api_token')
33
32
  You can get person's JSON data:
34
33
 
35
34
  ```ruby
36
- person = client.find(12345)
35
+ person = client.find_by_id(12345)
37
36
  person.success? # check what request was successful
38
37
  person.data # JSON data of person entity
39
38
  ```
@@ -93,7 +92,7 @@ And you can skip providing `api_token` to the entities classes.
93
92
 
94
93
  ## Contributing
95
94
 
96
- 1. Fork it ( https://github.com/simonoff/pipedrive/fork )
95
+ 1. Fork it ( https://github.com/amoniacou/pipedrive/fork )
97
96
  2. Create your feature branch (`git checkout -b my-new-feature`)
98
97
  3. Commit your changes (`git commit -am 'Add some feature'`)
99
98
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -7,21 +9,6 @@ RSpec::Core::RakeTask.new(:spec)
7
9
  require 'rubocop/rake_task'
8
10
  RuboCop::RakeTask.new(:rubocop)
9
11
 
10
- # reek
11
- require 'reek/rake/task'
12
-
13
- Reek::Rake::Task.new do |t|
14
- t.fail_on_error = false
15
- t.source_files = Dir['lib/**/*.rb']
16
- end
17
-
18
- default_tasks = [:spec, :rubocop, :reek]
19
-
20
- unless defined? ::Rubinius
21
- # cane
22
- require 'cane/rake_task'
23
- Cane::RakeTask.new
24
- default_tasks << :cane
25
- end
12
+ default_tasks = %i[spec rubocop]
26
13
 
27
14
  task default: default_tasks
@@ -3,10 +3,6 @@ require 'active_support/core_ext/hash'
3
3
  require 'active_support/concern'
4
4
  require 'active_support/inflector'
5
5
 
6
- ActiveSupport::Inflector.inflections do |inflect|
7
- inflect.irregular 'person', 'persons'
8
- end
9
-
10
6
  require 'hashie'
11
7
  require 'faraday'
12
8
  require 'faraday_middleware'
@@ -18,6 +18,9 @@ module Pipedrive
18
18
  res = connection.__send__(method.to_sym, url, params)
19
19
  rescue Errno::ETIMEDOUT
20
20
  retry
21
+ rescue Faraday::ParsingError
22
+ sleep 5
23
+ retry
21
24
  end
22
25
  process_response(res)
23
26
  end
@@ -57,7 +60,9 @@ module Pipedrive
57
60
  end
58
61
 
59
62
  def entity_name
60
- self.class.name.split('::')[-1].downcase.pluralize
63
+ class_name = self.class.name.split("::")[-1].downcase.pluralize
64
+ class_names = { "people" => "persons" }
65
+ class_names[class_name] || class_name
61
66
  end
62
67
 
63
68
  class << self
@@ -77,9 +82,9 @@ module Pipedrive
77
82
  conn.request :url_encoded
78
83
  conn.response :mashify
79
84
  conn.response :json, content_type: /\bjson$/
80
- conn.adapter Faraday.default_adapter
81
85
  conn.use FaradayMiddleware::ParseJson
82
86
  conn.response :logger, ::Pipedrive.logger if ::Pipedrive.debug
87
+ conn.adapter Faraday.default_adapter
83
88
  end
84
89
  end
85
90
  end
@@ -4,5 +4,14 @@ module Pipedrive
4
4
  include ::Pipedrive::Operations::Create
5
5
  include ::Pipedrive::Operations::Update
6
6
  include ::Pipedrive::Operations::Delete
7
+ include ::Pipedrive::Utils
8
+
9
+ def find_by_name(*args)
10
+ params = args.extract_options!
11
+ params[:term] ||= args[0]
12
+ fail 'term is missing' unless params[:term]
13
+ return to_enum(:find_by_name, params) unless block_given?
14
+ follow_pagination(:make_api_call, [:get, 'find'], params) { |item| yield item }
15
+ end
7
16
  end
8
17
  end
@@ -2,6 +2,7 @@ module Pipedrive
2
2
  class PersonField < Base
3
3
  include ::Pipedrive::Operations::Read
4
4
  include ::Pipedrive::Operations::Create
5
+ include ::Pipedrive::Operations::Update
5
6
  include ::Pipedrive::Operations::Delete
6
7
 
7
8
  def entity_name
@@ -1,3 +1,3 @@
1
1
  module Pipedrive
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -7,23 +7,24 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "pipedrive.rb"
8
8
  gem.version = Pipedrive::VERSION
9
9
  gem.authors = ["Alexander Simonov"]
10
- gem.email = ["alex@simonov.me"]
10
+ gem.email = ["alex@amoniac.eu"]
11
11
  gem.summary = %q{Pipedrive.com API Wrapper}
12
12
  gem.description = %q{Pipedrive.com API Wrapper}
13
- gem.homepage = 'https://github.com/dotpromo/pipedrive.rb'
13
+ gem.homepage = 'https://github.com/amoniacou/pipedrive.rb'
14
14
  gem.license = 'MIT'
15
15
 
16
16
  gem.files = `git ls-files -z`.split("\x0")
17
17
  gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ["lib"]
19
+ gem.require_paths = ['lib']
20
20
 
21
+ gem.add_dependency('activesupport', '>= 4.0.0')
21
22
  gem.add_dependency('faraday')
22
23
  gem.add_dependency('faraday_middleware')
23
- gem.add_dependency('activesupport', '>= 4.0.0')
24
24
  gem.add_dependency('hashie', '>= 3.0')
25
- gem.add_development_dependency('bundler', '~> 1.6')
26
- gem.add_development_dependency('rake')
25
+ gem.add_development_dependency('bundler')
26
+ gem.add_development_dependency('rake', '< 12')
27
27
  gem.add_development_dependency('rspec', '>= 3.0')
28
+ gem.add_development_dependency('rubocop')
28
29
  gem.add_development_dependency('webmock')
29
30
  end
@@ -11,7 +11,7 @@ RSpec.describe ::Pipedrive::Base do
11
11
  subject { described_class.faraday_options }
12
12
  it { is_expected.to eq({
13
13
  url: 'https://api.pipedrive.com',
14
- headers: { accept: 'application/json', user_agent: 'Pipedrive Ruby Client v0.0.1' }
14
+ headers: { accept: 'application/json', user_agent: 'Pipedrive Ruby Client v0.1.0' }
15
15
  }) }
16
16
  end
17
17
 
@@ -54,34 +54,34 @@ RSpec.describe ::Pipedrive::Base do
54
54
  end
55
55
  context 'without id' do
56
56
  it 'should call :get' do
57
- stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
57
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
58
58
  expect_any_instance_of(::Faraday::Connection).to receive(:get).with('/v1/bases?api_token=token', {}).and_call_original
59
59
  expect(subject.make_api_call(:get))
60
60
  end
61
61
  it 'should call :post' do
62
- stub_request(:post, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
62
+ stub_request(:post, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
63
63
  expect_any_instance_of(::Faraday::Connection).to receive(:post).with('/v1/bases?api_token=token', { test: 'bar' }).and_call_original
64
64
  expect(subject.make_api_call(:post, test: 'bar'))
65
65
  end
66
66
  it 'should call :put' do
67
- stub_request(:put, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
67
+ stub_request(:put, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
68
68
  expect_any_instance_of(::Faraday::Connection).to receive(:put).with('/v1/bases?api_token=token', { test: 'bar' }).and_call_original
69
69
  expect(subject.make_api_call(:put, test: 'bar'))
70
70
  end
71
71
  it 'should use field_selector properly' do
72
- stub_request(:get, 'https://api.pipedrive.com/v1/bases:(a,b,c)?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
72
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases:(a,b,c)?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
73
73
  expect_any_instance_of(::Faraday::Connection).to receive(:get).
74
74
  with('/v1/bases:(a,b,c)?api_token=token', {}).and_call_original
75
75
  expect(subject.make_api_call(:get, fields_to_select: %w(a b c)))
76
76
  end
77
77
  it 'should not use field_selector if it empty' do
78
- stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
78
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
79
79
  expect_any_instance_of(::Faraday::Connection).to receive(:get).
80
80
  with('/v1/bases?api_token=token', {}).and_call_original
81
81
  expect(subject.make_api_call(:get, fields_to_select: []))
82
82
  end
83
83
  it 'should retry if Errno::ETIMEDOUT' do
84
- stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
84
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
85
85
  connection = subject.connection
86
86
  allow(subject).to receive(:connection).and_return(connection)
87
87
  allow(connection).to receive(:get).
@@ -93,17 +93,17 @@ RSpec.describe ::Pipedrive::Base do
93
93
  end
94
94
  context 'with id' do
95
95
  it 'should call :get' do
96
- stub_request(:get, 'https://api.pipedrive.com/v1/bases/12?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
96
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases/12?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
97
97
  expect_any_instance_of(::Faraday::Connection).to receive(:get).with('/v1/bases/12?api_token=token', {}).and_call_original
98
98
  expect(subject.make_api_call(:get, 12))
99
99
  end
100
100
  it 'should call :post' do
101
- stub_request(:post, 'https://api.pipedrive.com/v1/bases/13?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
101
+ stub_request(:post, 'https://api.pipedrive.com/v1/bases/13?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
102
102
  expect_any_instance_of(::Faraday::Connection).to receive(:post).with('/v1/bases/13?api_token=token', { test: 'bar' }).and_call_original
103
103
  expect(subject.make_api_call(:post, 13, test: 'bar'))
104
104
  end
105
105
  it 'should call :put' do
106
- stub_request(:put, 'https://api.pipedrive.com/v1/bases/14?api_token=token').to_return(:status => 200, :body => {}, :headers => {})
106
+ stub_request(:put, 'https://api.pipedrive.com/v1/bases/14?api_token=token').to_return(:status => 200, :body => {}.to_json, :headers => {})
107
107
  expect_any_instance_of(::Faraday::Connection).to receive(:put).with('/v1/bases/14?api_token=token', { test: 'bar' }).and_call_original
108
108
  expect(subject.make_api_call(:put, 14, test: 'bar'))
109
109
  end
@@ -119,4 +119,4 @@ RSpec.describe ::Pipedrive::Base do
119
119
  expect(subject.make_api_call(:get))
120
120
  end
121
121
  end
122
- end
122
+ end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipedrive.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Simonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-16 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: faraday
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: faraday_middleware
28
+ name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: faraday_middleware
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 4.0.0
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 4.0.0
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hashie
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,30 +70,30 @@ dependencies:
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '1.6'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '1.6'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "<"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '12'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "<"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '12'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: webmock
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +138,7 @@ dependencies:
124
138
  version: '0'
125
139
  description: Pipedrive.com API Wrapper
126
140
  email:
127
- - alex@simonov.me
141
+ - alex@amoniac.eu
128
142
  executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
@@ -187,7 +201,7 @@ files:
187
201
  - spec/lib/pipedrive/product_spec.rb
188
202
  - spec/lib/pipedrive_spec.rb
189
203
  - spec/spec_helper.rb
190
- homepage: https://github.com/dotpromo/pipedrive.rb
204
+ homepage: https://github.com/amoniacou/pipedrive.rb
191
205
  licenses:
192
206
  - MIT
193
207
  metadata: {}
@@ -206,8 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
220
  - !ruby/object:Gem::Version
207
221
  version: '0'
208
222
  requirements: []
209
- rubyforge_project:
210
- rubygems_version: 2.2.2
223
+ rubygems_version: 3.0.6
211
224
  signing_key:
212
225
  specification_version: 4
213
226
  summary: Pipedrive.com API Wrapper