tessitura_rest 0.8.5 → 0.8.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 345f1da7aa6d63a1d827546acc3171483c777ba8ff4a0123d13116223aaf2645
4
- data.tar.gz: 9b9dfd0901d4bf2034e94dff62a983af75621c856d199656294a2d37d400bd09
3
+ metadata.gz: c8d4948755697e1e8c005d6d52d5f6740f3f975ac6c3ebb55d1e3d28cd250161
4
+ data.tar.gz: e8b2251ac807c265a374a4e368a592b668dc2c12957a091e86833628ac7b77e3
5
5
  SHA512:
6
- metadata.gz: 51355fd503e62044b2b5acfec524394f15ae50e8cadce8de93064ad44b9cfa7797cf435fcb38bb5ba5093094eefb2461efa2292754278ca2743cdf8fa2e8410a
7
- data.tar.gz: '027897de89660cf0edfeffd16c75c1611dc5df63004351fc2dec684a2ff383e11e2329f3aa1917c655dc2252101c8ac665bb7afd6f09ff3fb073c06a177a2639'
6
+ metadata.gz: 42b51281d5102ae7bfebede2f8bcc40ca79559abb6e57d2b359ef5c6444d4c4f1d90a34c17f7cd32f2c0de42275bf3638dc265bf537c1b482252274af8154fd5
7
+ data.tar.gz: 1d1f88840f37963adcf1f7464cbf6c7051e7f06cfeec17c057706053c3f84b84fdbd3d724e8ab15025bab41b55b24656d4306e62d07cb3b7e6879e2bc699f10a
data/.codeclimate.yml CHANGED
@@ -28,7 +28,7 @@ plugins:
28
28
  enabled: false
29
29
  rubocop:
30
30
  enabled: true
31
- channel: rubocop-0-79
31
+ channel: rubocop-0-88
32
32
  stylelint:
33
33
  enabled: false
34
34
  checks:
data/.env.enc CHANGED
Binary file
@@ -14,6 +14,7 @@ class TessituraRest
14
14
  include BillingSchedules
15
15
  include Cart
16
16
  include Constituencies
17
+ include Constituents
17
18
  include Countries
18
19
  include Diagnostics
19
20
  include Email
@@ -6,66 +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, phone, constituent_type, source, street1, street2, city, state, zip, country, options={})
16
- parameters =
17
- {
18
- "ConstituentType": {
19
- "Id": constituent_type,
20
- "Inactive": false,
21
- },
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
- "PrimaryPhoneNumbers":
36
- [
37
- {
38
- "PhoneNumber": phone,
39
- "PhoneType":
40
- {
41
- "Id": 1
42
- },
43
- },
44
- ],
45
- "OriginalSource": {
46
- "Id": source,
47
- },
48
- "Address": {
49
- "AddressType": {
50
- "Id": 3,
51
- },
52
- "City": city,
53
- "PostalCode": zip,
54
- "State": {
55
- "Id": state,
56
- },
57
- "Street1": street1,
58
- "Street2": street2,
59
- "Country": {
60
- "Id": country,
61
- },
62
- }
63
- }
64
- options.merge!(basic_auth: @auth, headers: @headers)
65
- options.merge!(:body => parameters.to_json, :headers => { 'Content-Type' => 'application/json' })
66
- self.class.post(base_api_endpoint('CRM/Constituents/Snapshot'), options)
67
- end
68
-
69
9
  def create_constituencies(constituency, id, options={})
70
10
  parameters =
71
11
  {
@@ -0,0 +1,140 @@
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
+ parameters.delete(:Prefix) unless params[:prefix].present?
94
+ parameters.delete(:Suffix) unless params[:suffix].present?
95
+ options.merge!(basic_auth: @auth, headers: @headers)
96
+ options.merge!(:body => parameters.to_json, :headers => { 'Content-Type' => 'application/json' })
97
+ self.class.put(base_api_endpoint("CRM/Constituents/#{constituent_id}"), options)
98
+ end
99
+ end
100
+
101
+ def is_household?(snapshot)
102
+ snapshot["ConstituentType"]["Id"] == 9
103
+ end
104
+
105
+ def update_household(params, current, options={})
106
+ constituents = current["Affiliates"].map{|c| c["RelatedConstituentId"]}
107
+ constituents.each_with_index do |constituent, i|
108
+ snapshot = get_constituent_snapshot(constituent)
109
+ parameters =
110
+ {
111
+ "ConstituentType": {
112
+ "Id": snapshot["ConstituentType"]["Id"],
113
+ "Inactive": false,
114
+ },
115
+ "Id": constituent,
116
+ "FirstName": i == 0 ? params[:first_name] : params[:first_name_2],
117
+ "UpdatedDateTime": snapshot["UpdatedDateTime"],
118
+ "LastName": i == 0 ? params[:last_name] : params[:last_name_2],
119
+ "MiddleName": i == 0 ? params[:middle_name] : params[:middle_name_2],
120
+ "Prefix": {
121
+ "Id": i == 0 ? params[:prefix] : params[:prefix_2],
122
+ "Inactive": false
123
+ },
124
+ "Suffix": {
125
+ "Id": i == 0 ? params[:suffix] : params[:suffix_2],
126
+ "Inactive": false
127
+ },
128
+ "OriginalSource": {
129
+ "Id": snapshot["OriginalSource"]["Id"],
130
+ "Inactive": false
131
+ },
132
+ }
133
+ options.merge!(basic_auth: @auth, headers: @headers)
134
+ options.merge!(:body => parameters)
135
+ self.class.put(base_api_endpoint("CRM/Constituents/#{constituent}"), options)
136
+ end
137
+ end
138
+
139
+
140
+ 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
@@ -1,3 +1,3 @@
1
1
  class TessituraRest
2
- VERSION = '0.8.5'
2
+ VERSION = '0.8.6.3'
3
3
  end
@@ -100,7 +100,7 @@ module Session
100
100
  'PromotionCode': 0,
101
101
  }
102
102
  options.merge!(basic_auth: @auth, headers: @headers)
103
- options.merge!(:body => parameters)
103
+ options.merge!(:body => parameters.to_json, :headers => {'Content-Type' => 'application/json'})
104
104
  self.class.put(base_api_endpoint("Web/Session/#{key}/WebLogins"), options)
105
105
  end
106
106
 
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.5
4
+ version: 0.8.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brittany Martin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,6 +135,7 @@ files:
135
135
  - lib/tessitura_rest/crm/addresses.rb
136
136
  - lib/tessitura_rest/crm/attributes.rb
137
137
  - lib/tessitura_rest/crm/constituencies.rb
138
+ - lib/tessitura_rest/crm/constituents.rb
138
139
  - lib/tessitura_rest/crm/issues.rb
139
140
  - lib/tessitura_rest/crm/phones.rb
140
141
  - lib/tessitura_rest/crm/web_logins.rb