7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/models/property_solutions/api_consumer.rb', line 7
def self.request(method, data = nil)
data = {} if data.nil?
data.delete_if { |k,v| v.nil? }
data = {
'auth' => {
'type' => "basic",
'username' => PropertySolutions::username,
'password' => PropertySolutions::password,
},
'method' => {
'name' => method, 'params' => data }
}
resp = Typhoeus::Request.new(
"https://#{PropertySolutions::domain}.propertysolutions.com/api/#{@@base}",
method: :post,
headers: { 'Content-type' => 'application/json, charset: utf-8' },
body: data.to_json
).run
resp = JSON.parse(resp.response_body)
if (resp['response'].nil? || !resp['response']['error'].nil? || resp['response']['result'].nil?)
return false
end
return resp = resp['response']['result']
end
|