pipedrive_jetrockets 0.0.40 → 0.0.41

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1563f29d3dbadd903065165be3dc0198a1fc2181d6ab1f7c1a3dbb22005f37e4
4
- data.tar.gz: cb07cd32ad485c582cbaab1e24112401d8f342f475ddb05d08f690e4a26139e0
3
+ metadata.gz: b6060fd8296a1710e33bc02cf6b1cebc96a405234db0858b0c02cfc5ebca92cc
4
+ data.tar.gz: 2c9e177ac63e0de45ba718b4c77f93073efb538ef38d4fd7801f8720449eaa5a
5
5
  SHA512:
6
- metadata.gz: cb7e97b3967c4cfac159de4d1faf15bad7750654b90c7708195d696172d17410a97c0644153529d1f464fe6ce9fd9a5f6f21937b3823ec2a6c4fe90dc3390538
7
- data.tar.gz: df522a4a679684981901366a1a5baf7348e3ad4cf0439e8a58f7072b66c75685b259d27c2aa0c8f261f7f19569c02aecf7351cfb70e67c31ea030155bc9b497a
6
+ metadata.gz: 3c67f4196e69691006b8e1c2ca4f412ef23b7f5c6b6de036c31716bc65d1b8c3f346ad20a40e24eae81db61f534b0ffa4ec15f21d686471fa818f2d5da9a178b
7
+ data.tar.gz: d17a85346ddd8d6147f560b571b4315394ae67173daa53887f3505cdadf98ed4c548f0940a22d6de49dd8e06e405f06143b597d13c9c8d0605563eeded539577
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
- Rails.application.routes.draw do
2
- scope '/pipedrive' do
3
- post '/deal_updated' => 'pipedrive_jetrockets/events#deal_updated'
4
- end
5
- end
1
+ # Rails.application.routes.draw do
2
+ # scope '/pipedrive' do
3
+ # post '/deal_updated' => 'pipedrive_jetrockets/events#deal_updated'
4
+ # end
5
+ # end
@@ -1,236 +1,26 @@
1
1
  require 'net/http'
2
2
  require 'pipedrive_jetrockets/engine'
3
+ require 'pipedrive_jetrockets/service'
3
4
 
4
5
  class Pipedrive
5
6
 
6
7
  def self.deals
7
- @@deals_service ||= Pipedrive::Service.new('deal')
8
+ @@deals_service ||= PipedriveJetrockets::Service.new('deal')
8
9
  end
9
10
 
10
11
  def self.notes
11
- @@persons_service ||= Pipedrive::Service.new('note')
12
+ @@persons_service ||= PipedriveJetrockets::Service.new('note')
12
13
  end
13
14
 
14
15
  def self.persons
15
- @@persons_service ||= Pipedrive::Service.new('person')
16
+ @@persons_service ||= PipedriveJetrockets::Service.new('person')
16
17
  end
17
18
 
18
19
  def self.pipelines
19
- @@pipelines_service ||= Pipedrive::Service.new('pipeline')
20
+ @@pipelines_service ||= PipedriveJetrockets::Service.new('pipeline')
20
21
  end
21
22
 
22
23
  def self.stages
23
- @@stages_service ||= Pipedrive::Service.new('stage')
24
+ @@stages_service ||= PipedriveJetrockets::Service.new('stage')
24
25
  end
25
-
26
- #Entities
27
-
28
- class Entity
29
- def initialize(hash)
30
- hash.each {|k,v| instance_variable_set("@#{k}",v)}
31
- end
32
- end
33
-
34
- class Note < Pipedrive::Entity
35
- attr_accessor :id, :deal_id, :person_id, :org_id, :content
36
- end
37
-
38
- class Organisation < Pipedrive::Entity
39
- attr_accessor :id, :name, :owner_id, :address, :cc_email
40
- end
41
-
42
- class Person < Pipedrive::Entity
43
- attr_accessor :name, :email, :phone
44
- def initialize(hash)
45
- super
46
- @email = hash['email'].first['value'] if hash['email']
47
- @phone = hash['phone'].first['value'] if hash['phone']
48
- end
49
- end
50
-
51
- class Pipeline < Pipedrive::Entity
52
- attr_accessor :id, :name
53
- end
54
-
55
- class User < Pipedrive::Entity
56
- attr_accessor :id, :name, :email, :phone
57
- end
58
-
59
- class Deal < Pipedrive::Entity
60
- attr_accessor :add_time, :id, :organisation, :title, :value, :currency, :status, :stage_id, :person
61
- def initialize(hash)
62
- super
63
- @organisation = Pipedrive::Organisation.new(hash['org_id']) if hash['org_id']
64
- @person = Pipedrive::Person.new(hash['person_id']) if hash['person_id']
65
- end
66
-
67
- def stage
68
- Pipedrive.stages.find(self.stage_id)
69
- end
70
-
71
- def display_stage_name
72
- self.stage.display_name
73
- end
74
- end
75
-
76
- class Stage < Pipedrive::Entity
77
- attr_accessor :id, :name, :pipeline_id
78
-
79
- def pipeline
80
- Pipedrive.pipelines.find(self.pipeline_id)
81
- end
82
-
83
- def display_name
84
- "#{pipeline.name}:#{name}"
85
- end
86
- end
87
-
88
- #Services
89
-
90
- class Service
91
- def initialize(resource_name)
92
- @resource_name = resource_name
93
- end
94
-
95
- def build_entity(raw)
96
- "Pipedrive::#{@resource_name.titleize}".constantize.new(raw)
97
- end
98
-
99
- def build_uri(id = nil)
100
- uri = URI("#{Pipedrive::HOST}/#{@resource_name.pluralize}/#{id}?api_token=#{ENV['pipedrive_api_token']}")
101
- end
102
-
103
- def all
104
- uri = build_uri
105
- json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
106
- json_array.map{|raw|build_entity(raw)}
107
- end
108
-
109
- def create(params)
110
- uri = build_uri
111
- response = Net::HTTP.post_form(uri, params)
112
-
113
- if response.kind_of? Net::HTTPSuccess
114
- JSON.parse(response.body)['data']['id']
115
- else
116
- nil
117
- end
118
- end
119
-
120
- def find(id)
121
- uri = build_uri(id)
122
- raw = ::JSON.parse(Net::HTTP.get(uri))['data']
123
- build_entity(raw)
124
- end
125
-
126
- def first
127
- self.all.first
128
- end
129
-
130
- end
131
-
132
- # class DealsService < Pipedrive::Service
133
- # # def all
134
- # # uri = build_uri('deals')
135
- # # json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
136
- # # json_array.map{|raw|Pipedrive::Deal.new(raw)}
137
- # # end
138
- # def resource_name
139
- # 'deal'
140
- # end
141
- #
142
- # def create(params)
143
- # uri = build_uri('deals')
144
- # response = Net::HTTP.post_form(params)
145
- #
146
- # if responce['success']
147
- # responce['data']['id']
148
- # else
149
- # nil
150
- # end
151
- # end
152
- #
153
- # def find(id)
154
- # uri = build_uri('deals', id)
155
- # raw = ::JSON.parse(Net::HTTP.get(uri))['data']
156
- # Pipedrive::Deal.new(raw)
157
- # end
158
- #
159
- # def first
160
- # self.all.first
161
- # end
162
- # end
163
- #
164
- # class PersonsService < Pipedrive::Service
165
- # # def all
166
- # # uri = build_uri('persons')
167
- # # json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
168
- # # json_array.map{|raw|Pipedrive::Person.new(raw)}
169
- # # end
170
- # def resource_name
171
- # 'person'
172
- # end
173
- #
174
- # def find(id)
175
- # uri = build_uri('persons', id)
176
- # raw = ::JSON.parse(Net::HTTP.get(uri))['data']
177
- # Pipedrive::Person.new(raw)
178
- # end
179
- #
180
- # def first
181
- # self.all.first
182
- # end
183
- # end
184
- #
185
- # class StagesService < Pipedrive::Service
186
- # # def all
187
- # # uri = build_uri('stages')
188
- # # json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
189
- # # json_array.map{|raw|Pipedrive::Stage.new(raw)}
190
- # # end
191
- #
192
- # def resource_name
193
- # 'stage'
194
- # end
195
- #
196
- # def find(id)
197
- # uri = build_uri('stages', id)
198
- # raw = ::JSON.parse(Net::HTTP.get(uri))['data']
199
- # Pipedrive::Stage.new(raw)
200
- # end
201
- #
202
- # def first
203
- # self.all.first
204
- # end
205
- # end
206
-
207
- HOST = 'https://api.pipedrive.com/v1'
208
-
209
- #Service Methods
210
-
211
- # def activities
212
- # uri = build_uri('activities')
213
- # ::JSON.parse(Net::HTTP.get(uri))['data']
214
- # end
215
- #
216
- # def activity_types
217
- # uri = build_uri('activities')
218
- # ::JSON.parse(Net::HTTP.get(uri))['data']
219
- # end
220
-
221
- #POST
222
-
223
- # def add_activity(subject, type, deal_id, due_date = nil, due_time = nil, duration = nil, org_id = nil)
224
- # uri = build_uri('activities')
225
- # response = Net::HTTP.post_form(uri, subject: subject, type: type, deal_id: deal_id, due_date: due_date, due_time: due_time, duration: duration, org_id: org_id)
226
- #
227
- # response.kind_of? Net::HTTPSuccess
228
- # end
229
- #
230
- # def add_deal(title, value = nil, user_id = nil, person_id = nil, org_id = nil)
231
- # uri = build_uri('deals')
232
- # response = Net::HTTP.post_form(uri, title: title, value: value, user_id: user_id, person_id: person_id, org_id: org_id)
233
- #
234
- # response.kind_of? Net::HTTPSuccess
235
- # end
236
26
  end
@@ -0,0 +1,22 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+ require 'pipedrive_jetrockets/organisation'
3
+ require 'pipedrive_jetrockets/person'
4
+
5
+ module PipedriveJetrockets
6
+ class Deal < Entity
7
+ attr_accessor :add_time, :id, :organisation, :title, :value, :currency, :status, :stage_id, :person
8
+ def initialize(hash)
9
+ super
10
+ @organisation = Organisation.new(hash['org_id']) if hash['org_id']
11
+ @person = Person.new(hash['person_id']) if hash['person_id']
12
+ end
13
+
14
+ def stage
15
+ Pipedrive.stages.find(self.stage_id)
16
+ end
17
+
18
+ def display_stage_name
19
+ self.stage.display_name
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ module PipedriveJetrockets
2
+ class Entity
3
+ def initialize(hash)
4
+ hash.each {|k,v| instance_variable_set("@#{k}",v)}
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+
3
+ module PipedriveJetrockets
4
+ class Note < Entity
5
+ attr_accessor :id, :deal_id, :person_id, :org_id, :content
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+
3
+ module PipedriveJetrockets
4
+ class Organisation < Entity
5
+ attr_accessor :id, :name, :owner_id, :address, :cc_email
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+
3
+ module PipedriveJetrockets
4
+ class Person < Entity
5
+ attr_accessor :name, :email, :phone
6
+ def initialize(hash)
7
+ super
8
+ @email = hash['email'].first['value'] if hash['email']
9
+ @phone = hash['phone'].first['value'] if hash['phone']
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+
3
+ module PipedriveJetrockets
4
+ class Pipeline < Entity
5
+ attr_accessor :id, :name
6
+ end
7
+ end
@@ -0,0 +1,53 @@
1
+ require 'pipedrive_jetrockets/deal'
2
+ require 'pipedrive_jetrockets/note'
3
+ require 'pipedrive_jetrockets/organisation'
4
+ require 'pipedrive_jetrockets/person'
5
+ require 'pipedrive_jetrockets/pipeline'
6
+ require 'pipedrive_jetrockets/stage'
7
+ require 'pipedrive_jetrockets/user'
8
+
9
+ module PipedriveJetrockets
10
+ class Service
11
+ HOST = 'https://api.pipedrive.com/v1'
12
+
13
+ def initialize(resource_name)
14
+ @resource_name = resource_name
15
+ end
16
+
17
+ def build_entity(raw)
18
+ "PipedriveJetrockets::#{@resource_name.titleize}".constantize.new(raw)
19
+ end
20
+
21
+ def build_uri(id = nil)
22
+ uri = URI("#{HOST}/#{@resource_name.pluralize}/#{id}?api_token=#{ENV['pipedrive_api_token']}")
23
+ end
24
+
25
+ def all
26
+ uri = build_uri
27
+ json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
28
+ json_array.map{|raw|build_entity(raw)}
29
+ end
30
+
31
+ def create(params)
32
+ uri = build_uri
33
+ response = Net::HTTP.post_form(uri, params)
34
+
35
+ if response.kind_of? Net::HTTPSuccess
36
+ JSON.parse(response.body)['data']['id']
37
+ else
38
+ nil
39
+ end
40
+ end
41
+
42
+ def find(id)
43
+ uri = build_uri(id)
44
+ raw = ::JSON.parse(Net::HTTP.get(uri))['data']
45
+ build_entity(raw)
46
+ end
47
+
48
+ def first
49
+ self.all.first
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,15 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+
3
+ module PipedriveJetrockets
4
+ class Stage < Entity
5
+ attr_accessor :id, :name, :pipeline_id
6
+
7
+ def pipeline
8
+ Pipedrive.pipelines.find(self.pipeline_id)
9
+ end
10
+
11
+ def display_name
12
+ "#{pipeline.name}:#{name}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'pipedrive_jetrockets/entity'
2
+
3
+ module PipedriveJetrockets
4
+ class User < Entity
5
+ attr_accessor :id, :name, :email, :phone
6
+ end
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipedrive_jetrockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.40
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agafonov Maksim
@@ -19,7 +19,16 @@ files:
19
19
  - app/controllers/pipedrive_jetrockets/events_controller.rb
20
20
  - config/routes.rb
21
21
  - lib/pipedrive_jetrockets.rb
22
+ - lib/pipedrive_jetrockets/deal.rb
22
23
  - lib/pipedrive_jetrockets/engine.rb
24
+ - lib/pipedrive_jetrockets/entity.rb
25
+ - lib/pipedrive_jetrockets/note.rb
26
+ - lib/pipedrive_jetrockets/organisation.rb
27
+ - lib/pipedrive_jetrockets/person.rb
28
+ - lib/pipedrive_jetrockets/pipeline.rb
29
+ - lib/pipedrive_jetrockets/service.rb
30
+ - lib/pipedrive_jetrockets/stage.rb
31
+ - lib/pipedrive_jetrockets/user.rb
23
32
  homepage: http://rubygems.org/gems/hola
24
33
  licenses:
25
34
  - MIT