module Phones

Public Instance Methods

create_primary_phone(id, phone, options={}) click to toggle source
# File lib/tessitura_rest/crm/phones.rb, line 9
def create_primary_phone(id, phone, options={})
  parameters =
  {
      'Constituent': {
              'Id': id
      },
      'PhoneNumber': phone,
      'PhoneType': {
              'Description': 'Phone 1',
              'Id': 1,
              '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
create_secondary_phone(id, phone, options={}) click to toggle source
# File lib/tessitura_rest/crm/phones.rb, line 28
def create_secondary_phone(id, phone, options={})
  parameters =
  {
    'Constituent': {
      'Id': id
    },
    'PhoneNumber': phone,
    'PhoneType': {
      'Description': 'Phone 2',
      'Id': 2,
      '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={}) click to toggle source
# File lib/tessitura_rest/crm/phones.rb, line 3
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={}) click to toggle source
# File lib/tessitura_rest/crm/phones.rb, line 47
def update_phone(id, phone, options={})
  current = get_phone(id)
  parameters =
    {
      "Address": {
        "Id": current["Address"]["Id"],
        "AddressType": {
          "Id": current["Address"]["AddressType"]["Id"],
        }
      },
      "Constituent": {
        "Id": current["Constituent"]["Id"]
      },
      "PhoneType": {
        "Id": current["PhoneType"]["Id"],
      },
      "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