Sha256: f5db68166f03272661a361e3b65d0fa491e2ff2240a902f0a8477bc86e3ac973

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

module Phones
  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

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

  def delete_phone(id, options = {})
    options.merge!(basic_auth: @auth, headers: @headers)
    self.class.delete(base_api_endpoint("CRM/Phones/#{id}"), options)
  end

  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'],
        'IsMobile': true,
        'PrimaryIndicator': true
      }
    options.merge!(basic_auth: @auth, headers: @headers)
    options.merge!(:body => parameters.to_json)
    self.class.put(base_api_endpoint("CRM/Phones/#{id}"), options)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tessitura_rest-2.1.8 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.1.7 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.1.6 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.1.5 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.1.4 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.1.3 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.1.2 lib/tessitura_rest/crm/phones.rb