Sha256: 25935ffebd1c04d13702643d4ffb766e5816f16fd66aa575cd274dd1fc0ee8de

Contents?: true

Size: 1.83 KB

Versions: 24

Compression:

Stored size: 1.83 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
    	},
    	'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

  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

  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

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
tessitura_rest-1.1.4 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.1.3 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.1.2 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.1.1 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.1.0 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.0.0 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.9.1.3 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.9.1.2 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.9.1.1 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.9.1 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.9.0 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.9 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.8 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.7 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.6.9 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.6.8 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.6.7 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.6.6 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.6.5 lib/tessitura_rest/crm/phones.rb
tessitura_rest-0.8.6.4 lib/tessitura_rest/crm/phones.rb