rdgem 0.1.21 → 0.1.22

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 +18 -19
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a643eb6bc7d2a49634344f25f9223f9e8e839be0
4
- data.tar.gz: 6245956f53019971dca4556367309c284ef8ddac
3
+ metadata.gz: 6b3f876dd490bcc6f8ad8381a43698db7c488e49
4
+ data.tar.gz: 65165d1ab20d17e90d1f105ad7f3fdb09af8a036
5
5
  SHA512:
6
- metadata.gz: 04fdaf35e9bf2ff6adb6b71fda1ee876dccdb4e9f72669e2089e89aa4d991d6541b27a3a0ea0732f9122a730edcb3c92cf6c9c736df751faf112c246732eab12
7
- data.tar.gz: 4c7a56edf214c3926dc701ae8646c0f0dbfd2c51ab1070f7fdc68150ff43a59ddf4a413d8429db3309e36fb35bcfb3d1f3ab982593e33ec11f706b29554cd4c3
6
+ metadata.gz: 2ee194e76b7fc5473976108d04bbc32b17d715370a50b98248df5bdd4fadeb300ebfa6af6519f0e1201b3b094718377ccecca36d23b4d4a98de773bc75f2db5e
7
+ data.tar.gz: ba0ad2e4ed6305351ad59b859dec09cb81b4e64ae34e0a992cee507598d1f6efd4d1eb39a1dfd8085902557f30531daeee713dcaa0b3270bc3da363a04107da0
data/lib/rdgem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rdgem
2
- VERSION = "0.1.21"
2
+ VERSION = "0.1.22"
3
3
  end
data/lib/rdgem.rb CHANGED
@@ -14,14 +14,19 @@ module Rdgem
14
14
  #pushes the lead to pipedrive
15
15
  def self.send_lead(app_key, lead_to_person)
16
16
  query = PIPEDRIVE_API + 'persons?' + TOKEN + app_key
17
- response = HTTParty.post(query, :body => lead_to_person, :headers => HEADERS)
17
+
18
+ response = HTTParty.post(query,
19
+ :body => lead_to_person,
20
+ :headers => HEADERS)
18
21
  end
19
22
 
20
23
  #queries for a company name. creates when it doesn't exist.
21
24
  def self.get_or_create_company(app_key, company)
22
25
  org_app_id = ""
26
+
23
27
  query = PIPEDRIVE_API + 'organizations/find?term=' \
24
28
  + company + '&start=0&' + TOKEN + app_key
29
+
25
30
  response = HTTParty.get(query)
26
31
  #if successfull and with content, get the company app_key
27
32
  #so as not to create another with the same name
@@ -40,8 +45,8 @@ module Rdgem
40
45
  input_query = PIPEDRIVE_API + 'organizations?' + TOKEN + app_key
41
46
 
42
47
  org_response = HTTParty.post(input_query,
43
- :body => {:name =>company},
44
- :headers => HEADERS )
48
+ :body => {:name =>company},
49
+ :headers => HEADERS )
45
50
 
46
51
  unless org_response["data"] == nil
47
52
  org_app_id = org_response["data"]["id"]
@@ -60,13 +65,15 @@ module Rdgem
60
65
  input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
61
66
 
62
67
  response = HTTParty.post(input_query,
63
- :body => {:name =>"#{field_name}", :field_type => "varchar"},
64
- :headers => HEADERS )
68
+ :body => {:name =>"#{field_name}",
69
+ :field_type => "varchar"},
70
+ :headers => HEADERS )
65
71
 
66
72
  unless response["data"] == nil
67
73
  field_api_id = response["data"]["id"]
74
+
68
75
  key_query = PIPEDRIVE_API + 'personFields/'\
69
- + field_api_id.to_s + "?" + TOKEN + app_key
76
+ + field_api_id.to_s + "?" + TOKEN + app_key
70
77
 
71
78
 
72
79
  field_key_response = HTTParty.get(key_query)
@@ -97,29 +104,20 @@ module Rdgem
97
104
  #Hash the info
98
105
  custom_field = Hash[fields.zip(@field_key.map \
99
106
  {|i| i.include?(',') ? (i.split /, /) : i})] #/
100
- puts "custom_field",custom_field
101
107
  #integrate missing fields
102
108
  custom_field.each do |create|
103
- puts "creating",create
104
109
  if create[1].blank?
105
- puts "created_before",create
106
110
  create[1] = create_field(app_key, create[0])
107
- puts "created_after",create
108
111
  end
109
112
  end
110
113
  else
111
114
  if response["error"] == "You need to be authorized to make this request."
112
- return response["error"]
115
+ return false
113
116
  end
114
117
  end
115
- puts "custom_field",custom_field
116
118
  return custom_field
117
119
  end
118
120
 
119
-
120
-
121
-
122
-
123
121
  #checks if the key is valid and if the custom fields are created in the acc
124
122
  # if any field is missing, create it
125
123
  ## even if populated the field key will always be replaced
@@ -129,14 +127,15 @@ module Rdgem
129
127
  input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
130
128
 
131
129
  response = HTTParty.post(input_query,
132
- :body => {:name =>"#{field_name}", :field_type => "varchar"},
133
- :headers => HEADERS )
130
+ :body => {:name =>"#{field_name}",
131
+ :field_type => "varchar"},
132
+ :headers => HEADERS )
134
133
 
135
134
  unless response["data"] == nil
136
135
  field_api_id = response["data"]["id"]
137
136
 
138
137
  key_query = PIPEDRIVE_API + 'personFields/'\
139
- + field_api_id.to_s + "?" + TOKEN + app_key
138
+ + field_api_id.to_s + "?" + TOKEN + app_key
140
139
 
141
140
  field_key_response = HTTParty.get(key_query)
142
141
 
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.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - gabriel