pipedrive_jetrockets 0.0.13 → 0.0.14
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/config/routes.rb +3 -0
- data/lib/pipedrive_jetrockets.rb +98 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b798adb157e8825faac7b32baebd41f3613c3f0a57ad39e5932b3e516e82132
|
4
|
+
data.tar.gz: 2daac400b9ec927cc5aef91ee5d688af4794572d2b39a0e657f1019988df2712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da82fe6601fe0f23b74c5c6b0b09593b47faaca2d889e06ba7fac3ef0dc102ddcc9b49bfb7a881a4e80dd43d0aacee68fc0d3f1a3c513ea367cfeea6e965751
|
7
|
+
data.tar.gz: 4504dc911721b84622a397b2ce0eb7da3abef844b607d02f13d57a1a0fa050d67a93e76bd8e825a674689e7e5452249b636b7032f9a9556fa114615ca7f7cdd5
|
data/config/routes.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'pipedrive_jetrockets/engine'
|
3
|
+
|
4
|
+
class PipedriveAPI
|
5
|
+
#Entities
|
6
|
+
|
7
|
+
class Entity
|
8
|
+
def initialize(hash)
|
9
|
+
hash.each {|k,v| instance_variable_set("@#{k}",v)}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Organization < PipedriveAPI::Entity
|
14
|
+
attr_accessor :name, :owner_id, :address, :cc_email
|
15
|
+
end
|
16
|
+
|
17
|
+
class User < PipedriveAPI::Entity
|
18
|
+
attr_accessor :id, :name, :email
|
19
|
+
end
|
20
|
+
|
21
|
+
class Deal < PipedriveAPI::Entity
|
22
|
+
attr_accessor :id, :creator, :organization, :title, :value, :currency, :status
|
23
|
+
def initialize(hash)
|
24
|
+
super
|
25
|
+
@creator = PipedriveAPI::User.new(hash['creator_user_id']) if hash['creator_user_id']
|
26
|
+
@organization = PipedriveAPI::Organization.new(hash['org_id']) if hash['org_id']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#Services
|
31
|
+
|
32
|
+
class Service
|
33
|
+
def initialize(api_token)
|
34
|
+
@api_token = api_token
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_uri(action)
|
38
|
+
uri = URI("#{PipedriveAPI::HOST}/#{action}?api_token=#{@api_token}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class DealsService < PipedriveAPI::Service
|
43
|
+
def all
|
44
|
+
uri = build_uri('deals')
|
45
|
+
json_array = ::JSON.parse(Net::HTTP.get(uri))['data']
|
46
|
+
json_array.map{|raw|PipedriveAPI::Deal.new(raw)}
|
47
|
+
end
|
48
|
+
|
49
|
+
def create(title, value = nil, user_id = nil, person_id = nil, org_id = nil)
|
50
|
+
uri = build_uri('deals')
|
51
|
+
response = Net::HTTP.post_form(uri, title: title, value: value, user_id: user_id, person_id: person_id, org_id: org_id)
|
52
|
+
|
53
|
+
response.kind_of? Net::HTTPSuccess
|
54
|
+
end
|
55
|
+
|
56
|
+
def first
|
57
|
+
self.all.first
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
HOST = 'https://api.pipedrive.com/v1'
|
62
|
+
|
63
|
+
def initialize(api_token)
|
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
|
77
|
+
|
78
|
+
def activity_types
|
79
|
+
uri = build_uri('activities')
|
80
|
+
::JSON.parse(Net::HTTP.get(uri))['data']
|
81
|
+
end
|
82
|
+
|
83
|
+
#POST
|
84
|
+
|
85
|
+
def add_activity(subject, type, deal_id, due_date = nil, due_time = nil, duration = nil, org_id = nil)
|
86
|
+
uri = build_uri('activities')
|
87
|
+
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)
|
88
|
+
|
89
|
+
response.kind_of? Net::HTTPSuccess
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_deal(title, value = nil, user_id = nil, person_id = nil, org_id = nil)
|
93
|
+
uri = build_uri('deals')
|
94
|
+
response = Net::HTTP.post_form(uri, title: title, value: value, user_id: user_id, person_id: person_id, org_id: org_id)
|
95
|
+
|
96
|
+
response.kind_of? Net::HTTPSuccess
|
97
|
+
end
|
98
|
+
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.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agafonov Maksim
|
@@ -16,6 +16,8 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- config/routes.rb
|
20
|
+
- lib/pipedrive_jetrockets.rb
|
19
21
|
- lib/pipedrive_jetrockets/engine.rb
|
20
22
|
homepage: http://rubygems.org/gems/hola
|
21
23
|
licenses:
|