g5_ygl_client_20 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/g5_ygl_client_20.rb +2 -2
- data/lib/g5_ygl_client_20/client.rb +4 -3
- data/lib/g5_ygl_client_20/requests/post_lead_request.rb +8 -2
- data/lib/g5_ygl_client_20/version.rb +1 -1
- data/spec/client_spec.rb +4 -2
- data/spec/requests/post_lead_request_spec.rb +25 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGY5MDE3NzAwNTY5NjI4ZTUzODIwNzVhNDMyMjQzODgyODFmNDVjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDc3ZjQ3MzA3NDZjMmI1NTQ5ZWUwMWY1NmI3NjcyMmJiN2RlZjJjNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGJiNzNkOTYyZGQ0YTBiYzM3YTNkZTdiMzVmYmYzMzg4Mzg0OTE5NDYwZDc0
|
10
|
+
ZjhmNTA2NmFkN2MxZmUyYzZhMzFiNjlhYjE1YzBhNGU4MDNkMjM1MGM2MjBi
|
11
|
+
MDEwOWE4MmMzMmMxZWQxMTcyNGRkMWIxYzY4NThhNWI2MzA0M2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDc5ODA3YTc5NDUyMWUxYzZjYzU1NjRkNWYxOWEwNTE4ZTUwNzM3OTNmNzQ4
|
14
|
+
MjU3YjgxZWM5NTJiNzgzYzQ2MGU5NmIzODU5NDZlNGE4ZTliYjIyYjhhZjRj
|
15
|
+
N2U4ZDFiNzc1OTIzNGM4MzM2Mjk3MTEwOTFhMWQ2MmQ4NzM5YzQ=
|
data/lib/g5_ygl_client_20.rb
CHANGED
@@ -17,7 +17,7 @@ module G5YglClient20
|
|
17
17
|
|
18
18
|
HOST = "www.youvegotleads.com"
|
19
19
|
|
20
|
-
def self.new(username, password, subscription_id, source_id)
|
21
|
-
client = G5YglClient20::Client.new(username, password, subscription_id, source_id)
|
20
|
+
def self.new(username, password, subscription_id, source_id, sub_source_id=nil)
|
21
|
+
client = G5YglClient20::Client.new(username, password, subscription_id, source_id, sub_source_id)
|
22
22
|
end
|
23
23
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module G5YglClient20
|
2
2
|
class Client
|
3
3
|
|
4
|
-
def initialize(username, password, subscription_id, source_id)
|
4
|
+
def initialize(username, password, subscription_id, source_id, sub_source_id)
|
5
5
|
@auth = "BASIC " + Base64.strict_encode64("#{username}:#{password}")
|
6
6
|
@url = "https://www.youvegotleads.com/api/properties/"
|
7
7
|
@subscription_id = subscription_id
|
8
|
-
@source_id = source_id || 588
|
8
|
+
@source_id = source_id || 588 #this magical code was for the first client - but should probably be removed
|
9
|
+
@sub_source_id = sub_source_id
|
9
10
|
end
|
10
11
|
|
11
12
|
def get_properties
|
@@ -17,7 +18,7 @@ module G5YglClient20
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def post_lead(property_id, lead)
|
20
|
-
request = PostLeadRequest.execute(@auth, @url, @source_id, property_id, lead)
|
21
|
+
request = PostLeadRequest.execute(@auth, @url, @source_id, @sub_source_id, property_id, lead)
|
21
22
|
end
|
22
23
|
|
23
24
|
def get_leads_for_property(property_id)
|
@@ -1,7 +1,13 @@
|
|
1
1
|
module G5YglClient20
|
2
2
|
class PostLeadRequest
|
3
|
+
# just for future reference
|
4
|
+
# Sub source id's are specific forms (tour request, Contact us, etc.) Source id's are more general, (Internet, G5, etc.)
|
5
|
+
# If there is a sub source id, pass it as the LeadSourceId, and pass source id as the RootLeadSourceId
|
6
|
+
# If the sub source id is nil, pass source id as the LeadSourceId, and don't pass a RootLeadSourceId
|
3
7
|
|
4
|
-
def self.execute(auth, url, source_id, property_id, lead)
|
8
|
+
def self.execute(auth, url, source_id, sub_source_id, property_id, lead)
|
9
|
+
referral_source_array = [{"LeadSourceId" => "#{sub_source_id.blank? ? source_id : sub_source_id}", "LeadSourceRank" => "1"}]
|
10
|
+
referral_source_array.first.merge!("RootLeadSourceId" => "#{source_id}") unless sub_source_id.blank?
|
5
11
|
response = HTTParty.post("#{url}#{property_id}/leads",
|
6
12
|
:headers => {"Authorization" => auth,
|
7
13
|
"Host" => HOST,
|
@@ -13,7 +19,7 @@ module G5YglClient20
|
|
13
19
|
"PhoneCell" => "#{lead[:phone]}"}},
|
14
20
|
"CallCenterId" => "G5-#{lead[:id]}",
|
15
21
|
"Notes" => {"Notes" => "#{lead[:notes]}"},
|
16
|
-
"ReferralSources" =>
|
22
|
+
"ReferralSources" => referral_source_array
|
17
23
|
}.to_json)
|
18
24
|
end
|
19
25
|
|
data/spec/client_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
module G5YglClient20
|
3
3
|
describe Client do
|
4
4
|
|
5
|
-
let(:client) {G5YglClient20::Client.new("shinyandchrome", "aquacola", 3, 44)}
|
5
|
+
let(:client) {G5YglClient20::Client.new("shinyandchrome", "aquacola", 3, 44, 666)}
|
6
6
|
|
7
7
|
describe "initialize" do
|
8
8
|
it "assigns" do
|
@@ -10,6 +10,7 @@ module G5YglClient20
|
|
10
10
|
client.instance_variable_get(:@url).should eq("https://www.youvegotleads.com/api/properties/")
|
11
11
|
client.instance_variable_get(:@subscription_id).should eq(3)
|
12
12
|
client.instance_variable_get(:@source_id).should eq(44)
|
13
|
+
client.instance_variable_get(:@sub_source_id).should eq(666)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -17,6 +18,7 @@ module G5YglClient20
|
|
17
18
|
let(:auth) {"BASIC c2hpbnlhbmRjaHJvbWU6YXF1YWNvbGE="}
|
18
19
|
let(:subscription_id) {3}
|
19
20
|
let(:source_id) {44}
|
21
|
+
let(:sub_source_id) {666}
|
20
22
|
|
21
23
|
describe "get_properties" do
|
22
24
|
it "makes a Get Properties Request" do
|
@@ -34,7 +36,7 @@ module G5YglClient20
|
|
34
36
|
|
35
37
|
describe "post_lead" do
|
36
38
|
it "makes a Post Lead Request" do
|
37
|
-
expect(PostLeadRequest).to receive(:execute).with(auth, url, source_id, 1, {})
|
39
|
+
expect(PostLeadRequest).to receive(:execute).with(auth, url, source_id, sub_source_id, 1, {})
|
38
40
|
client.post_lead(1,{})
|
39
41
|
end
|
40
42
|
end
|
@@ -6,9 +6,10 @@ module G5YglClient20
|
|
6
6
|
let(:auth) {"BASIC c2hpbnlhbmRjaHJvbWU6YXF1YWNvbGE="}
|
7
7
|
let(:subscription_id) {3}
|
8
8
|
let(:source_id) {588}
|
9
|
+
let(:sub_source_id) {666}
|
9
10
|
|
10
11
|
describe 'execute' do
|
11
|
-
it "calls HTTParty post" do
|
12
|
+
it "calls HTTParty post without RootLeadSource" do
|
12
13
|
expect(HTTParty).to receive(:post).with("#{url}1/leads",
|
13
14
|
:headers => {"Authorization" => auth,
|
14
15
|
"Host" => HOST,
|
@@ -16,13 +17,30 @@ module G5YglClient20
|
|
16
17
|
"Content-Type" => "application/json"},
|
17
18
|
:body=>"{\"PrimaryContact\":{\"FirstName\":\"mad\",\"LastName\":\"max\",\"Address\":{\"Email\":\"mad@max.com\",\"PhoneCell\":\"5418675309\"}},\"CallCenterId\":\"G5-50\",\"Notes\":{\"Notes\":\"Witness Me\"},\"ReferralSources\":[{\"LeadSourceId\":\"588\",\"LeadSourceRank\":\"1\"}]}")
|
18
19
|
|
19
|
-
PostLeadRequest.execute(auth, url, source_id, 1, {first_name: "mad",
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
PostLeadRequest.execute(auth, url, source_id, nil, 1, {first_name: "mad",
|
21
|
+
last_name: "max",
|
22
|
+
email: "mad@max.com",
|
23
|
+
phone: "5418675309",
|
24
|
+
notes: "Witness Me",
|
25
|
+
id: 50})
|
25
26
|
end
|
27
|
+
|
28
|
+
it "calls HTTParty post with RootLeadSource" do
|
29
|
+
expect(HTTParty).to receive(:post).with("#{url}1/leads",
|
30
|
+
:headers => {"Authorization" => auth,
|
31
|
+
"Host" => HOST,
|
32
|
+
"Accept" => "application/json",
|
33
|
+
"Content-Type" => "application/json"},
|
34
|
+
:body=>"{\"PrimaryContact\":{\"FirstName\":\"mad\",\"LastName\":\"max\",\"Address\":{\"Email\":\"mad@max.com\",\"PhoneCell\":\"5418675309\"}},\"CallCenterId\":\"G5-50\",\"Notes\":{\"Notes\":\"Witness Me\"},\"ReferralSources\":[{\"LeadSourceId\":\"666\",\"LeadSourceRank\":\"1\",\"RootLeadSourceId\":\"588\"}]}")
|
35
|
+
|
36
|
+
PostLeadRequest.execute(auth, url, source_id, sub_source_id, 1, {first_name: "mad",
|
37
|
+
last_name: "max",
|
38
|
+
email: "mad@max.com",
|
39
|
+
phone: "5418675309",
|
40
|
+
notes: "Witness Me",
|
41
|
+
id: 50})
|
42
|
+
end
|
43
|
+
|
26
44
|
end
|
27
45
|
|
28
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g5_ygl_client_20
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Bishop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|