Sha256: 2253b288eff766e2736d38100159968e99079289cae7022390c19a457cde1a32

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 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': 'Cell Phone',
          'Id': 5,
          'Inactive': false,
        },
      }
    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 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.to_json)
    self.class.put(base_api_endpoint("CRM/Phones/#{id}"), options)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tessitura_rest-2.0.1 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.5.2 lib/tessitura_rest/crm/phones.rb
tessitura_rest-2.0.0 lib/tessitura_rest/crm/phones.rb
tessitura_rest-1.5.1 lib/tessitura_rest/crm/phones.rb