Module: Phones

Included in:
TessituraRest
Defined in:
lib/tessitura_rest/crm/phones.rb

Instance Method Summary collapse

Instance Method Details

#create_primary_phone(id, phone, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tessitura_rest/crm/phones.rb', line 8

def create_primary_phone(id, phone, options = {})
  parameters =
    {
      'Constituent': {
        'Id': id,
      },
      'PhoneNumber': phone,
      'PhoneType': {
        'Description': 'Cell Phone',
        'Id': 5,
        'Inactive': false,
      },
    }
  options.merge!(basic_auth: @auth, headers: @headers)
  options.merge!(:body => parameters)
  response = self.class.post(base_api_endpoint('CRM/Phones'), options)
  JSON.parse(response.body)
end

#get_phone(id, options = {}) ⇒ Object



2
3
4
5
6
# File 'lib/tessitura_rest/crm/phones.rb', line 2

def get_phone(id, options = {})
  options.merge!(basic_auth: @auth, headers: @headers)
  response = self.class.get(base_api_endpoint("CRM/Phones/#{id}"), options)
  JSON.parse(response.body)
end

#update_phone(id, phone, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tessitura_rest/crm/phones.rb', line 27

def update_phone(id, phone, options = {})
  current = get_phone(id)
  parameters =
    {
      'Constituent': {
        'Id': current['Constituent']['Id'],
      },
      'PhoneType': {
        'Id': 5,
      },
      'Id': current['Id'],
      'PhoneNumber': phone,
      'UpdatedDateTime': current['UpdatedDateTime'],
    }
  options.merge!(basic_auth: @auth, headers: @headers)
  options.merge!(:body => parameters)
  self.class.put(base_api_endpoint("CRM/Phones/#{id}"), options)
end