class Adparlor::Facebook::GraphApi::CustomAudienceUser
Constants
- FIELD_KEYS
Public Instance Methods
destroy(path, options = {})
click to toggle source
Calls superclass method
Adparlor::Facebook::GraphApi::Traits::Methods#destroy
# File lib/adparlor/facebook/graph_api/custom_audience_user.rb, line 24 def destroy(path, options = {}) if @custom_audience_id destroy_path = "/#{custom_audience_id}/users" else raise FbError.new('required parameter account_id missing', 500) unless @account_id account_id = remove_instance_variable(:@account_id) destroy_path = "act_#{account_id}/usersofanyaudience" end ready_payload super(destroy_path, options) end
path()
click to toggle source
# File lib/adparlor/facebook/graph_api/custom_audience_user.rb, line 36 def path raise FbError.new('required parameter custom_audience_id missing', 500) unless custom_audience_id "/#{custom_audience_id}/users" end
update(path, options = {})
click to toggle source
Calls superclass method
Adparlor::Facebook::GraphApi::Traits::Methods#update
# File lib/adparlor/facebook/graph_api/custom_audience_user.rb, line 41 def update(path, options = {}) ready_payload super(path, options) end
Private Instance Methods
normalize_object(obj, type)
click to toggle source
# File lib/adparlor/facebook/graph_api/custom_audience_user.rb, line 61 def normalize_object(obj, type) audience_type = type.is_a?(Array) ? type.first : type case audience_type when 'EMAIL_SHA256' Digest::SHA256.hexdigest(obj.downcase.strip) when 'PHONE_SHA256' Digest::SHA256.hexdigest(obj.gsub(/\D/, '')) when 'GEN' if obj.downcase.include?('fe') [Digest::SHA256.hexdigest('f')] else [Digest::SHA256.hexdigest('m')] end when 'LN', 'FN', 'CT' [Digest::SHA256.hexdigest(obj.gsub(/(\W+|[0-9 ]+)/, ''))] when 'ST', 'ZIP', 'MADID' [Digest::SHA256.hexdigest(obj.downcase)] else Digest::SHA256.hexdigest(obj) end end
ready_payload()
click to toggle source
# File lib/adparlor/facebook/graph_api/custom_audience_user.rb, line 48 def ready_payload schema, data = [], [] instance_variables.each do |iv| schema_key = FIELD_KEYS[iv.to_s.delete('@').to_sym] schema << schema_key data << instance_variable_get(iv).map { |obj| normalize_object(obj, schema_key) } remove_instance_variable iv end schema = schema.first if schema.length == 1 data = data.first if data.length == 1 @payload = { schema: schema, data: data } end