g5_enquire 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/g5_enquire.gemspec +27 -0
- data/lib/g5_enquire/client.rb +15 -0
- data/lib/g5_enquire/requests/post_lead_request.rb +37 -0
- data/lib/g5_enquire/version.rb +3 -0
- data/lib/g5_enquire.rb +17 -0
- data/spec/client_spec.rb +28 -0
- data/spec/g5_enquire_spec.rb +8 -0
- data/spec/requests/post_lead_request_spec.rb +23 -0
- data/spec/spec_helper.rb +2 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGExZjk2ZjA1OTA0ODljNGIxZDMxMmY1N2M5NDdlNzM4ZWFjNjgyZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWMzZjViY2U3YmU0YmYyYWUxNGQyN2Y0Mjc2ODZjMmM3ZjMyNjJkNA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDVkY2NmMzZhMTEwYzNlOTI4YmNlODk2YWFhODdkYmZhOTY3N2JjMTJkMzhm
|
10
|
+
YzI5M2EwYTA5MjI0YmNhZTI1YTRjNThlN2JmNWQ2MDNkZGQ0NGM3NTIzYjJh
|
11
|
+
M2I0MmYzZDFkZDE1NmZhYjM5MzZlN2MwMmJhZTJlNWQxMjg5YWY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDcwYzRmZDY4MWQyZTMwNGUxZjNjNTY5NDA2Njk4MDliZjcyMzQ0YmVlNWQ0
|
14
|
+
YjMwNDgwYjQ1YjQzMmU5ZGRkMjFhZjQyYWE0Y2NiYTEyOTg1NmRiNmZlYWIy
|
15
|
+
M2ZmMjBjMGMwYzU1Y2I3ZDI5Nzg5YzA0OWUxNzAzMmI2MDkyYTE=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# G5Enquire
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/g5_enquire`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'g5_enquire'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install g5_enquire
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/g5_enquire.
|
36
|
+
|
data/Rakefile
ADDED
data/g5_enquire.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'g5_enquire/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "g5_enquire"
|
8
|
+
spec.version = G5Enquire::VERSION
|
9
|
+
spec.authors = ["Matt Bishop"]
|
10
|
+
spec.email = ["matt.bishop@getg5.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Pushing leads to enquire}
|
13
|
+
spec.description = %q{Hello. Peter Lemonjello, your house is on fire.}
|
14
|
+
spec.homepage = ""
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "activemodel"
|
22
|
+
spec.add_dependency "activesupport"
|
23
|
+
spec.add_dependency "httparty"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module G5Enquire
|
2
|
+
class Client
|
3
|
+
|
4
|
+
def initialize(community_name, subscription_key, endpoint)
|
5
|
+
@url = endpoint
|
6
|
+
@subscription_key = subscription_key
|
7
|
+
@community_name = community_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def post_lead(lead)
|
11
|
+
request = PostLeadRequest.execute(@url, @subscription_key, @community_name, lead)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module G5Enquire
|
2
|
+
class PostLeadRequest
|
3
|
+
|
4
|
+
def self.execute(url, subscription_key, community_name, lead)
|
5
|
+
uri = URI(url)
|
6
|
+
uri.query = URI.encode_www_form({'subscription-key' => subscription_key})
|
7
|
+
response = HTTParty.post(uri.to_s,
|
8
|
+
:body => {"CommunityName" => "#{community_name}",
|
9
|
+
"FirstName" => "#{lead[:first_name]}",
|
10
|
+
"LastName" => "#{lead[:last_name]}",
|
11
|
+
"Email" => "#{lead[:email]}",
|
12
|
+
"HomePhone" => "#{lead[:phone]}",
|
13
|
+
"WorkPhone" => "",
|
14
|
+
"MobilePhone" => "",
|
15
|
+
"Message" => "#{lead[:message]}",
|
16
|
+
"AddressLine1" => "#{lead[:address]}",
|
17
|
+
"AddressLine2" => "",
|
18
|
+
"City" => "#{lead[:city]}",
|
19
|
+
"State" => "#{lead[:state]}",
|
20
|
+
"ZipCode" => "#{lead[:postal_code]}",
|
21
|
+
"InquiringFor" => "#{lead[:inquiring_for]}",
|
22
|
+
"NewsLetters" => "#{string_to_bool(lead[:subscription])}",
|
23
|
+
"CommunitiesRequested" => "",
|
24
|
+
"IndividualTypeName" => "Prospect",
|
25
|
+
"ActivityTypeName" => "Web Form",
|
26
|
+
"ActivityDescription" => "#{community_name} Website"
|
27
|
+
}.to_json,
|
28
|
+
:headers => { 'Content-Type' => 'application/json' },
|
29
|
+
:verify => false )
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.string_to_bool(str)
|
33
|
+
str == "true" || str == "1"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/g5_enquire.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "g5_enquire/version"
|
2
|
+
require "g5_enquire/client"
|
3
|
+
require "g5_enquire/requests/post_lead_request"
|
4
|
+
require "httparty"
|
5
|
+
|
6
|
+
module G5Enquire
|
7
|
+
|
8
|
+
SENSITIVE_FIELDS = [
|
9
|
+
"address",
|
10
|
+
"email",
|
11
|
+
"phone"
|
12
|
+
]
|
13
|
+
|
14
|
+
def self.new(community_name, subscription_key, endpoint)
|
15
|
+
client = G5Enquire::Client.new(community_name, subscription_key, endpoint)
|
16
|
+
end
|
17
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module G5Enquire
|
4
|
+
describe Client do
|
5
|
+
|
6
|
+
let(:client) {G5Enquire::Client.new("shinyandchrome", "8675309", "https://api2.enquiresolutions.com/2/Individual/")}
|
7
|
+
|
8
|
+
describe "initialize" do
|
9
|
+
it "assigns" do
|
10
|
+
client.instance_variable_get(:@community_name).should eq("shinyandchrome")
|
11
|
+
client.instance_variable_get(:@url).should eq("https://api2.enquiresolutions.com/2/Individual/")
|
12
|
+
client.instance_variable_get(:@subscription_key).should eq("8675309")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:community_name) {"shinyandchrome"}
|
17
|
+
let(:subscription_key) {"8675309"}
|
18
|
+
let(:url) {"https://api2.enquiresolutions.com/2/Individual/"}
|
19
|
+
|
20
|
+
describe "post_lead" do
|
21
|
+
it "makes a Post Lead Request" do
|
22
|
+
expect(PostLeadRequest).to receive(:execute).with(url, subscription_key, community_name, {})
|
23
|
+
client.post_lead({})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module G5Enquire
|
4
|
+
describe PostLeadRequest do
|
5
|
+
let(:url) {"http://www.immortanjoerecruitment.com"}
|
6
|
+
let(:community_name) {"Bartertown"}
|
7
|
+
let(:subscription_key) {"666"}
|
8
|
+
describe 'execute' do
|
9
|
+
it "calls HTTParty post" do
|
10
|
+
expect(HTTParty).to receive(:post).with("http://www.immortanjoerecruitment.com?subscription-key=666", {:body=>"{\"CommunityName\":\"Bartertown\",\"FirstName\":\"mad\",\"LastName\":\"max\",\"Email\":\"mad@max.com\",\"HomePhone\":\"5418675309\",\"WorkPhone\":\"\",\"MobilePhone\":\"\",\"Message\":\"\",\"AddressLine1\":\"\",\"AddressLine2\":\"\",\"City\":\"\",\"State\":\"\",\"ZipCode\":\"\",\"InquiringFor\":\"\",\"NewsLetters\":\"true\",\"CommunitiesRequested\":\"\",\"IndividualTypeName\":\"Prospect\",\"ActivityTypeName\":\"Web Form\",\"ActivityDescription\":\"Bartertown Website\"}", :headers=>{"Content-Type"=>"application/json"}, :verify=>false})
|
11
|
+
PostLeadRequest.execute(url,
|
12
|
+
subscription_key,
|
13
|
+
community_name,
|
14
|
+
{first_name: "mad",
|
15
|
+
last_name: "max",
|
16
|
+
email: "mad@max.com",
|
17
|
+
phone: "5418675309",
|
18
|
+
subscription: "1"})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: g5_enquire
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Bishop
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Hello. Peter Lemonjello, your house is on fire.
|
98
|
+
email:
|
99
|
+
- matt.bishop@getg5.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .travis.yml
|
107
|
+
- Gemfile
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- g5_enquire.gemspec
|
111
|
+
- lib/g5_enquire.rb
|
112
|
+
- lib/g5_enquire/client.rb
|
113
|
+
- lib/g5_enquire/requests/post_lead_request.rb
|
114
|
+
- lib/g5_enquire/version.rb
|
115
|
+
- spec/client_spec.rb
|
116
|
+
- spec/g5_enquire_spec.rb
|
117
|
+
- spec/requests/post_lead_request_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
homepage: ''
|
120
|
+
licenses: []
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.2.2
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Pushing leads to enquire
|
142
|
+
test_files:
|
143
|
+
- spec/client_spec.rb
|
144
|
+
- spec/g5_enquire_spec.rb
|
145
|
+
- spec/requests/post_lead_request_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
has_rdoc:
|