rdgem 0.1.34 → 0.1.35
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 +8 -13
- 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: de80e8b0822ba009febe13abda7a104e26bc5b50
|
4
|
+
data.tar.gz: 334a0de06a81442cfb084be29168ec364aaaffb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cb71d06fe8a6749611183f2ea7380c9fb6997c4836a79f86e684b97afc141634dbc891572a834dfea7c5d0d5fee4a2dd21e598743f8ada98ccb310adb40d275
|
7
|
+
data.tar.gz: db9764a49a8650f96f359a4919c47abf5831b3c272baa9e8877a2dc8114791eccf214f23d3e936ec1883a39a89dda53c0508a84779a88286965dc66701e813df
|
data/lib/rdgem/version.rb
CHANGED
data/lib/rdgem.rb
CHANGED
@@ -5,6 +5,7 @@ require 'httparty'
|
|
5
5
|
|
6
6
|
module Rdgem
|
7
7
|
# Your code goes here...
|
8
|
+
# global declarations
|
8
9
|
PIPEDRIVE_API = "https://api.pipedrive.com/v1/"
|
9
10
|
TOKEN = "api_token="
|
10
11
|
HEADERS = {'Accept'=>'application/json',
|
@@ -85,17 +86,17 @@ module Rdgem
|
|
85
86
|
return field_api_key
|
86
87
|
end
|
87
88
|
|
88
|
-
#
|
89
|
+
#checks if the key is valid and if the custom fields are created in the acc
|
90
|
+
# if any field is missing, create it
|
89
91
|
def self.assert_fields(fields, app_key)
|
90
92
|
@field_key = []
|
91
93
|
|
92
94
|
query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
|
93
95
|
|
94
96
|
response = HTTParty.get(query)
|
95
|
-
puts "field_key_begin",@field_key
|
96
97
|
|
97
98
|
if response["success"]
|
98
|
-
#
|
99
|
+
#Assert: looks for the desired fields
|
99
100
|
fields.each_with_index do |assert, index|
|
100
101
|
response["data"].each do |search|
|
101
102
|
if search['name'] == assert
|
@@ -103,16 +104,13 @@ module Rdgem
|
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
106
|
-
puts "field_key middle",@field_key
|
107
107
|
|
108
|
-
# create missing fields
|
108
|
+
# Integrate: create missing fields
|
109
109
|
fields.each_with_index do |create, index|
|
110
110
|
if @field_key[index].blank?
|
111
|
-
puts "blank field",@field_key[index]
|
112
111
|
@field_key[index] = create_field(app_key, create)
|
113
112
|
end
|
114
113
|
end
|
115
|
-
puts "field_key end",@field_key
|
116
114
|
|
117
115
|
#Hash the info
|
118
116
|
custom_field = Hash[fields.zip(@field_key.map \
|
@@ -122,12 +120,10 @@ module Rdgem
|
|
122
120
|
return false
|
123
121
|
end
|
124
122
|
end
|
125
|
-
|
123
|
+
#ship it back
|
126
124
|
return custom_field
|
127
125
|
end
|
128
|
-
|
129
|
-
#checks if the key is valid and if the custom fields are created in the acc
|
130
|
-
# if any field is missing, create it
|
126
|
+
|
131
127
|
## even if populated the field key will always be replaced
|
132
128
|
def self.create_field(app_key, field_name)
|
133
129
|
field_api_key = false
|
@@ -153,5 +149,4 @@ module Rdgem
|
|
153
149
|
end
|
154
150
|
return field_api_key
|
155
151
|
end
|
156
|
-
|
157
|
-
end
|
152
|
+
end
|