callrail 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/callrail.rb +25 -39
- data/lib/callrail/version.rb +1 -1
- 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: 755f0a7d0503a15aa630debbb1bc4e93a9d1ed70
|
4
|
+
data.tar.gz: e4ade5757b8caa6ac48e8e8bfb4de30f2dd4af1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 300a031b407ba7bd46762784d0d0d5c8d445585ed3ae8f89f408c949aeb595d7d40c59368470a22d509626512655d46d5edf6c95a83fa6efce794d3a343711e8
|
7
|
+
data.tar.gz: 5e5a03de59af3a266cada07bae9c566302e036b220bd9f067936133a8a5e45fe5a3342d8878d836ee7c8df684a2d0c842bfdc192f158fa919184e5f300df26a9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -90,6 +90,12 @@ testcon.disable_company(opts)
|
|
90
90
|
###### Get Users
|
91
91
|
``` testcon.get_users ```
|
92
92
|
|
93
|
+
###### Get Users For a specific company
|
94
|
+
```
|
95
|
+
user_opts = {:company_id => <company_id>}
|
96
|
+
puts testcon.get_users(user_opts)
|
97
|
+
```
|
98
|
+
|
93
99
|
###### Get Specific User
|
94
100
|
```
|
95
101
|
opts[:user_id] = <user_id>
|
data/lib/callrail.rb
CHANGED
@@ -100,48 +100,39 @@ module Callrail
|
|
100
100
|
# Filtering: date_range
|
101
101
|
# Searching: customer_phone_number, customer_name
|
102
102
|
#pagination
|
103
|
-
params[:total_records] = get_total_records(params) if opts[:path]
|
104
|
-
params[:total_pages] = get_total_pages(params) if opts[:path]
|
105
103
|
|
106
104
|
return params
|
107
105
|
end
|
108
106
|
|
109
|
-
def get_total_records(params)
|
110
|
-
total_records = parse_json(RestClient.get(@url+params[:path], params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body['total_records'] || 1
|
111
|
-
return total_records
|
112
|
-
end
|
113
|
-
|
114
|
-
def get_total_pages(params)
|
115
|
-
total_pages = parse_json(RestClient.get(@url+params[:path], params: params, :content_type => 'application/json', :accept => 'application/json', :Authorization => @auth)).body['total_pages'] || 1
|
116
|
-
return total_pages
|
117
|
-
end
|
118
|
-
|
119
107
|
def get_responses(opts = {})
|
120
108
|
responses = []
|
121
109
|
params = set_params(opts)
|
122
|
-
|
123
|
-
|
124
|
-
|
110
|
+
response = parse_json(RestClient.get(@url+params[:path], params: params,:Authorization => @auth)).body
|
111
|
+
total_pages = response["total_pages"] || 1
|
112
|
+
total_records = response["total_records"] || 1
|
113
|
+
|
114
|
+
while total_pages > 0
|
115
|
+
response = (opts[:data]) ? response[opts[:data]] : response
|
125
116
|
responses.push(response)
|
126
117
|
params[:page] += 1 unless opts[:page]
|
127
|
-
|
118
|
+
total_pages -= 1
|
119
|
+
response = parse_json(RestClient.get(@url+params[:path], params: params,:Authorization => @auth)).body
|
128
120
|
end
|
129
|
-
return responses
|
121
|
+
return responses.flatten! || responses
|
130
122
|
end
|
123
|
+
|
131
124
|
# Account Calls
|
132
125
|
def get_accounts(opts = {})
|
133
126
|
opts[:path] = (opts[:account_id]) ? "/" + opts[:account_id].to_s + ".json" : ".json"
|
134
127
|
opts[:data] = "accounts" unless opts[:account_id]
|
135
|
-
|
136
|
-
return results
|
128
|
+
return get_responses(opts)
|
137
129
|
end
|
138
130
|
|
139
131
|
# Company Calls
|
140
132
|
def get_companies(opts = {})
|
141
133
|
opts[:path] = (opts[:company_id]) ? "/" + @account_id + "/companies/" + opts[:company_id].to_s + ".json" : "/" + @account_id + "/companies.json"
|
142
134
|
opts[:data] = "companies" unless opts[:company_id]
|
143
|
-
|
144
|
-
return results
|
135
|
+
return get_responses(opts)
|
145
136
|
end
|
146
137
|
|
147
138
|
def create_company(opts = {}) # http://apidocs.callrail.com/#time-zones
|
@@ -154,84 +145,79 @@ module Callrail
|
|
154
145
|
def update_company(opts = {})
|
155
146
|
params = set_params(opts)
|
156
147
|
path = "/" + @account_id + "/companies/" + opts[:company_id].to_s + ".json"
|
157
|
-
|
148
|
+
return parse_json(RestClient.put(@url+path, params, :Authorization => @auth)).body
|
158
149
|
end
|
159
150
|
|
160
151
|
def disable_company( opts = {})
|
161
152
|
path = "/" + @account_id + "/companies/" + opts[:company_id].to_s
|
162
|
-
|
153
|
+
return parse_json(RestClient.delete(@url+path, :Authorization => @auth))
|
163
154
|
end
|
164
155
|
|
165
156
|
# User Calls
|
166
157
|
def get_users( opts={} )
|
167
158
|
opts[:path] = (opts[:user_id]) ? "/" + @account_id + "/users/" + opts[:user_id].to_s + ".json" : "/" + @account_id + "/users.json"
|
168
159
|
opts[:data] = "users" unless opts[:user_id]
|
169
|
-
|
170
|
-
return results
|
160
|
+
return get_responses(opts)
|
171
161
|
end
|
172
162
|
|
173
163
|
def create_user( opts = {})
|
174
164
|
params = set_params(opts)
|
175
165
|
path = "/" + @account_id + "/users.json"
|
176
|
-
|
177
|
-
return response
|
166
|
+
return parse_json(RestClient.post(@url+path, params ,:Authorization => @auth))
|
178
167
|
end
|
179
168
|
|
180
169
|
def update_user(opts = {})
|
181
170
|
params = set_params(opts)
|
182
171
|
path = "/" + @account_id + "/users/" + opts[:user_id].to_s + ".json"
|
183
|
-
|
172
|
+
return parse_json(RestClient.put(@url+path, params, :Authorization => @auth))
|
184
173
|
end
|
185
174
|
|
186
175
|
# Tracker Calls
|
187
176
|
def get_trackers(opts={})
|
188
177
|
opts[:path] = (opts[:tracker_id]) ? "/" + @account_id + "/trackers/" + opts[:tracker_id].to_s + ".json" : "/" + @account_id + "/trackers.json"
|
189
178
|
opts[:data] = "trackers" unless opts[:tracker_id]
|
190
|
-
|
179
|
+
return get_responses(opts)
|
191
180
|
end
|
192
181
|
|
193
182
|
def create_tracker(opts={})
|
194
183
|
opts[:path] = "/" + @account_id + "/trackers.json"
|
195
184
|
params = set_params(opts)
|
196
|
-
|
197
|
-
return response
|
185
|
+
return parse_json(RestClient.post(@url+opts[:path], params ,:Authorization => @auth))
|
198
186
|
end
|
199
187
|
|
200
188
|
def update_tracker(opts={})
|
201
189
|
opts[:path] = "/" + @account_id + "/trackers/" + opts[:tracker_id] + ".json"
|
202
190
|
params = set_params(opts)
|
203
|
-
|
191
|
+
return parse_json(RestClient.put(@url+path, params, :Authorization => @auth))
|
204
192
|
end
|
205
193
|
|
206
194
|
def disable_tracker(opts={})
|
207
195
|
path = "/" + @account_id + "/trackers/" + opts[:tracker_id] + ".json"
|
208
|
-
|
196
|
+
return parse_json(RestClient.delete(@url+path, :Authorization => @auth))
|
209
197
|
end
|
210
198
|
|
211
199
|
# Integrations
|
212
200
|
def get_integrations(opts ={})
|
213
201
|
opts[:path] = (opts[:integration_id]) ? "/" + @account_id + "/integrations/" + opts[:integration_id].to_s + ".json" : "/" + @account_id + "/integrations.json"
|
214
202
|
opts[:data] = "integrations" unless opts[:integration_id]
|
215
|
-
|
216
|
-
return results
|
203
|
+
return get_responses(opts)
|
217
204
|
end
|
218
205
|
|
219
206
|
def create_integration(opts ={})
|
220
207
|
opts[:path] = "/" + @account_id + "/integrations.json"
|
221
208
|
params = set_params(opts)
|
222
|
-
|
223
|
-
return response
|
209
|
+
return parse_json(RestClient.post(@url+opts[:path], params ,:Authorization => @auth))
|
224
210
|
end
|
225
211
|
|
226
212
|
def update_integration(opts = {})
|
227
213
|
params = set_params(opts)
|
228
214
|
path = "/" + @account_id + "/integrations/" + opts[:integration_id].to_s + ".json"
|
229
|
-
|
215
|
+
return parse_json(RestClient.put(@url+path, params, :Authorization => @auth))
|
230
216
|
end
|
231
217
|
|
232
218
|
def disable_integration(opts={})
|
233
219
|
path = "/" + @account_id + "/integrations/" + opts[:integration_id].to_s + ".json"
|
234
|
-
|
220
|
+
return parse_json(RestClient.delete(@url+path, :Authorization => @auth))
|
235
221
|
end
|
236
222
|
|
237
223
|
end
|
data/lib/callrail/version.rb
CHANGED