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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rdgem/version.rb +1 -1
  3. data/lib/rdgem.rb +39 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4bca0677e426d16e913c7711877cf758553b79d
4
- data.tar.gz: 66a29a81ad071fa354f9ef7eee49f78662cf261c
3
+ metadata.gz: 193d9b87071dea4f390b99b4ac3284cb0b5e6e61
4
+ data.tar.gz: b99927f3f0200c22b3f50d7ebdad8f06924fc80b
5
5
  SHA512:
6
- metadata.gz: e1a052d4ed740984a0c408b7ed673312428171f372b63bcb563c5853f863d1e5c22968cf425b8a1dc616104955481c83129009bb58ffd965257d18df10122efb
7
- data.tar.gz: 396a4e51a121bf2c8893a802b9c207023b005bc2518071b877bff67afb57eb04e182733d2ae2b6a29de0fd6882674d803a90b206a29f6d801daa3a9de3415c4e
6
+ metadata.gz: 9a46d1596791c13ce3e246389b00bdbe221cf276f8f1691eba29ae787af4516f8dda3f8027cd24213953ce59efb2ccdba0f2e26aa1c7501102cb84016c3b98bc
7
+ data.tar.gz: 2e285708bd772d6fb3613619b1b05596d2b937bdd0a0efc07561c304c14e080b15ea2c06e8058e13d83278b9d1e23d82217e31ddd7892e191646c4902b8f2d91
data/lib/rdgem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rdgem
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - gabriel