Class: Cxf::User

Inherits:
Object
  • Object
show all
Includes:
Config, Contacts, Content, CustomerData, CxfHelper, Ecommerce, Helpers, Marketing, Profile, ThreadsHelper
Defined in:
lib/user.rb

Overview

User context API

User class contains functions that needs an API key and a session token as authentication

Usage example

Initialize

client = Cxf::User.new(cxf_url, api_key)

Call any function

client.get_contacts

Single resource options

  • include - [String] include a relationship

  • attributes - [Boolean] attach attributes to response

  • tags - [Boolean] attach tags to response

  • taxonomies - [Boolean] attach categories to response

Resource collections options

  • search - [String] filter by a search word

  • scopes - [String] filter by a scope

  • filters - [String] filter by where clauses

  • jfilters - [String] filter using complex condition objects (this filter use mongo queries)

  • afilters - [String] filter using complex condition objects (this filter use postgresql queries)

  • rfilters - [String] filter using complex condition objects from relationships

  • dfilters - [String] filter using conditions based on dates

  • fields - [String] indicates the columns that will be selected

  • sort - [String] indicates the columns that will be selected

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ThreadsHelper

#make_multiple_request

Methods included from CxfHelper

#correct_json, #data_transform, #get_query_results

Methods included from Contacts

#add_contact_profile, #create_contact, #create_contact_deal, #create_contact_user, #delete_contact_deal, #delete_contact_user, #delete_contacts, #get_contact, #get_contact_deal, #get_contact_segments, #get_contact_submissions, #get_contact_tags, #get_contact_user, #get_contacts, #get_contacts_support_data, #get_online_activity, #merge_contacts, #remove_contact_profile, #send_magic_links, #update_contact

Methods included from Helpers

#slugify

Methods included from Profile

#create_preferences, #delete_notifications, #get_notifications, #get_preferences, #get_preferences_by_setting_key, #me, #read_notifications

Methods included from Calendars

#create_calendar, #delete_calendar, #get_calendar, #get_calendars, #update_calendar

Methods included from Password

#update_password

Methods included from Logs

#create_log, #delete_log, #get_log, #get_logs, #update_log

Methods included from Exports

#get_export, #get_export_jobs_using_view_id, #get_exports

Methods included from Docs

#generate_docs, #get_doc_jobs

Methods included from Users

#can_users_coach, #create_user, #get_user, #get_users, #update_user

Methods included from Taxonomies

#create_taxonomy, #get_taxonomies, #get_taxonomies_for_object, #get_taxonomies_support_data, #get_taxonomy, #sync_taxonomies_for_object, #update_taxonomy

Methods included from Tags

#create_tag, #get_tag, #get_tags, #update_tag

Methods included from SystemSettings

#clear_settings_cache, #create_setting, #get_settings, #get_settings_by_keys

Methods included from Seeds

#get_seed_process_status, #process_seed

Methods included from Relationships

#attach_relationship, #create_relationship, #delete_relationship, #detach_relationship, #get_relationship, #get_relationships, #update_relationship, #update_relationship_pivot_fields

Methods included from Views

#create_view, #export_view_to_bigquery, #get_view, #get_view_query, #get_views, #update_view

Methods included from Attributes

#create_attribute, #get_attribute, #get_attributes, #get_attributes_data_types, #get_sub_attributes, #update_attribute

Methods included from AttributeGroups

#create_attribute_group, #get_attribute_group, #get_attribute_groups, #get_attribute_groups_data_types, #update_attribute_group

Methods included from OrderTemplates

#create_order_template, #delete_order_template, #get_order_template, #get_order_templates, #update_order_template

Methods included from Orders

#add_order_line_item, #change_order_status, #create_child_order, #create_order, #delete_order, #delete_order_line_item, #get_order, #get_orders, #reorder_order_line_item, #update_order, #update_order_line_item, #update_order_unit_line_item

Methods included from ItemCodes

#create_item_code, #delete_item_code, #get_item_code, #get_item_codes, #update_item_code

Methods included from Marketing

#create_automation, #delete_automation, #duplicate_automation, #get_automation, #get_automation_executions, #get_automations, #reset_automation, #update_automation

Methods included from Content

#create_keyword, #create_stage, #get_keyword, #get_keywords, #get_public_images_url, #get_stage, #get_stages, #update_keyword, #update_stage

Methods included from Prints

#create_print, #delete_print, #get_print, #get_prints, #update_print

Methods included from MessageTemplates

#create_message_template, #delete_message_template, #get_message_template, #get_message_templates, #send_message_template, #update_message_template

Methods included from Bundles

#create_bundle, #delete_bundle, #get_bundle, #get_bundles, #update_bundle

Methods included from Templates

#create_template, #create_template_variant_option, #delete_template_variant_option, #get_template, #get_templates, #update_template

Methods included from PrintVersions

#create_print_version, #create_print_version_from_print_version, #delete_print_version, #duplicate_print_version, #get_print_version, #get_print_versions, #publish_print_version, #update_print_version

Methods included from Instances

#add_variant_value_to_instance, #create_instance, #create_instance_version, #create_item_code_for_instance, #delete_instance, #delete_variant_value_from_instance, #duplicate_instance, #get_instance, #get_instances, #get_intance_variations, #update_instance

Methods included from ContentPrints

#create_content_print, #delete_content_print, #get_content_print, #get_content_prints, #update_content_print

Methods included from ContentBundles

#create_content_bundle, #delete_content_bundle, #get_content_bundle, #get_content_bundles, #update_content_bundle

Methods included from BlockTemplates

#create_block_template, #get_block_template, #get_block_templates, #update_block_template

Methods included from Blocks

#create_block, #delete_block, #duplicate_block, #get_block, #get_blocks, #update_block

Methods included from Assets

#create_asset, #delete_asset, #get_asset, #get_asset_usage, #get_assets, #update_asset

Methods included from WorkflowSteps

#attach_workflow_step, #create_workflow_step, #delete_workflow_steps, #detach_workflow_step, #get_workflow_step, #get_workflow_steps, #update_workflow_step

Methods included from Workflows

#check_workflow_object_steps, #create_workflow, #delete_workflows, #get_workflow, #get_workflows, #update_workflow, #update_workflow_object_steps

Methods included from Segments

#create_segment, #delete_segments, #get_segment, #get_segments, #update_segment

Methods included from Profiles

#create_profile, #delete_profiles, #get_profile, #get_profiles, #update_profile

Methods included from Companies

#create_company, #delete_companies, #get_companies, #get_companies_support_data, #get_company, #update_company

Constructor Details

#initialize(host, api_key, session_token = nil, refresh_token = nil, debug = false, user_agent = nil, timeouts = {}) ⇒ User

Returns a new instance of User.


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/user.rb', line 53

def initialize(host, api_key, session_token = nil, refresh_token = nil, debug = false, user_agent = nil, timeouts = {})
  @client = Cxf::Client.new(
    host,
    api_key,
    'user',
    session_token,
    refresh_token,
    nil,
    nil,
    debug,
    timeouts,
  )

  @client.user_agent = user_agent
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.


51
52
53
# File 'lib/user.rb', line 51

def client
  @client
end

Instance Method Details

#get_clientObject


95
96
97
# File 'lib/user.rb', line 95

def get_client
  @client
end

#login(email, password) ⇒ Object


69
70
71
72
73
74
75
76
77
78
# File 'lib/user.rb', line 69

def (email, password)
  data = { email: email, password: password }
  response = @client.raw('post', '/users/login', nil, data.to_json, '/api/v1', { no_content_type: true })
  # @client.session_token = response['api_token'] if response.key? 'api_token'
  if response.key? 'data' and response['data'].key? 'access_token'
    @client.session_token = response['data']['access_token']
    @client.refresh_token = response['data']['refresh_token']
  end
  response
end

80
81
82
# File 'lib/user.rb', line 80

def (token)
  @client.raw('get', "/users/magic-link-login/#{token}", nil, nil, '/api/v1')
end

Send magic link to user


86
87
88
89
90
91
92
93
# File 'lib/user.rb', line 86

def send_magic_link(email, redirect_url = '', life_time = 24)
  data = {
    email: email,
    redirectUrl: redirect_url,
    lifeTime: life_time
  }
  @client.raw('post', '/users/magic-link', nil, { data: data }, '/api/v1')
end