Class: Cxf::User

Inherits:
Object
  • Object
show all
Includes:
CRM, Config, Contacts, Content, 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

#change_password_no_auth, #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, #send_magic_links, #update_contact

Methods included from Helpers

#generate_seed, #get_activities_by_object_type_and_id, #get_available_types_from_usage, #get_dice_coefficient, #get_magic_link_config, #get_permission_menu, #slugify

Methods included from UserFolders

#create_user_folder, #delete_user_folder, #get_user_folder, #get_user_folders, #update_user_folder

Methods included from ObjectFolders

#create_object_folder, #delete_object_folder, #get_object_folder, #get_object_folders, #update_object_folder

Methods included from ObjectActivities

#create_object_activity, #delete_object_activity, #get_object_activities, #get_object_activity, #update_object_activity

Methods included from Profile

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

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_tag, #create_setting, #get_settings, #get_settings_by_keys

Methods included from Seeds

#apply_seeds, #get_seed_process, #get_seed_processes

Methods included from Relationships

#attach_relationship, #create_relationship, #delete_relationship, #detach_relationship, #get_relationship, #get_relationships, #get_relationships_available_for, #relationship_has_objects, #update_relationship

Methods included from Views

#create_view, #get_view, #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 Vouchers

#create_voucher, #get_voucher, #get_vouchers, #update_voucher

Methods included from VariantValues

#create_variant_value, #get_variant_value, #get_variant_values, #update_variant_value

Methods included from VariantOptions

#create_variant_option, #get_variant_option, #get_variant_options, #update_variant_option

Methods included from Taxes

#create_tax, #delete_tax, #get_tax, #get_taxes, #update_tax

Methods included from Skus

#create_sku, #delete_sku, #get_sku, #get_skus, #update_sku

Methods included from ProductVersions

#create_product_version, #delete_product_version, #get_product_version, #get_product_versions, #publish_product_version, #update_product_version

Methods included from Products

#create_product, #delete_product, #get_product, #get_product_variant_options_config, #get_products, #get_products_support_data, #revert_published_product, #schedule_product, #update_product, #update_product_variations_config

Methods included from ProductVariations

#create_product_variation, #delete_product_variation, #generate_product_variation, #get_product_from_product_variation, #get_product_variation, #get_product_variations, #set_prices_to_product_variations, #update_product_variation

Methods included from ProductTemplates

#create_product_template, #get_product_template, #get_product_templates, #get_product_templates_support_data, #get_product_templates_support_data_from_order_items_group, #get_product_templates_support_data_from_product, #update_product_template

Methods included from PriceList

#create_price_list, #get_price_list, #get_price_lists, #update_price_list

Methods included from Locations

#create_location, #create_location_template, #delete_location, #get_location, #get_location_template, #get_location_template_support_data, #get_location_templates, #get_location_templates_support_data, #get_locations, #update_location, #update_location_template

Methods included from ItemPrices

#create_item_price, #delete_item_price, #get_item_price, #get_item_prices, #update_item_price

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 Templates

#create_template, #get_template, #get_templates, #update_template

Methods included from Instances

#create_instance, #create_instance_version, #delete_instance, #duplicate_instance, #get_instance, #get_instances, #update_instance

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 StoryTemplates

#create_story_template, #get_story_template, #get_story_template_support_data, #get_story_templates, #get_story_templates_support_data, #update_story_template

Methods included from PrintVersions

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

Methods included from Stories

#create_story, #delete_story, #duplicate_story, #get_stories, #get_story, #update_story

Methods included from Assets

#create_asset, #create_asset_size, #delete_asset, #download_asset, #generate_asset_variation, #get_asset, #get_asset_doc_types, #get_asset_info, #get_asset_link_info, #get_asset_public_route, #get_asset_size, #get_asset_sizes, #get_asset_thumbnails, #get_asset_usage, #get_asset_variation, #get_assets, #update_asset, #upload_asset

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.



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

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.



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

def client
  @client
end

Instance Method Details

#get_clientObject



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

def get_client
  @client
end

#login(email, password) ⇒ Object



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

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


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

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

Send magic link to user



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

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