tessitura_rest 0.8.3 → 0.8.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.env.enc +0 -0
- data/.travis.yml +3 -1
- data/Gemfile +6 -4
- data/lib/tessitura_rest.rb +1 -0
- data/lib/tessitura_rest/crm/constituencies.rb +0 -49
- data/lib/tessitura_rest/crm/constituents.rb +138 -0
- data/lib/tessitura_rest/crm/phones.rb +31 -0
- data/lib/tessitura_rest/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c0e41bcfb196645015381ae137c284ec58f6f84d493f13043faac2c30bd710e
|
4
|
+
data.tar.gz: ec46fa48f3a9baf514a293366c50cbca34bfbb872e73a15e5cb690ab82990129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1629aff07a5055026d383f55d654f2826341872e5df0816cdf09487fa15796e08678c4eb98ac6ba3badfec520983f2c0f0551c1035ad01529747391a47214d85
|
7
|
+
data.tar.gz: a02a8671ef120a3388e238a31e5031a2fbdf4045e2124242ffd936a92167f5b648b5758482b1cf358276fdbe106b9cdc17c9b407292b8540f66a8cae9abf394e
|
data/.codeclimate.yml
CHANGED
data/.env.enc
ADDED
Binary file
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/tessitura_rest.rb
CHANGED
@@ -6,55 +6,6 @@ module Constituencies
|
|
6
6
|
JSON.parse(response.body)
|
7
7
|
end
|
8
8
|
|
9
|
-
def get_constituent_snapshot(id, options={})
|
10
|
-
options.merge!(basic_auth: @auth, headers: @headers)
|
11
|
-
response = self.class.get(base_api_endpoint("CRM/Constituents/#{id}/Snapshot"), options)
|
12
|
-
JSON.parse(response.body)
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_constituent_by_snapshot(first_name, last_name, email, constituent_type, source, city, zip, state, street1, country, options={})
|
16
|
-
parameters = {
|
17
|
-
"ConstituentType": {
|
18
|
-
"Id": constituent_type,
|
19
|
-
"Inactive": false,
|
20
|
-
},
|
21
|
-
"DisplayName": "#{first_name} #{last_name}",
|
22
|
-
"FirstName": first_name,
|
23
|
-
"LastName": last_name,
|
24
|
-
"ElectronicAddress": {
|
25
|
-
"Address": email,
|
26
|
-
"ElectronicAddressType": {
|
27
|
-
"Id": 1,
|
28
|
-
},
|
29
|
-
"AllowHtmlFormat": true,
|
30
|
-
"Inactive": false,
|
31
|
-
"AllowMarketing": false,
|
32
|
-
"Months": 'YYYYYYYYYYYY',
|
33
|
-
"PrimaryIndicator": true,
|
34
|
-
},
|
35
|
-
"OriginalSource": {
|
36
|
-
"Id": source,
|
37
|
-
},
|
38
|
-
"Address": {
|
39
|
-
"AddressType": {
|
40
|
-
"Id": 3,
|
41
|
-
},
|
42
|
-
"City": city,
|
43
|
-
"PostalCode": zip,
|
44
|
-
"State": {
|
45
|
-
"Id": state,
|
46
|
-
},
|
47
|
-
"Street1": street1,
|
48
|
-
"Country": {
|
49
|
-
"Id": country,
|
50
|
-
},
|
51
|
-
}
|
52
|
-
}
|
53
|
-
options.merge!(basic_auth: @auth, headers: @headers)
|
54
|
-
options.merge!(:body => parameters)
|
55
|
-
response = self.class.post(base_api_endpoint('CRM/Constituents/Snapshot'), options)
|
56
|
-
end
|
57
|
-
|
58
9
|
def create_constituencies(constituency, id, options={})
|
59
10
|
parameters =
|
60
11
|
{
|
@@ -0,0 +1,138 @@
|
|
1
|
+
module Constituents
|
2
|
+
|
3
|
+
def get_constituent_snapshot(id, options={})
|
4
|
+
options.merge!(basic_auth: @auth, headers: @headers)
|
5
|
+
response = self.class.get(base_api_endpoint("CRM/Constituents/#{id}/Snapshot"), options)
|
6
|
+
JSON.parse(response.body)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_constituent_by_snapshot(first_name, last_name, email, phone, constituent_type, source, street1, street2, city, state, zip, country, options={})
|
10
|
+
parameters =
|
11
|
+
{
|
12
|
+
"ConstituentType": {
|
13
|
+
"Id": constituent_type,
|
14
|
+
"Inactive": false,
|
15
|
+
},
|
16
|
+
"FirstName": first_name,
|
17
|
+
"LastName": last_name,
|
18
|
+
"ElectronicAddress": {
|
19
|
+
"Address": email,
|
20
|
+
"ElectronicAddressType": {
|
21
|
+
"Id": 1,
|
22
|
+
},
|
23
|
+
"AllowHtmlFormat": true,
|
24
|
+
"Inactive": false,
|
25
|
+
"AllowMarketing": false,
|
26
|
+
"Months": 'YYYYYYYYYYYY',
|
27
|
+
"PrimaryIndicator": true,
|
28
|
+
},
|
29
|
+
"PrimaryPhoneNumbers":
|
30
|
+
[
|
31
|
+
{
|
32
|
+
"PhoneNumber": phone,
|
33
|
+
"PhoneType":
|
34
|
+
{
|
35
|
+
"Id": 1
|
36
|
+
},
|
37
|
+
},
|
38
|
+
],
|
39
|
+
"OriginalSource": {
|
40
|
+
"Id": source,
|
41
|
+
},
|
42
|
+
"Address": {
|
43
|
+
"AddressType": {
|
44
|
+
"Id": 3,
|
45
|
+
},
|
46
|
+
"City": city,
|
47
|
+
"PostalCode": zip,
|
48
|
+
"State": {
|
49
|
+
"Id": state,
|
50
|
+
},
|
51
|
+
"Street1": street1,
|
52
|
+
"Street2": street2,
|
53
|
+
"Country": {
|
54
|
+
"Id": country,
|
55
|
+
},
|
56
|
+
}
|
57
|
+
}
|
58
|
+
parameters.delete(:PrimaryPhoneNumbers) unless phone.present?
|
59
|
+
options.merge!(basic_auth: @auth, headers: @headers)
|
60
|
+
options.merge!(:body => parameters.to_json, :headers => { 'Content-Type' => 'application/json' })
|
61
|
+
self.class.post(base_api_endpoint('CRM/Constituents/Snapshot'), options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def update_constituent(constituent_id, params, options={})
|
65
|
+
current = get_constituent_snapshot(constituent_id)
|
66
|
+
if is_household?(current)
|
67
|
+
update_household(params, current)
|
68
|
+
else
|
69
|
+
parameters =
|
70
|
+
{
|
71
|
+
"ConstituentType": {
|
72
|
+
"Id": current["ConstituentType"]["Id"],
|
73
|
+
"Inactive": false,
|
74
|
+
},
|
75
|
+
"Id": constituent_id,
|
76
|
+
"FirstName": params[:first_name],
|
77
|
+
"UpdatedDateTime": current["UpdatedDateTime"],
|
78
|
+
"LastName": params[:last_name],
|
79
|
+
"MiddleName": params[:middle_name],
|
80
|
+
"Prefix": {
|
81
|
+
"Id": params[:prefix],
|
82
|
+
"Inactive": false
|
83
|
+
},
|
84
|
+
"Suffix": {
|
85
|
+
"Id": params[:suffix],
|
86
|
+
"Inactive": false
|
87
|
+
},
|
88
|
+
"OriginalSource": {
|
89
|
+
"Id": current["OriginalSource"]["Id"],
|
90
|
+
"Inactive": false
|
91
|
+
},
|
92
|
+
}
|
93
|
+
options.merge!(basic_auth: @auth, headers: @headers)
|
94
|
+
options.merge!(:body => parameters)
|
95
|
+
self.class.put(base_api_endpoint("CRM/Constituents/#{constituent_id}"), options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def is_household?(snapshot)
|
100
|
+
snapshot["ConstituentType"]["Id"] == 9
|
101
|
+
end
|
102
|
+
|
103
|
+
def update_household(params, current, options={})
|
104
|
+
constituents = current["Affiliates"].map{|c| c["RelatedConstituentId"]}
|
105
|
+
constituents.each_with_index do |constituent, i|
|
106
|
+
snapshot = get_constituent_snapshot(constituent)
|
107
|
+
parameters =
|
108
|
+
{
|
109
|
+
"ConstituentType": {
|
110
|
+
"Id": snapshot["ConstituentType"]["Id"],
|
111
|
+
"Inactive": false,
|
112
|
+
},
|
113
|
+
"Id": constituent,
|
114
|
+
"FirstName": i == 0 ? params[:first_name] : params[:first_name_2],
|
115
|
+
"UpdatedDateTime": snapshot["UpdatedDateTime"],
|
116
|
+
"LastName": i == 0 ? params[:last_name] : params[:last_name_2],
|
117
|
+
"MiddleName": i == 0 ? params[:middle_name] : params[:middle_name_2],
|
118
|
+
"Prefix": {
|
119
|
+
"Id": i == 0 ? params[:prefix] : params[:prefix_2],
|
120
|
+
"Inactive": false
|
121
|
+
},
|
122
|
+
"Suffix": {
|
123
|
+
"Id": i == 0 ? params[:suffix] : params[:suffix_2],
|
124
|
+
"Inactive": false
|
125
|
+
},
|
126
|
+
"OriginalSource": {
|
127
|
+
"Id": snapshot["OriginalSource"]["Id"],
|
128
|
+
"Inactive": false
|
129
|
+
},
|
130
|
+
}
|
131
|
+
options.merge!(basic_auth: @auth, headers: @headers)
|
132
|
+
options.merge!(:body => parameters)
|
133
|
+
self.class.put(base_api_endpoint("CRM/Constituents/#{constituent}"), options)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
module Phones
|
2
2
|
|
3
|
+
def get_phone(id, options={})
|
4
|
+
options.merge!(basic_auth: @auth, headers: @headers)
|
5
|
+
response = self.class.get(base_api_endpoint("CRM/Phones/#{id}"), options)
|
6
|
+
JSON.parse(response.body)
|
7
|
+
end
|
8
|
+
|
3
9
|
def create_primary_phone(id, phone, options={})
|
4
10
|
parameters =
|
5
11
|
{
|
@@ -38,4 +44,29 @@ module Phones
|
|
38
44
|
JSON.parse(response.body)
|
39
45
|
end
|
40
46
|
|
47
|
+
def update_phone(id, phone, options={})
|
48
|
+
current = get_phone(id)
|
49
|
+
parameters =
|
50
|
+
{
|
51
|
+
"Address": {
|
52
|
+
"Id": current["Address"]["Id"],
|
53
|
+
"AddressType": {
|
54
|
+
"Id": current["Address"]["AddressType"]["Id"],
|
55
|
+
}
|
56
|
+
},
|
57
|
+
"Constituent": {
|
58
|
+
"Id": current["Constituent"]["Id"]
|
59
|
+
},
|
60
|
+
"PhoneType": {
|
61
|
+
"Id": current["PhoneType"]["Id"],
|
62
|
+
},
|
63
|
+
"Id": current["Id"],
|
64
|
+
"PhoneNumber": phone,
|
65
|
+
"UpdatedDateTime": current["UpdatedDateTime"],
|
66
|
+
}
|
67
|
+
options.merge!(basic_auth: @auth, headers: @headers)
|
68
|
+
options.merge!(:body => parameters)
|
69
|
+
self.class.put(base_api_endpoint("CRM/Phones/#{id}"), options)
|
70
|
+
end
|
71
|
+
|
41
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tessitura_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brittany Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,7 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- ".codeclimate.yml"
|
120
|
+
- ".env.enc"
|
120
121
|
- ".gitignore"
|
121
122
|
- ".rspec"
|
122
123
|
- ".rubocop.yml"
|
@@ -134,6 +135,7 @@ files:
|
|
134
135
|
- lib/tessitura_rest/crm/addresses.rb
|
135
136
|
- lib/tessitura_rest/crm/attributes.rb
|
136
137
|
- lib/tessitura_rest/crm/constituencies.rb
|
138
|
+
- lib/tessitura_rest/crm/constituents.rb
|
137
139
|
- lib/tessitura_rest/crm/issues.rb
|
138
140
|
- lib/tessitura_rest/crm/phones.rb
|
139
141
|
- lib/tessitura_rest/crm/web_logins.rb
|