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