rdgem 0.1.4 → 0.1.5
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/rdgem/version.rb +1 -1
- data/lib/rdgem.rb +39 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 193d9b87071dea4f390b99b4ac3284cb0b5e6e61
|
4
|
+
data.tar.gz: b99927f3f0200c22b3f50d7ebdad8f06924fc80b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a46d1596791c13ce3e246389b00bdbe221cf276f8f1691eba29ae787af4516f8dda3f8027cd24213953ce59efb2ccdba0f2e26aa1c7501102cb84016c3b98bc
|
7
|
+
data.tar.gz: 2e285708bd772d6fb3613619b1b05596d2b937bdd0a0efc07561c304c14e080b15ea2c06e8058e13d83278b9d1e23d82217e31ddd7892e191646c4902b8f2d91
|
data/lib/rdgem/version.rb
CHANGED
data/lib/rdgem.rb
CHANGED
@@ -11,8 +11,47 @@ module Rdgem
|
|
11
11
|
'Content-Type'=>'application/x-www-form-urlencoded',
|
12
12
|
'User-Agent'=>'Ruby.Pipedrive.Api' }
|
13
13
|
|
14
|
+
#pushes the lead to pipedrive
|
14
15
|
def self.send_lead(app_key, lead_to_person)
|
15
16
|
query = PIPEDRIVE_API + 'persons?' + TOKEN + app_key
|
16
17
|
response = HTTParty.post(query, :body => lead_to_person, :headers => HEADERS)
|
17
18
|
end
|
19
|
+
|
20
|
+
#queries for a company name. creates when it doesn't exist.
|
21
|
+
def self.get_or_create_company(app_key, company)
|
22
|
+
org_app_id = ""
|
23
|
+
query = PIPEDRIVE_API + 'organizations/find?term=' \
|
24
|
+
+ company + '&start=0&' + TOKEN + app_key
|
25
|
+
response = HTTParty.get(query)
|
26
|
+
puts "response",response
|
27
|
+
#if successfull and with content, get the company app_key
|
28
|
+
#so as not to create another with the same name
|
29
|
+
if response["success"]
|
30
|
+
unless response["data"] == nil
|
31
|
+
response["data"].each do |search|
|
32
|
+
if search['name'] == company
|
33
|
+
org_app_id = search['id']
|
34
|
+
puts "org_app_id",org_app_id
|
35
|
+
#not caring about duplicates.
|
36
|
+
#we will ensure we at least won't create any
|
37
|
+
break
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
#didn't find, create one
|
42
|
+
input_query = PIPEDRIVE_API + 'organizations?' + TOKEN + app_key
|
43
|
+
|
44
|
+
org_response = HTTParty.post(input_query, :body => HEADERS)
|
45
|
+
puts "org_response",org_response
|
46
|
+
|
47
|
+
unless org_response["data"] == nil
|
48
|
+
org_app_id = org_response["data"]["id"]
|
49
|
+
puts "org_app_id", org_app_id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
else
|
53
|
+
#error getting company
|
54
|
+
end
|
55
|
+
return org_app_id
|
56
|
+
end
|
18
57
|
end
|