tessitura_rest 0.8.5.1 → 0.8.6

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: aa8fdef7873685e3a8b5673ff9cd8c85e68bb479383109c4b27cafa315816b0d
4
- data.tar.gz: d63ca4291e1cfcc12e28f3b16690fa2d670996109a37031a41974e461f5aac43
3
+ metadata.gz: 8ce97e962168e19a75d57d0a227c85bfcd2ede2ba17a0171d03211c3fe4e74d9
4
+ data.tar.gz: 1156459b00c1f389cbba7bffa93ff66db4457effdfeeae699cf70eeb01661da7
5
5
  SHA512:
6
- metadata.gz: db67dc630c0d34cde442b0a2253ac44d909a27be8769ab8ad2bf21f8e94b20e8c74f655bb4aa42886dfdb471429f089c592a7be8b57d72dfad504daf61b9922d
7
- data.tar.gz: 0e68f178a88f864813fd8b81d15a913fca2ef8572a84a7e58ce72486990ae6c724270c5585b3ee8342b00623b11c43cd53238e8ef6cb48793f19b150179d2e02
6
+ metadata.gz: e15d99cd90fc0088e2a67720ac7105b20ce1f484cd99fe32fe0633dc94116300373a6aa7dc93fe1227113e366293005884ea3e5725c5cb2280fd80bd8e95d154
7
+ data.tar.gz: 93f78518ee524a716a0c775b47dcaad08c5e254209767dd0bb0561c526467d9d54f78bc63ecd7d29245fda24a22a64ccd5896a0cc6b8e3d61c96df6e70921056
@@ -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,77 +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
- parameters.delete(:PrimaryPhoneNumbers) unless phone.present?
65
- options.merge!(basic_auth: @auth, headers: @headers)
66
- options.merge!(:body => parameters.to_json, :headers => { 'Content-Type' => 'application/json' })
67
- self.class.post(base_api_endpoint('CRM/Constituents/Snapshot'), options)
68
- end
69
-
70
- def update_constituent(constituent_id, options={})
71
- parameters =
72
- {
73
-
74
- }
75
- options.merge!(basic_auth: @auth, headers: @headers)
76
- options.merge!(:body => parameters)
77
- self.class.put(base_api_endpoint("CRM/Constituents/#{constituent_id}"), options)
78
- end
79
-
80
9
  def create_constituencies(constituency, id, options={})
81
10
  parameters =
82
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
@@ -1,3 +1,3 @@
1
1
  class TessituraRest
2
- VERSION = '0.8.5.1'
2
+ VERSION = '0.8.6'
3
3
  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.5.1
4
+ version: 0.8.6
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-22 00:00:00.000000000 Z
11
+ date: 2021-01-29 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