pipedrive_jetrockets 0.0.24 → 0.0.38
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 +4 -4
- data/lib/pipedrive_jetrockets.rb +56 -48
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ab9b0331d3fc8ea29b5b64749ded2cd2511b85cfd7bdb4913e7385c611d7ab9
|
4
|
+
data.tar.gz: '08e9f87c78bd71c42af0e9d147c9e5b3a651c738ff60c8a8553fd854221af1af'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a1cab1b4c9b4579c9cc8301ebb68b89b198416e569cd6ff0e343d463b83f27f95dfd35b9608390839d6483aec73d73780aade6f4d784f361be758d63f1c748e
|
7
|
+
data.tar.gz: 505e552ee66b29a157d1d85925f706f0d9b4977f0114635aa267d1fb9620d6ac06a9186dbee39482bd92219f64c0ae0403f77b3d336b07f1dc73669e6e754fca
|
data/lib/pipedrive_jetrockets.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'pipedrive_jetrockets/engine'
|
3
3
|
|
4
|
-
class
|
4
|
+
class Pipedrive
|
5
|
+
|
6
|
+
def self.deals
|
7
|
+
@@deals_service ||= Pipedrive::DealsService.new
|
8
|
+
end
|
9
|
+
|
5
10
|
#Entities
|
6
11
|
|
7
12
|
class Entity
|
@@ -10,40 +15,45 @@ class PipedriveAPI
|
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
13
|
-
class
|
14
|
-
attr_accessor :name, :owner_id, :address, :cc_email
|
18
|
+
class Organisation < Pipedrive::Entity
|
19
|
+
attr_accessor :id, :name, :owner_id, :address, :cc_email
|
20
|
+
end
|
21
|
+
|
22
|
+
class Person < Pipedrive::Entity
|
23
|
+
attr_accessor :name, :email, :phone
|
24
|
+
def initialize(hash)
|
25
|
+
super
|
26
|
+
@email = hash['email'].first['value'] if hash['email']
|
27
|
+
@phone = hash['phone'].first['value'] if hash['phone']
|
28
|
+
end
|
15
29
|
end
|
16
30
|
|
17
|
-
class User <
|
18
|
-
attr_accessor :id, :name, :email
|
31
|
+
class User < Pipedrive::Entity
|
32
|
+
attr_accessor :id, :name, :email, :phone
|
19
33
|
end
|
20
34
|
|
21
|
-
class Deal <
|
22
|
-
attr_accessor :id, :
|
35
|
+
class Deal < Pipedrive::Entity
|
36
|
+
attr_accessor :id, :organisation, :title, :value, :currency, :status, :stage_id, :person
|
23
37
|
def initialize(hash)
|
24
38
|
super
|
25
|
-
@
|
26
|
-
@
|
39
|
+
@organisation = Pipedrive::Organisation.new(hash['org_id']) if hash['org_id']
|
40
|
+
@person = Pipedrive::Person.new(hash['person_id']) if hash['person_id']
|
27
41
|
end
|
28
42
|
end
|
29
43
|
|
30
44
|
#Services
|
31
45
|
|
32
46
|
class Service
|
33
|
-
def
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def build_uri(action)
|
38
|
-
uri = URI("#{PipedriveAPI::HOST}/#{action}?api_token=#{@api_token}")
|
47
|
+
def build_uri(action, id = nil)
|
48
|
+
uri = URI("#{Pipedrive::HOST}/#{action}/#{id}?api_token=#{ENV['pipedrive_api_token']}")
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
42
|
-
class DealsService <
|
52
|
+
class DealsService < Pipedrive::Service
|
43
53
|
def all
|
44
54
|
uri = build_uri('deals')
|
45
55
|
json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
|
46
|
-
json_array.map{|raw|
|
56
|
+
json_array.map{|raw|Pipedrive::Deal.new(raw)}
|
47
57
|
end
|
48
58
|
|
49
59
|
def create(title, value = nil, user_id = nil, person_id = nil, org_id = nil)
|
@@ -53,6 +63,12 @@ class PipedriveAPI
|
|
53
63
|
response.kind_of? Net::HTTPSuccess
|
54
64
|
end
|
55
65
|
|
66
|
+
def find(id)
|
67
|
+
uri = build_uri('deals', id)
|
68
|
+
raw = ::JSON.parse(Net::HTTP.get(uri))['data']
|
69
|
+
Pipedrive::Deal.new(raw)
|
70
|
+
end
|
71
|
+
|
56
72
|
def first
|
57
73
|
self.all.first
|
58
74
|
end
|
@@ -60,39 +76,31 @@ class PipedriveAPI
|
|
60
76
|
|
61
77
|
HOST = 'https://api.pipedrive.com/v1'
|
62
78
|
|
63
|
-
|
64
|
-
@api_token = api_token
|
65
|
-
end
|
66
|
-
|
67
|
-
#Actions
|
68
|
-
|
69
|
-
def deals
|
70
|
-
@deals_serice ||= PipedriveAPI::DealsService.new(@api_token)
|
71
|
-
end
|
72
|
-
|
73
|
-
def activities
|
74
|
-
uri = build_uri('activities')
|
75
|
-
::JSON.parse(Net::HTTP.get(uri))['data']
|
76
|
-
end
|
79
|
+
#Service Methods
|
77
80
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
end
|
81
|
+
# def activities
|
82
|
+
# uri = build_uri('activities')
|
83
|
+
# ::JSON.parse(Net::HTTP.get(uri))['data']
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# def activity_types
|
87
|
+
# uri = build_uri('activities')
|
88
|
+
# ::JSON.parse(Net::HTTP.get(uri))['data']
|
89
|
+
# end
|
82
90
|
|
83
91
|
#POST
|
84
92
|
|
85
|
-
def add_activity(subject, type, deal_id, due_date = nil, due_time = nil, duration = nil, org_id = nil)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
def add_deal(title, value = nil, user_id = nil, person_id = nil, org_id = nil)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
93
|
+
# def add_activity(subject, type, deal_id, due_date = nil, due_time = nil, duration = nil, org_id = nil)
|
94
|
+
# uri = build_uri('activities')
|
95
|
+
# 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)
|
96
|
+
#
|
97
|
+
# response.kind_of? Net::HTTPSuccess
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# def add_deal(title, value = nil, user_id = nil, person_id = nil, org_id = nil)
|
101
|
+
# uri = build_uri('deals')
|
102
|
+
# response = Net::HTTP.post_form(uri, title: title, value: value, user_id: user_id, person_id: person_id, org_id: org_id)
|
103
|
+
#
|
104
|
+
# response.kind_of? Net::HTTPSuccess
|
105
|
+
# end
|
98
106
|
end
|