velocify 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6581d14d749b2c078a7a2989f87057de13f9be9d
4
- data.tar.gz: e396d9ad2c7b08f45218d18f70fec99a61d894e9
3
+ metadata.gz: a3f8637807ba83f0fffa648a0672a075b4414a75
4
+ data.tar.gz: 5ac014642b7032104cbd11d633f1ecc3fdf4397c
5
5
  SHA512:
6
- metadata.gz: 33ff9678e5cf648f1f894bcec1409c9497a119a83990064a0d38999c9f902c94ae680e258154d275cf1a83c77e478bc0eaea1c75eded72a709cdbfc9c0207bd3
7
- data.tar.gz: 79944b40ba9dd23404a79804e34410b2f809df55f8fb5fa65de2ed3596f8925aa7e98b8bb74a0bddb0120804965238cf0423d7e58c3edf4126af80ea35af6175
6
+ metadata.gz: 7fd417d8fec9ec1ced275d3348cc09ebc07d52891fcab22475573edf0e16165f8e0cbecf8983c9240f2efb1b8f97177076ee268617a5c2db26b96a3c77fb83fa
7
+ data.tar.gz: 51df44628159511a6130665b2c520a20cc56ca16363726a2825451ec9e93c83dffcce1f58c5c91a9e751289df27f25a023feaf3118ee2a8b33a5ebfc49f47eb0
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Velocify
2
2
  [![Gem Version](https://badge.fury.io/rb/velocify.svg)](http://badge.fury.io/rb/velocify)
3
+ [![Code Climate](https://codeclimate.com/github/pennymac/velocify/badges/gpa.svg)](https://codeclimate.com/github/pennymac/velocify)
3
4
 
4
5
  ## Installation
5
6
 
@@ -4,10 +4,10 @@ module Velocify
4
4
 
5
5
  operations :get_campaigns
6
6
 
7
- def self.find_all
7
+ def self.find_all destruct: false
8
8
  verify_credentials!
9
9
 
10
- request do
10
+ request(destruct: destruct) do
11
11
  response = get_campaigns(message: @credentials)
12
12
  response.body[:get_campaigns_response][:get_campaigns_result]
13
13
  end
@@ -6,10 +6,10 @@ module Velocify
6
6
 
7
7
  # @return [Hash] a list of fields
8
8
  #
9
- def self.find_all
9
+ def self.find_all destruct: false
10
10
  verify_credentials!
11
11
 
12
- request do
12
+ request(destruct: destruct) do
13
13
  response = get_fields(message: @credentials)
14
14
  response.body[:get_fields_response][:get_fields_result]
15
15
  end
@@ -5,10 +5,10 @@ module Velocify
5
5
  operations :get_field_types
6
6
 
7
7
  # @return [Hash] a list of fields
8
- def self.find_all
8
+ def self.find_all destruct: false
9
9
  verify_credentials!
10
10
 
11
- request do
11
+ request(destruct: destruct) do
12
12
  response = get_field_types(message: authenticated_message({}))
13
13
  response.body[:get_field_types_response][:get_field_types_result]
14
14
  end
@@ -36,10 +36,10 @@ module Velocify
36
36
  # @param leads [String] The string representation of the XML document
37
37
  # containing the new leads
38
38
  #
39
- def add leads:
39
+ def add leads:, destruct: false
40
40
  verify_credentials!
41
41
 
42
- request do
42
+ request(destruct: destruct) do
43
43
  response = add_leads(message: authenticated_message({ leads: leads }))
44
44
  response.body[:add_leads_response][:add_leads_result]
45
45
  end
@@ -51,12 +51,12 @@ module Velocify
51
51
  # @param to [String] The end date
52
52
  # @return [Hash] The leads between the `from:` and `to:` dates
53
53
  #
54
- def find_all from:, to:
54
+ def find_all from:, to:, destruct: false
55
55
  verify_credentials!
56
56
 
57
57
  m = { from: from, to: to }
58
58
 
59
- request do
59
+ request(destruct: destruct) do
60
60
  response = get_leads(message: authenticated_message(m))
61
61
  response.body
62
62
  end
@@ -67,10 +67,10 @@ module Velocify
67
67
  # @param email [String] The email address used to search for a lead
68
68
  # @return [Hash] The leads having the matching email address
69
69
  #
70
- def find_by_email email
70
+ def find_by_email email, destruct: false
71
71
  verify_credentials!
72
72
 
73
- request do
73
+ request(destruct: destruct) do
74
74
  response = get_leads_by_email(message: authenticated_message({ email: email }))
75
75
  response.body[:get_leads_by_email_response][:get_leads_by_email_result]
76
76
  end
@@ -81,10 +81,10 @@ module Velocify
81
81
  # @param phone [String] The phone number used to search for a lead
82
82
  # @return [Hash] The leads having the matching phone number
83
83
  #
84
- def find_by_phone phone
84
+ def find_by_phone phone, destruct: false
85
85
  verify_credentials!
86
86
 
87
- request do
87
+ request(destruct: destruct) do
88
88
  response = get_leads_by_phone(message: authenticated_message({ phone: phone.gsub(/[()\- ]/, '') }))
89
89
  response.body[:get_leads_by_phone_response][:get_leads_by_phone_result]
90
90
  end
@@ -95,28 +95,28 @@ module Velocify
95
95
  # @param id [String] the id of the lead
96
96
  # @return [Hash] The lead with the matching id
97
97
  #
98
- def find_by_id id
98
+ def find_by_id id, destruct: false
99
99
  verify_credentials!
100
100
 
101
- request do
101
+ request(destruct: destruct) do
102
102
  response = get_lead(message: authenticated_message({ lead_id: id }))
103
103
  response.body[:get_lead_response][:get_lead_result]
104
104
  end
105
105
  end
106
106
 
107
- def find_last_created
107
+ def find_last_created destruct: false
108
108
  verify_credentials!
109
109
 
110
- request do
110
+ request(destruct: destruct) do
111
111
  response = get_last_created_lead(message: authenticated_message({}))
112
112
  response.body[:get_last_created_lead_response][:get_last_created_lead_result]
113
113
  end
114
114
  end
115
115
 
116
- def find_last_modified
116
+ def find_last_modified destruct: false
117
117
  verify_credentials!
118
118
 
119
- request do
119
+ request(destruct: destruct) do
120
120
  response = get_last_modified_lead(message: authenticated_message({}))
121
121
  response.body[:get_last_modified_lead_response][:get_last_modified_lead_result]
122
122
  end
@@ -132,10 +132,10 @@ module Velocify
132
132
  # @param status_id [String] The id of the status
133
133
  # @return [Hash] The response containing the updated lead
134
134
  #
135
- def update_status lead_id:, status_id:
135
+ def update_status lead_id:, status_id:, destruct: false
136
136
  verify_credentials!
137
137
 
138
- request do
138
+ request(destruct: destruct) do
139
139
  response = modify_lead_status(message: authenticated_message({
140
140
  lead_id: lead_id,
141
141
  status_id: status_id
@@ -151,10 +151,10 @@ module Velocify
151
151
  # @param new_value [String] The new value of the field
152
152
  # @return [Hash] The response containing the updated lead
153
153
  #
154
- def update_field lead_id:, field_id:, new_value:
154
+ def update_field lead_id:, field_id:, new_value:, destruct: false
155
155
  verify_credentials!
156
156
 
157
- request do
157
+ request(destruct: destruct) do
158
158
  response = modify_lead_field(message: authenticated_message({
159
159
  field_id: field_id,
160
160
  lead_id: lead_id,
@@ -31,13 +31,26 @@ module Velocify
31
31
  !@credentials[:username].empty? && !@credentials[:password].empty?
32
32
  end
33
33
 
34
- def request &block
34
+ def request destruct: false, &block
35
35
  begin
36
- yield block
36
+ if destruct
37
+ result = yield block
38
+ [true, result]
39
+ else
40
+ yield block
41
+ end
37
42
  rescue Savon::SOAPFault => ex
38
- { message: ex.message }
43
+ if destruct
44
+ [false, { message: ex.message }]
45
+ else
46
+ { message: ex.message }
47
+ end
39
48
  rescue Net::ReadTimeout => ex
40
- { message: ex.message }
49
+ if destruct
50
+ [false, { message: ex.message }]
51
+ else
52
+ { message: ex.message }
53
+ end
41
54
  end
42
55
  end
43
56
  end
@@ -4,10 +4,10 @@ module Velocify
4
4
 
5
5
  operations :get_statuses
6
6
 
7
- def self.find_all
7
+ def self.find_all destruct: false
8
8
  verify_credentials!
9
9
 
10
- request do
10
+ request(destruct: destruct) do
11
11
  response = get_statuses(message: authenticated_message({}))
12
12
  response.body[:get_statuses_response][:get_statuses_result]
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Velocify
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Dyba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon