pipedrive_api_rb 1.0.0

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 (66) hide show
  1. checksums.yaml +7 -0
  2. data/.cane +5 -0
  3. data/.gitignore +23 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +105 -0
  6. data/.travis.yml +14 -0
  7. data/Gemfile +6 -0
  8. data/HISTORY.md +43 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +98 -0
  11. data/Rakefile +12 -0
  12. data/defaults.reek +11 -0
  13. data/lib/pipedrive/activity.rb +10 -0
  14. data/lib/pipedrive/activity_type.rb +14 -0
  15. data/lib/pipedrive/base.rb +93 -0
  16. data/lib/pipedrive/deal.rb +10 -0
  17. data/lib/pipedrive/deal_field.rb +13 -0
  18. data/lib/pipedrive/file.rb +10 -0
  19. data/lib/pipedrive/filter.rb +8 -0
  20. data/lib/pipedrive/goal.rb +10 -0
  21. data/lib/pipedrive/lead.rb +8 -0
  22. data/lib/pipedrive/lead_label.rb +12 -0
  23. data/lib/pipedrive/note.rb +10 -0
  24. data/lib/pipedrive/operations/create.rb +13 -0
  25. data/lib/pipedrive/operations/delete.rb +17 -0
  26. data/lib/pipedrive/operations/read.rb +32 -0
  27. data/lib/pipedrive/operations/update.rb +18 -0
  28. data/lib/pipedrive/organization.rb +20 -0
  29. data/lib/pipedrive/organization_field.rb +13 -0
  30. data/lib/pipedrive/person.rb +22 -0
  31. data/lib/pipedrive/person_field.rb +14 -0
  32. data/lib/pipedrive/pipeline.rb +10 -0
  33. data/lib/pipedrive/product.rb +10 -0
  34. data/lib/pipedrive/product_field.rb +13 -0
  35. data/lib/pipedrive/railties.rb +9 -0
  36. data/lib/pipedrive/role.rb +10 -0
  37. data/lib/pipedrive/stage.rb +10 -0
  38. data/lib/pipedrive/user.rb +10 -0
  39. data/lib/pipedrive/utils.rb +20 -0
  40. data/lib/pipedrive/version.rb +5 -0
  41. data/lib/pipedrive.rb +100 -0
  42. data/pipedrive.gemspec +34 -0
  43. data/spec/lib/pipedrive/activity_spec.rb +13 -0
  44. data/spec/lib/pipedrive/activity_type_spec.rb +13 -0
  45. data/spec/lib/pipedrive/base_spec.rb +155 -0
  46. data/spec/lib/pipedrive/deal_field_spec.rb +13 -0
  47. data/spec/lib/pipedrive/deal_spec.rb +13 -0
  48. data/spec/lib/pipedrive/file_spec.rb +13 -0
  49. data/spec/lib/pipedrive/filter_spec.rb +13 -0
  50. data/spec/lib/pipedrive/goal_spec.rb +13 -0
  51. data/spec/lib/pipedrive/lead_label_spec.rb +9 -0
  52. data/spec/lib/pipedrive/lead_spec.rb +9 -0
  53. data/spec/lib/pipedrive/note_spec.rb +13 -0
  54. data/spec/lib/pipedrive/ogranization_spec.rb +13 -0
  55. data/spec/lib/pipedrive/operations/create_spec.rb +18 -0
  56. data/spec/lib/pipedrive/operations/delete_spec.rb +25 -0
  57. data/spec/lib/pipedrive/operations/read_spec.rb +77 -0
  58. data/spec/lib/pipedrive/operations/update_spec.rb +23 -0
  59. data/spec/lib/pipedrive/organization_field_spec.rb +13 -0
  60. data/spec/lib/pipedrive/person_field_spec.rb +13 -0
  61. data/spec/lib/pipedrive/person_spec.rb +30 -0
  62. data/spec/lib/pipedrive/product_field_spec.rb +13 -0
  63. data/spec/lib/pipedrive/product_spec.rb +13 -0
  64. data/spec/lib/pipedrive_spec.rb +73 -0
  65. data/spec/spec_helper.rb +5 -0
  66. metadata +285 -0
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class OrganizationField < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Create
7
+ include ::Pipedrive::Operations::Delete
8
+
9
+ def entity_name
10
+ 'organizationFields'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Person < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Create
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ include ::Pipedrive::Utils
10
+
11
+ def find_by_name(*args, &block)
12
+ params = args.extract_options!
13
+ params[:term] ||= args[0]
14
+ raise 'term is missing' unless params[:term]
15
+
16
+ params[:search_by_email] ||= args[1] ? 1 : 0
17
+ return to_enum(:find_by_name, params) unless block_given?
18
+
19
+ follow_pagination(:make_api_call, [:get, 'find'], params, &block)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class PersonField < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Create
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+
10
+ def entity_name
11
+ 'personFields'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Pipeline < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Product < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Create
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class ProductField < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Create
7
+ include ::Pipedrive::Operations::Delete
8
+
9
+ def entity_name
10
+ 'productFields'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Railties < ::Rails::Railtie
5
+ initializer 'Pipedrive logger' do
6
+ ::Pipedrive.logger = ::Rails.logger
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Role < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Stage < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class User < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ module Utils
5
+ extend ActiveSupport::Concern
6
+
7
+ def follow_pagination(method, args, params, &block)
8
+ start = params[:start] || 0
9
+ loop do
10
+ res = __send__(method, *args, params.merge(start: start))
11
+ break if !res.try(:data) || !res.success?
12
+
13
+ res.data.each(&block)
14
+ break unless res.try(:additional_data).try(:pagination).try(:more_items_in_collection?)
15
+
16
+ start = res.try(:additional_data).try(:pagination).try(:next_start)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ VERSION = '1.0.0'
5
+ end
data/lib/pipedrive.rb ADDED
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require 'active_support/core_ext/hash'
5
+ require 'active_support/concern'
6
+ require 'active_support/inflector'
7
+
8
+ require 'hashie'
9
+ require 'faraday'
10
+ require 'faraday/mashify'
11
+ require 'pipedrive/version'
12
+
13
+ module Pipedrive
14
+ extend self
15
+ attr_accessor :api_token, :debug
16
+ attr_writer :user_agent, :logger
17
+
18
+ # ensures the setup only gets run once
19
+ @_ran_once = false
20
+
21
+ def reset!
22
+ @logger = nil
23
+ @_ran_once = false
24
+ @user_agent = nil
25
+ @api_token = nil
26
+ end
27
+
28
+ def user_agent
29
+ @user_agent ||= "Pipedrive Ruby Client v#{::Pipedrive::VERSION}"
30
+ end
31
+
32
+ def setup
33
+ yield self unless @_ran_once
34
+ @_ran_once = true
35
+ end
36
+
37
+ def logger
38
+ @logger ||= Logger.new($stdout)
39
+ end
40
+
41
+ reset!
42
+ end
43
+
44
+ require 'pipedrive/railties' if defined?(::Rails)
45
+
46
+ # Core
47
+ require 'pipedrive/base'
48
+ require 'pipedrive/utils'
49
+ require 'pipedrive/operations/create'
50
+ require 'pipedrive/operations/read'
51
+ require 'pipedrive/operations/update'
52
+ require 'pipedrive/operations/delete'
53
+
54
+ # Persons
55
+ require 'pipedrive/person_field'
56
+ require 'pipedrive/person'
57
+
58
+ # Organizations
59
+ require 'pipedrive/organization_field'
60
+ require 'pipedrive/organization'
61
+
62
+ # Filters
63
+ require 'pipedrive/filter'
64
+
65
+ # Products
66
+ require 'pipedrive/product_field'
67
+ require 'pipedrive/product'
68
+
69
+ # Roles
70
+ require 'pipedrive/role'
71
+
72
+ # Stages
73
+ require 'pipedrive/stage'
74
+
75
+ # Goals
76
+ require 'pipedrive/goal'
77
+
78
+ # Activities
79
+ require 'pipedrive/activity'
80
+ require 'pipedrive/activity_type'
81
+
82
+ # Deals
83
+ require 'pipedrive/deal_field'
84
+ require 'pipedrive/deal'
85
+
86
+ # Lead
87
+ require 'pipedrive/lead_label'
88
+ require 'pipedrive/lead'
89
+
90
+ # Files
91
+ require 'pipedrive/file'
92
+
93
+ # Notes
94
+ require 'pipedrive/note'
95
+
96
+ # Users
97
+ require 'pipedrive/user'
98
+
99
+ # Pipelines
100
+ require 'pipedrive/pipeline'
data/pipedrive.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'pipedrive/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = 'pipedrive_api_rb'
9
+ gem.version = Pipedrive::VERSION
10
+ gem.authors = ['Jan Sterba', 'Alexander Simonov']
11
+ gem.email = ['info@jansterba.com']
12
+ gem.summary = 'Pipedrive.com API Wrapper'
13
+ gem.description = 'Pipedrive.com API Wrapper'
14
+ gem.homepage = 'https://github.com/honzasterba/pipedrive_api_rb'
15
+ gem.license = 'MIT'
16
+
17
+ gem.files = `git ls-files -z`.split("\x0")
18
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ['lib']
21
+ gem.required_ruby_version = '>=2.5'
22
+
23
+ gem.add_dependency('activesupport', '>= 4.0.0')
24
+ gem.add_dependency('faraday')
25
+ gem.add_dependency('faraday-mashify')
26
+ gem.add_dependency('hashie', '>= 3.0')
27
+ gem.add_development_dependency('bundler')
28
+ gem.add_development_dependency('rake', '> 12')
29
+ gem.add_development_dependency('rspec', '>= 3.0')
30
+ gem.add_development_dependency('rubocop')
31
+ gem.add_development_dependency('rubocop-performance')
32
+ gem.add_development_dependency('rubocop-rspec')
33
+ gem.add_development_dependency('webmock')
34
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Activity do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('activities') }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::ActivityType do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('activityTypes') }
12
+ end
13
+ end
@@ -0,0 +1,155 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Base do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq described_class.name.split('::')[-1].downcase.pluralize }
12
+ end
13
+
14
+ context '::faraday_options' do
15
+ subject { described_class.faraday_options }
16
+
17
+ it {
18
+ expect(subject).to eq({
19
+ url: 'https://api.pipedrive.com',
20
+ headers: { accept: 'application/json', content_type: "application/json", user_agent: 'Pipedrive Ruby Client v0.3.0' }
21
+ })
22
+ }
23
+ end
24
+
25
+ context '::connection' do
26
+ subject { super().connection }
27
+
28
+ it { is_expected.to be_kind_of(::Faraday::Connection) }
29
+ end
30
+
31
+ describe '#failed_response' do
32
+ subject { super().failed_response(res) }
33
+
34
+ let(:res) { double('res', body: ::Hashie::Mash.new({}), status: status) }
35
+
36
+ context 'status is 401' do
37
+ let(:status) { 401 }
38
+
39
+ it {
40
+ expect(subject).to eq(::Hashie::Mash.new({
41
+ failed: false,
42
+ not_authorized: true,
43
+ success: false
44
+ }))
45
+ }
46
+ end
47
+
48
+ context 'status is 420' do
49
+ let(:status) { 420 }
50
+
51
+ it {
52
+ expect(subject).to eq(::Hashie::Mash.new({
53
+ failed: true,
54
+ not_authorized: false,
55
+ success: false
56
+ }))
57
+ }
58
+ end
59
+
60
+ context 'status is 400' do
61
+ let(:status) { 400 }
62
+
63
+ it {
64
+ expect(subject).to eq(::Hashie::Mash.new({
65
+ failed: false,
66
+ not_authorized: false,
67
+ success: false
68
+ }))
69
+ }
70
+ end
71
+ end
72
+
73
+ describe '#make_api_call' do
74
+ it 'faileds no method' do
75
+ expect { subject.make_api_call(test: 'foo') }.to raise_error('method param missing')
76
+ end
77
+
78
+ context 'without id' do
79
+ it 'calls :get' do
80
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
81
+ expect_any_instance_of(::Faraday::Connection).to receive(:get).with('/v1/bases?api_token=token', {}).and_call_original
82
+ expect(subject.make_api_call(:get))
83
+ end
84
+
85
+ it 'calls :post' do
86
+ stub_request(:post, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
87
+ expect_any_instance_of(::Faraday::Connection).to receive(:post).with('/v1/bases?api_token=token', { test: 'bar' }.to_json).and_call_original
88
+ expect(subject.make_api_call(:post, test: 'bar'))
89
+ end
90
+
91
+ it 'calls :put' do
92
+ stub_request(:put, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
93
+ expect_any_instance_of(::Faraday::Connection).to receive(:put).with('/v1/bases?api_token=token', { test: 'bar' }.to_json).and_call_original
94
+ expect(subject.make_api_call(:put, test: 'bar'))
95
+ end
96
+
97
+ it 'uses field_selector properly' do
98
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases:(a,b,c)?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
99
+ expect_any_instance_of(::Faraday::Connection).to receive(:get)
100
+ .with('/v1/bases:(a,b,c)?api_token=token', {}).and_call_original
101
+ expect(subject.make_api_call(:get, fields_to_select: %w[a b c]))
102
+ end
103
+
104
+ it 'does not use field_selector if it empty' do
105
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
106
+ expect_any_instance_of(::Faraday::Connection).to receive(:get)
107
+ .with('/v1/bases?api_token=token', {}).and_call_original
108
+ expect(subject.make_api_call(:get, fields_to_select: []))
109
+ end
110
+
111
+ it 'retries if Errno::ETIMEDOUT' do
112
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
113
+ connection = subject.connection
114
+ allow(subject).to receive(:connection).and_return(connection)
115
+ allow(connection).to receive(:get)
116
+ .with('/v1/bases?api_token=token', {}).and_raise(Errno::ETIMEDOUT)
117
+ expect(connection).to receive(:get)
118
+ .with('/v1/bases?api_token=token', {}).and_call_original
119
+ expect(subject.make_api_call(:get, fields_to_select: []))
120
+ end
121
+ end
122
+
123
+ context 'with id' do
124
+ it 'calls :get' do
125
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases/12?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
126
+ expect_any_instance_of(::Faraday::Connection).to receive(:get).with('/v1/bases/12?api_token=token', {}).and_call_original
127
+ expect(subject.make_api_call(:get, 12))
128
+ end
129
+
130
+ it 'calls :post' do
131
+ stub_request(:post, 'https://api.pipedrive.com/v1/bases/13?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
132
+ expect_any_instance_of(::Faraday::Connection).to receive(:post).with('/v1/bases/13?api_token=token', { test: 'bar' }.to_json).and_call_original
133
+ expect(subject.make_api_call(:post, 13, test: 'bar'))
134
+ end
135
+
136
+ it 'calls :put' do
137
+ stub_request(:put, 'https://api.pipedrive.com/v1/bases/14?api_token=token').to_return(status: 200, body: {}.to_json, headers: {})
138
+ expect_any_instance_of(::Faraday::Connection).to receive(:put).with('/v1/bases/14?api_token=token', { test: 'bar' }.to_json).and_call_original
139
+ expect(subject.make_api_call(:put, 14, test: 'bar'))
140
+ end
141
+ end
142
+
143
+ it 'calls Hashie::Mash if return empty string' do
144
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 200, body: '', headers: {})
145
+ expect(::Hashie::Mash).to receive(:new).with(success: true).and_call_original
146
+ expect(subject.make_api_call(:get))
147
+ end
148
+
149
+ it 'calls #failed_response if failed status' do
150
+ stub_request(:get, 'https://api.pipedrive.com/v1/bases?api_token=token').to_return(status: 400, body: '', headers: {})
151
+ expect(subject).to receive(:failed_response)
152
+ expect(subject.make_api_call(:get))
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::DealField do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('dealFields') }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Deal do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('deals') }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::File do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('files') }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Filter do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('filters') }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Goal do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('goals') }
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ::Pipedrive::LeadLabel do
4
+ subject { described_class.new('token') }
5
+ context '#entity_name' do
6
+ subject { super().entity_name }
7
+ it { is_expected.to eq('leadLabels') }
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ::Pipedrive::Lead do
4
+ subject { described_class.new('token') }
5
+ context '#entity_name' do
6
+ subject { super().entity_name }
7
+ it { is_expected.to eq('leads') }
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Note do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('notes') }
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Organization do
6
+ subject { described_class.new('token') }
7
+
8
+ describe '#entity_name' do
9
+ subject { super().entity_name }
10
+
11
+ it { is_expected.to eq('organizations') }
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Operations::Create do
6
+ subject do
7
+ Class.new(::Pipedrive::Base) do
8
+ include ::Pipedrive::Operations::Create
9
+ end.new('token')
10
+ end
11
+
12
+ describe '#create' do
13
+ it 'calls #make_api_call' do
14
+ expect(subject).to receive(:make_api_call).with(:post, { foo: 'bar' })
15
+ subject.create(foo: 'bar')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::Pipedrive::Operations::Delete do
6
+ subject do
7
+ Class.new(::Pipedrive::Base) do
8
+ include ::Pipedrive::Operations::Delete
9
+ end.new('token')
10
+ end
11
+
12
+ describe '#delete' do
13
+ it 'calls #make_api_call' do
14
+ expect(subject).to receive(:make_api_call).with(:delete, 12)
15
+ subject.delete(12)
16
+ end
17
+ end
18
+
19
+ describe '#delete_all' do
20
+ it 'calls #make_api_call' do
21
+ expect(subject).to receive(:make_api_call).with(:delete)
22
+ subject.delete_all
23
+ end
24
+ end
25
+ end