velocify 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +2 -0
- data/bin/console +2 -9
- data/lib/velocify.rb +1 -2
- data/lib/velocify/payload.rb +77 -0
- data/lib/velocify/report.rb +23 -3
- data/lib/velocify/version.rb +1 -1
- data/templates/get_report_results.xml.erb +18 -0
- metadata +4 -4
- data/lib/velocify/add_leads_payload.rb +0 -34
- data/lib/velocify/message_payload.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee1603a4f06f0f08e5d8328494e33032d7f5b5fb
|
4
|
+
data.tar.gz: 72a7393f07db8068fad64e459d6d911721276dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6bbebb0e2ae3dd963ead916315f8b2993fde6dff387852b4a27c4c9a481e323dafcd56d4c9dceb15a22520f4192641768baacda8937e9095bd27d1cc6294bb
|
7
|
+
data.tar.gz: 338374623b65744e64537aeedd1e82c3a66e463920c1324a494a5c6e71ab53262b78a0005b4a0d858b0c08d73b7a248afa1a652dde530befe1cc93c8333bc3a8
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# Changes in 0.1.7
|
2
|
+
|
3
|
+
* Supports adding filter items to the template_values option when retrieving report results
|
4
|
+
|
5
|
+
```
|
6
|
+
require 'ostruct'
|
7
|
+
|
8
|
+
item = OpenStruct.new field_title: 'Last Status Change Date', value: '4/12/2016 12:00:00'
|
9
|
+
Velocify::Report.find_results report_id: 123, template_values: [ item ]
|
10
|
+
```
|
11
|
+
|
1
12
|
# Changes in 0.1.6
|
2
13
|
|
3
14
|
* Supports programmatic configuration of Velocify credentials:
|
data/Gemfile
CHANGED
data/bin/console
CHANGED
@@ -3,12 +3,5 @@
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "velocify"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
6
|
+
require "pry"
|
7
|
+
Pry.start
|
data/lib/velocify.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Velocify
|
4
|
+
class MessagePayload
|
5
|
+
def initialize msg
|
6
|
+
@msg = msg || {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def authenticate username:, password:
|
10
|
+
@msg.merge!({ username: username, password: password })
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
{ message: @msg }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class AddLeadsPayload
|
19
|
+
include ERB::Util
|
20
|
+
|
21
|
+
# Creates a new request to add leads
|
22
|
+
#
|
23
|
+
# @param leads [Array<Lead>] A list of leads to be added
|
24
|
+
def initialize leads
|
25
|
+
@leads = leads
|
26
|
+
@credentials = {}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Stores credentials for making an authenticated request
|
30
|
+
#
|
31
|
+
# @param username [String]
|
32
|
+
# @param password [String]
|
33
|
+
# @return [Hash]
|
34
|
+
def authenticate username:, password:
|
35
|
+
@credentials = Hash[:username, username, :password, password]
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] The XML payload to send to Velocify's AddLeads operation
|
39
|
+
def render
|
40
|
+
relative_path = File.join '..', '..', 'templates', 'add_leads.xml.erb'
|
41
|
+
current_dir = File.dirname(__FILE__)
|
42
|
+
path = File.expand_path relative_path, current_dir
|
43
|
+
template = File.read(path)
|
44
|
+
xml_str = ERB.new(template).result binding
|
45
|
+
{ xml: xml_str.gsub(/[\n\t]*/, '').gsub(/[ ]{2,}/, '') }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class GetReportResultsPayload
|
50
|
+
include ERB::Util
|
51
|
+
|
52
|
+
def initialize report_id, filter_items
|
53
|
+
@filter_items = filter_items
|
54
|
+
@report_id = report_id
|
55
|
+
@credentials = {}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Stores credentials for making an authenticated request
|
59
|
+
#
|
60
|
+
# @param username [String]
|
61
|
+
# @param password [String]
|
62
|
+
# @return [Hash]
|
63
|
+
def authenticate username:, password:
|
64
|
+
@credentials = Hash[:username, username, :password, password]
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String] The XML payload to send to Velocify's GetReportResults operation
|
68
|
+
def render
|
69
|
+
relative_path = File.join '..', '..', 'templates', 'get_report_results.xml.erb'
|
70
|
+
current_dir = File.dirname(__FILE__)
|
71
|
+
path = File.expand_path relative_path, current_dir
|
72
|
+
template = File.read(path)
|
73
|
+
xml_str = ERB.new(template).result binding
|
74
|
+
{ xml: xml_str.gsub(/[\n\t]*/, '').gsub(/[ ]{2,}/, '') }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/velocify/report.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
1
3
|
module Velocify
|
2
4
|
class Report
|
3
5
|
include Model
|
@@ -20,17 +22,35 @@ module Velocify
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
# Retrieves report results with or without a filter
|
26
|
+
#
|
27
|
+
# @param report_id [Number] The id of the report
|
28
|
+
#
|
29
|
+
# @param template_values [Array<#field_title, #value>] (Optional) A list of filter items
|
30
|
+
#
|
31
|
+
# @example Including a filter item for retrieving report results with a last status change date filter
|
32
|
+
# require 'ostruct'
|
33
|
+
#
|
34
|
+
# item = OpenStruct.new field_title: 'Last Status Change Date', value: '4/12/2016 12:00:00'
|
35
|
+
# Velocify::Report.find_results report_id: 123, template_values: [ item ]
|
36
|
+
#
|
37
|
+
# @note The template_values option must contain an array of filter items. Filter items are objects that must respond to #field_title and #value.
|
38
|
+
#
|
39
|
+
def find_results report_id:, template_values: [], destruct: false, return_array: false
|
24
40
|
verify_credentials!
|
25
41
|
|
26
42
|
request do
|
27
43
|
destruct_response? destruct
|
28
44
|
operation :get_report_results
|
29
45
|
authenticate? true
|
30
|
-
|
46
|
+
xml GetReportResultsPayload.new(report_id, template_values)
|
31
47
|
transform do |resp|
|
32
48
|
if return_array
|
33
|
-
|
49
|
+
if template_values.empty?
|
50
|
+
arrayify resp[:report_results][:result]
|
51
|
+
else
|
52
|
+
arrayify resp[:report_results]
|
53
|
+
end
|
34
54
|
else
|
35
55
|
resp
|
36
56
|
end
|
data/lib/velocify/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="https://service.leads360.com">
|
2
|
+
<env:Body>
|
3
|
+
<ser:GetReportResults>
|
4
|
+
<ser:username><%= @credentials[:username] %></ser:username>
|
5
|
+
<ser:password><%= @credentials[:password] %></ser:password>
|
6
|
+
<ser:reportId><%= @report_id %></ser:reportId>
|
7
|
+
<% unless @filter_items.empty? %>
|
8
|
+
<ser:templateValues>
|
9
|
+
<FilterItems>
|
10
|
+
<% @filter_items.each do |item| %>
|
11
|
+
<FilterItem FieldTitle="<%= item.field_title %>"><%= item.value %></FilterItem>
|
12
|
+
<% end %>
|
13
|
+
</FilterItems>
|
14
|
+
</ser:templateValues>
|
15
|
+
<% end %>
|
16
|
+
</ser:GetReportResults>
|
17
|
+
</env:Body>
|
18
|
+
</env:Envelope>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: velocify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Dyba
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -126,19 +126,19 @@ files:
|
|
126
126
|
- bin/console
|
127
127
|
- bin/setup
|
128
128
|
- lib/velocify.rb
|
129
|
-
- lib/velocify/add_leads_payload.rb
|
130
129
|
- lib/velocify/agent.rb
|
131
130
|
- lib/velocify/campaign.rb
|
132
131
|
- lib/velocify/field.rb
|
133
132
|
- lib/velocify/field_type.rb
|
134
133
|
- lib/velocify/lead.rb
|
135
|
-
- lib/velocify/message_payload.rb
|
136
134
|
- lib/velocify/model.rb
|
135
|
+
- lib/velocify/payload.rb
|
137
136
|
- lib/velocify/report.rb
|
138
137
|
- lib/velocify/response_reader.rb
|
139
138
|
- lib/velocify/status.rb
|
140
139
|
- lib/velocify/version.rb
|
141
140
|
- templates/add_leads.xml.erb
|
141
|
+
- templates/get_report_results.xml.erb
|
142
142
|
- velocify.gemspec
|
143
143
|
homepage: http://github.com/pennymac/velocify
|
144
144
|
licenses:
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Velocify
|
4
|
-
class AddLeadsPayload
|
5
|
-
include ERB::Util
|
6
|
-
|
7
|
-
# Creates a new request to add leads
|
8
|
-
#
|
9
|
-
# @param leads [Array<Lead>] A list of leads to be added
|
10
|
-
def initialize leads
|
11
|
-
@leads = leads
|
12
|
-
@credentials = {}
|
13
|
-
end
|
14
|
-
|
15
|
-
# Stores credentials for making an authenticated request
|
16
|
-
#
|
17
|
-
# @param username [String]
|
18
|
-
# @param password [String]
|
19
|
-
# @return [Hash]
|
20
|
-
def authenticate username:, password:
|
21
|
-
@credentials = Hash[:username, username, :password, password]
|
22
|
-
end
|
23
|
-
|
24
|
-
# @return [String] The XML payload to send to Velocify's AddLeads operation
|
25
|
-
def render
|
26
|
-
relative_path = File.join '..', '..', 'templates', 'add_leads.xml.erb'
|
27
|
-
current_dir = File.dirname(__FILE__)
|
28
|
-
path = File.expand_path relative_path, current_dir
|
29
|
-
template = File.read(path)
|
30
|
-
xml_str = ERB.new(template).result binding
|
31
|
-
{ xml: xml_str.gsub(/[\n\t]*/, '').gsub(/[ ]{2,}/, '') }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|