cxf 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +12 -0
- data/README.md +395 -0
- data/lib/client.rb +447 -0
- data/lib/contact/config/config.rb +4 -0
- data/lib/contact/content/content.rb +4 -0
- data/lib/contact/ecommerce/ecommerce.rb +4 -0
- data/lib/contact.rb +284 -0
- data/lib/cxf/controllers/admin_base_controller.rb +17 -0
- data/lib/cxf/controllers/base_api_controller.rb +28 -0
- data/lib/cxf/controllers/base_controller.rb +54 -0
- data/lib/cxf/controllers/concerns/cxf_clients.rb +104 -0
- data/lib/cxf/controllers/concerns/read_config_file.rb +30 -0
- data/lib/cxf/controllers/contact_api_controller.rb +17 -0
- data/lib/cxf/controllers/public_api_controller.rb +14 -0
- data/lib/cxf/controllers/user_api_controller.rb +16 -0
- data/lib/cxf/helpers/contact_auth_helper.rb +86 -0
- data/lib/cxf/helpers/cxf_helper.rb +52 -0
- data/lib/cxf/helpers/proxy_controllers_methods.rb +144 -0
- data/lib/cxf/helpers/threads_helper.rb +109 -0
- data/lib/cxf/helpers/user_auth_helper.rb +74 -0
- data/lib/cxf.rb +15 -0
- data/lib/errors.rb +109 -0
- data/lib/generators/cxf_assets_controller.rb +7 -0
- data/lib/generators/cxf_config.yml.erb +27 -0
- data/lib/generators/cxf_contact_controller.rb +7 -0
- data/lib/generators/cxf_files_generator.rb +28 -0
- data/lib/generators/cxf_public_controller.rb +7 -0
- data/lib/generators/cxf_user_controller.rb +7 -0
- data/lib/pub/config/config.rb +6 -0
- data/lib/pub/content/assets.rb +16 -0
- data/lib/pub/content/content.rb +9 -0
- data/lib/pub/ecommerce/ecommerce.rb +6 -0
- data/lib/pub.rb +163 -0
- data/lib/user/config/attribute_groups.rb +79 -0
- data/lib/user/config/attributes.rb +88 -0
- data/lib/user/config/calendars.rb +91 -0
- data/lib/user/config/config.rb +23 -0
- data/lib/user/config/relationships.rb +141 -0
- data/lib/user/config/seeds.rb +55 -0
- data/lib/user/config/system_settings.rb +54 -0
- data/lib/user/config/tags.rb +61 -0
- data/lib/user/config/taxonomies.rb +120 -0
- data/lib/user/config/users.rb +77 -0
- data/lib/user/config/views.rb +68 -0
- data/lib/user/contacts/contacts.rb +22 -0
- data/lib/user/content/assets.rb +294 -0
- data/lib/user/content/block_templates.rb +72 -0
- data/lib/user/content/blocks.rb +109 -0
- data/lib/user/content/content.rb +174 -0
- data/lib/user/content/instances.rb +121 -0
- data/lib/user/content/print_versions.rb +129 -0
- data/lib/user/content/stories.rb +110 -0
- data/lib/user/content/story_templates.rb +97 -0
- data/lib/user/content/templates.rb +72 -0
- data/lib/user/crm/companies.rb +111 -0
- data/lib/user/crm/contacts.rb +294 -0
- data/lib/user/crm/crm.rb +9 -0
- data/lib/user/ecommerce/ecommerce.rb +29 -0
- data/lib/user/ecommerce/item_prices.rb +89 -0
- data/lib/user/ecommerce/locations.rb +171 -0
- data/lib/user/ecommerce/price_lists.rb +75 -0
- data/lib/user/ecommerce/product_templates.rb +106 -0
- data/lib/user/ecommerce/product_variations.rb +133 -0
- data/lib/user/ecommerce/product_versions.rb +107 -0
- data/lib/user/ecommerce/products.rb +156 -0
- data/lib/user/ecommerce/skus.rb +90 -0
- data/lib/user/ecommerce/taxes.rb +84 -0
- data/lib/user/ecommerce/variant_options.rb +71 -0
- data/lib/user/ecommerce/variant_values.rb +74 -0
- data/lib/user/ecommerce/vouchers.rb +90 -0
- data/lib/user/helpers/helpers.rb +116 -0
- data/lib/user/helpers/object_activities.rb +85 -0
- data/lib/user/helpers/object_folders.rb +84 -0
- data/lib/user/helpers/user_folders.rb +85 -0
- data/lib/user/marketing/marketing.rb +123 -0
- data/lib/user/profile/profile.rb +104 -0
- data/lib/user.rb +98 -0
- metadata +227 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ObjectActivities
|
4
|
+
##
|
5
|
+
# == Object Activities
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get object activities.
|
9
|
+
# Get a collection of object activities.
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
13
|
+
#
|
14
|
+
# ==== First Example
|
15
|
+
# @data = @cxf_user.get_object_activities
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = { fields: 'object_type' }
|
19
|
+
# @data = @cxf_user.get_object_activities(options)
|
20
|
+
def get_object_activities(options = nil)
|
21
|
+
@client.raw('get', '/helpers/object-activities', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# === Get object activity.
|
25
|
+
# Get an object activity.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# id:: (Integer) -- Object activity id.
|
29
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
30
|
+
#
|
31
|
+
# ==== First Example
|
32
|
+
# @data = @cxf_user.get_object_activity(1)
|
33
|
+
#
|
34
|
+
# ==== Second Example
|
35
|
+
# options = { fields: 'activity_type' }
|
36
|
+
# @data = @cxf_user.get_object_activity(1, options)
|
37
|
+
def get_object_activity(id, options = nil)
|
38
|
+
@client.raw('get', "/helpers/object-activities/#{id}", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# === Create object activity.
|
42
|
+
# Create an object activity with data.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# data:: (Hash) -- Data to be submitted.
|
46
|
+
#
|
47
|
+
# ==== Example
|
48
|
+
# data = {
|
49
|
+
# activity_type: 'note',
|
50
|
+
# object_type: 'contacts',
|
51
|
+
# object_id: 1
|
52
|
+
# }
|
53
|
+
# @data = @cxf_user.create_object_activity(data)
|
54
|
+
def create_object_activity(data)
|
55
|
+
@client.raw('post', '/helpers/object-activities', nil, data_transform(data))
|
56
|
+
end
|
57
|
+
|
58
|
+
# === Update object activity.
|
59
|
+
# Update an object activity info.
|
60
|
+
#
|
61
|
+
# ==== Parameters
|
62
|
+
# id:: (Integer) -- Object activity id.
|
63
|
+
# data:: (Hash) -- Data to be submitted.
|
64
|
+
#
|
65
|
+
# ==== Example
|
66
|
+
# data = {
|
67
|
+
# activity_type: 'ticket'
|
68
|
+
# }
|
69
|
+
# @data = @cxf_user.update_object_activity(573, data)
|
70
|
+
def update_object_activity(id, data)
|
71
|
+
@client.raw('put', "/helpers/object-activities/#{id}", nil, data_transform(data))
|
72
|
+
end
|
73
|
+
|
74
|
+
# === Delete object activity.
|
75
|
+
# Delete an object activity.
|
76
|
+
#
|
77
|
+
# ==== Parameters
|
78
|
+
# id:: (Integer) -- Object activity id.
|
79
|
+
#
|
80
|
+
# ==== Example
|
81
|
+
# @data = @cxf_user.delete_object_activity(573)
|
82
|
+
def delete_object_activity(id)
|
83
|
+
@client.raw('delete', "/helpers/object-activities/#{id}")
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ObjectFolders
|
4
|
+
##
|
5
|
+
# == Object Folders
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get object folders.
|
9
|
+
# Get a collection of object folders.
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
13
|
+
#
|
14
|
+
# ==== First Example
|
15
|
+
# @data = @cxf_user.get_object_folders
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = { fields: "id" }
|
19
|
+
# @data = @cxf_user.get_object_folders(options)
|
20
|
+
def get_object_folders(options = nil)
|
21
|
+
@client.raw('get', '/helpers/object-folders', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# === Get object folder.
|
25
|
+
# Get an object folder info.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# id:: (Integer) -- Object folders id.
|
29
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
30
|
+
#
|
31
|
+
# ==== First Example
|
32
|
+
# @data = @cxf_user.get_object_folder(1)
|
33
|
+
#
|
34
|
+
# ==== Second Example
|
35
|
+
# options = { fields: 'id' }
|
36
|
+
# @data = @cxf_user.get_object_folder(1, options)
|
37
|
+
def get_object_folder(id, options = nil)
|
38
|
+
@client.raw('get', "/helpers/object-folders/#{id}", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# === Create object folder.
|
42
|
+
# Create an object folder with data.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# data:: (Hash) -- Data to be submitted.
|
46
|
+
#
|
47
|
+
# ==== Example
|
48
|
+
# data = {
|
49
|
+
# folder_id: 1,
|
50
|
+
# object_id: 1
|
51
|
+
# }
|
52
|
+
# @data = @cxf_user.create_object_folder(data)
|
53
|
+
def create_object_folder(data)
|
54
|
+
@client.raw('post', '/helpers/object-folders', nil, data_transform(data))
|
55
|
+
end
|
56
|
+
|
57
|
+
# === Update object folder.
|
58
|
+
# Update an object folder info.
|
59
|
+
#
|
60
|
+
# ==== Parameters
|
61
|
+
# id:: (Integer) -- Object folder id.
|
62
|
+
# data:: (Hash) -- Data to be submitted.
|
63
|
+
#
|
64
|
+
# ==== Example
|
65
|
+
# data = {
|
66
|
+
# folder_id: 2
|
67
|
+
# }
|
68
|
+
# @data = @cxf_user.update_object_folder(1, data)
|
69
|
+
def update_object_folder(id, data)
|
70
|
+
@client.raw('put', "/helpers/object-folders/#{id}", nil, data_transform(data))
|
71
|
+
end
|
72
|
+
|
73
|
+
# === Delete object folder.
|
74
|
+
# Delete an object folder.
|
75
|
+
#
|
76
|
+
# ==== Parameters
|
77
|
+
# id:: (Integer) -- Object folder id.
|
78
|
+
#
|
79
|
+
# ==== Example
|
80
|
+
# @data = @cxf_user.delete_object_folder(2)
|
81
|
+
def delete_object_folder(id)
|
82
|
+
@client.raw('delete', "/helpers/object-folders/#{id}")
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UserFolders
|
4
|
+
##
|
5
|
+
# == User Folders
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get user folders.
|
9
|
+
# Get a collection of user folders.
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
13
|
+
#
|
14
|
+
# ==== First Example
|
15
|
+
# @data = @cxf_user.get_user_folders
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = { fields: 'folder' }
|
19
|
+
# @data = @cxf_user.get_user_folders(options)
|
20
|
+
def get_user_folders(options = nil)
|
21
|
+
@client.raw('get', '/helpers/folders', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# === Get user folder.
|
25
|
+
# Get an user folder info.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# id:: (Integer) -- User folder id.
|
29
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
30
|
+
#
|
31
|
+
# ==== First Example
|
32
|
+
# @data = @cxf_user.get_user_folder(1)
|
33
|
+
#
|
34
|
+
# ==== Second Example
|
35
|
+
# options = { fields: 'user_id, folder' }
|
36
|
+
# @data = @cxf_user.get_user_folder(1, options)
|
37
|
+
def get_user_folder(id, options = nil)
|
38
|
+
@client.raw('get', "/helpers/folders/#{id}", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# === Create user folder.
|
42
|
+
# Create an user folder with data.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# data:: (Hash) -- Data to be submitted.
|
46
|
+
#
|
47
|
+
# ==== Example
|
48
|
+
# data = {
|
49
|
+
# folder: 'new-user-folder',
|
50
|
+
# object_type: 'contacts'
|
51
|
+
# }
|
52
|
+
# @data = @cxf_user.create_user_folder(data)
|
53
|
+
def create_user_folder(data)
|
54
|
+
@client.raw('post', '/helpers/folders', nil, data_transform(data))
|
55
|
+
end
|
56
|
+
|
57
|
+
# === Update user folder.
|
58
|
+
# Update an user folder info.
|
59
|
+
#
|
60
|
+
# ==== Parameters
|
61
|
+
# id:: (Integer) -- User folder id.
|
62
|
+
# data:: (Hash) -- Data to be submitted.
|
63
|
+
#
|
64
|
+
# ==== Example
|
65
|
+
# data = {
|
66
|
+
# folder:'new-user-folder-modifier',
|
67
|
+
# object_type:'contact'
|
68
|
+
# }
|
69
|
+
# @data = @cxf_user.update_user_folder(289, data)
|
70
|
+
def update_user_folder(id, data)
|
71
|
+
@client.raw('put', "/helpers/folders/#{id}", nil, data_transform(data))
|
72
|
+
end
|
73
|
+
|
74
|
+
# === Delete user folder.
|
75
|
+
# Delete an user folder.
|
76
|
+
#
|
77
|
+
# ==== Parameters
|
78
|
+
# id:: (Integer) -- User folder id.
|
79
|
+
#
|
80
|
+
# ==== Example
|
81
|
+
# @data = @cxf_user.delete_user_folder(289)
|
82
|
+
def delete_user_folder(id)
|
83
|
+
@client.raw('delete', "/helpers/folders/#{id}")
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Marketing
|
4
|
+
##
|
5
|
+
# == Automation
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get automations.
|
9
|
+
# Get a collection of automations.
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
13
|
+
#
|
14
|
+
# ==== First Example
|
15
|
+
# @data = @cxf_user.get_automations
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = {
|
19
|
+
# fields: 'title'
|
20
|
+
# }
|
21
|
+
# @data = @cxf_user.get_automations(options)
|
22
|
+
def get_automations(options = nil)
|
23
|
+
@client.raw('get', '/marketing/automation', options)
|
24
|
+
end
|
25
|
+
|
26
|
+
# === Get automation.
|
27
|
+
# Get an automation info.
|
28
|
+
#
|
29
|
+
# ==== Parameters
|
30
|
+
# id:: (Integer) -- Automation id.
|
31
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
32
|
+
#
|
33
|
+
# ==== First Example
|
34
|
+
# @data = @cxf_user.get_automation(1)
|
35
|
+
#
|
36
|
+
# ==== Second Example
|
37
|
+
# options = {
|
38
|
+
# fields: 'title, id'
|
39
|
+
# }
|
40
|
+
# @data = @cxf_user.get_automation(1, options)
|
41
|
+
def get_automation(id, options = nil)
|
42
|
+
@client.raw('get', "/marketing/automation/#{id}", options)
|
43
|
+
end
|
44
|
+
|
45
|
+
# === Create automation.
|
46
|
+
# Create an automation with data.
|
47
|
+
#
|
48
|
+
# ==== Parameters
|
49
|
+
# data:: (Hash) -- Data to be submitted.
|
50
|
+
#
|
51
|
+
# ==== Example
|
52
|
+
# data = {
|
53
|
+
# title: 'New Automation'
|
54
|
+
# }
|
55
|
+
# @data = @cxf_user.create_automation(data)
|
56
|
+
def create_automation(data)
|
57
|
+
@client.raw('post', '/marketing/automation/', nil, data_transform(data))
|
58
|
+
end
|
59
|
+
|
60
|
+
# === Update automation.
|
61
|
+
# Update an automation info.
|
62
|
+
#
|
63
|
+
# ==== Parameters
|
64
|
+
# id:: (Integer) -- Automation id.
|
65
|
+
# data:: (Hash) -- Data to be submitted.
|
66
|
+
#
|
67
|
+
def update_automation(id, data)
|
68
|
+
# FIXME: Method doesn't work.
|
69
|
+
@client.raw('put', "/marketing/automation/#{id}", nil, data_transform(data))
|
70
|
+
end
|
71
|
+
|
72
|
+
# === Delete automation.
|
73
|
+
# Delete an automation.
|
74
|
+
#
|
75
|
+
# ==== Parameters
|
76
|
+
# id:: (Integer) -- Automation id.
|
77
|
+
#
|
78
|
+
# ==== Example
|
79
|
+
# @data = @cxf_user.delete_automation(5)
|
80
|
+
def delete_automation(id)
|
81
|
+
@client.raw('delete', "/marketing/automation/#{id}")
|
82
|
+
end
|
83
|
+
|
84
|
+
# === Get automation executions.
|
85
|
+
# Get executions of an automation.
|
86
|
+
#
|
87
|
+
# ==== Parameters
|
88
|
+
# id:: (Integer) -- Automation id.
|
89
|
+
#
|
90
|
+
# ==== Example
|
91
|
+
# @data = @cxf_user.get_automation_executions(1)
|
92
|
+
def get_automation_executions(id)
|
93
|
+
@client.raw('get', "/marketing/automation/#{id}/executions")
|
94
|
+
end
|
95
|
+
|
96
|
+
# === Reset automation.
|
97
|
+
# Reset an automation.
|
98
|
+
#
|
99
|
+
# ==== Parameters
|
100
|
+
# id:: (Integer) -- Automation id.
|
101
|
+
#
|
102
|
+
# ==== Example
|
103
|
+
# @data = @cxf_user.reset_automation(1)
|
104
|
+
def reset_automation(id)
|
105
|
+
@client.raw('post', "/marketing/automation/#{id}/reset")
|
106
|
+
end
|
107
|
+
|
108
|
+
# === Duplicate automation.
|
109
|
+
# Duplicate an automation.
|
110
|
+
#
|
111
|
+
# ==== Parameters
|
112
|
+
# id:: (Integer) -- Automation id.
|
113
|
+
# data:: (Hash) -- Data to be submitted.
|
114
|
+
#
|
115
|
+
# ==== Example
|
116
|
+
# data = {
|
117
|
+
# options: []
|
118
|
+
# }
|
119
|
+
# @data = @cxf_user.duplicate_automation(1, data.to_json)
|
120
|
+
def duplicate_automation(id, data)
|
121
|
+
@client.raw('post', "/marketing/automation/#{id}/duplicate", nil, data)
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Profile
|
4
|
+
##
|
5
|
+
# === Me.
|
6
|
+
# Get contact logged info.
|
7
|
+
#
|
8
|
+
# ==== Example
|
9
|
+
# @data = @cxf_user.me
|
10
|
+
def me(options = nil)
|
11
|
+
@client.raw('get', '/profile/me', options)
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# == User Preferences
|
16
|
+
#
|
17
|
+
|
18
|
+
##
|
19
|
+
# === Get preferences.
|
20
|
+
# Get preferences of current user logged.
|
21
|
+
#
|
22
|
+
# ==== Example
|
23
|
+
# @data = @cxf_user.get_preferences
|
24
|
+
def get_preferences
|
25
|
+
@client.raw('get', '/profile/preferences')
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# === Create preferences.
|
30
|
+
# Create preferences of current user logged with data.
|
31
|
+
#
|
32
|
+
# ==== Parameters
|
33
|
+
# data:: (Hash) -- Data to be submitted.
|
34
|
+
#
|
35
|
+
# ==== Example
|
36
|
+
# data = {
|
37
|
+
# time_zone: 'GMT-5'
|
38
|
+
# }
|
39
|
+
# @data = @cxf_user.create_preferences(data)
|
40
|
+
def create_preferences(data)
|
41
|
+
@client.raw('post', '/profile/preferences', nil, data_transform(data))
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# === Get preferences by setting key.
|
46
|
+
# Get preferences using a setting key.
|
47
|
+
#
|
48
|
+
# ==== Parameters
|
49
|
+
# setting_key:: (String) -- Setting key.
|
50
|
+
#
|
51
|
+
# ==== Example
|
52
|
+
# @data = @cxf_user.get_preferences_by_setting_key('time_zone')
|
53
|
+
def get_preferences_by_setting_key(setting_key)
|
54
|
+
@client.raw('get', "/profile/preferences/#{setting_key}")
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# == Notifications
|
59
|
+
#
|
60
|
+
|
61
|
+
# === Get notifications.
|
62
|
+
# Get a collection of notifications.
|
63
|
+
#
|
64
|
+
# ==== Example
|
65
|
+
# @data = @cxf_user.get_notifications
|
66
|
+
def get_notifications(options = nil)
|
67
|
+
@client.raw('get', '/profile/notifications', options)
|
68
|
+
end
|
69
|
+
|
70
|
+
# === Read notifications.
|
71
|
+
# Read notifications by data.
|
72
|
+
#
|
73
|
+
# ==== Parameters
|
74
|
+
# data:: (Hash) -- Data to be submitted.
|
75
|
+
#
|
76
|
+
# ==== Example
|
77
|
+
# data = {
|
78
|
+
# ids: %w[406e9b74-4a9d-42f2-afc6-1587bad6147c a2d9f582-1bdb-4e55-8af0-cd1962eaa88c],
|
79
|
+
# read: true
|
80
|
+
# }
|
81
|
+
# @data = @cxf_user.read_notifications(data)
|
82
|
+
def read_notifications(data)
|
83
|
+
# TODO: Inform NotificationController.read method has been modified
|
84
|
+
# TODO: Method in controller didnt return data
|
85
|
+
@client.raw('post', '/profile/notifications/read', nil, data_transform(data))
|
86
|
+
end
|
87
|
+
|
88
|
+
# === Delete notifications.
|
89
|
+
# Delete notifications by data.
|
90
|
+
#
|
91
|
+
# ==== Parameters
|
92
|
+
# data:: (Hash) -- Data to be submitted.
|
93
|
+
#
|
94
|
+
# ==== Example
|
95
|
+
# data = {
|
96
|
+
# ids: ['179083e3-3678-4cf6-b75e-5a8b9761245e']
|
97
|
+
# }
|
98
|
+
# @data = @cxf_user.delete_notifications(data)
|
99
|
+
def delete_notifications(data)
|
100
|
+
# TODO: Inform NotificationController.delete method has been modified
|
101
|
+
# TODO: Method in controller didnt return data
|
102
|
+
@client.raw('post', '/profile/notifications/delete', nil, data_transform(data))
|
103
|
+
end
|
104
|
+
end
|
data/lib/user.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './client'
|
4
|
+
require_relative './cxf/helpers/cxf_helper'
|
5
|
+
require_relative './cxf/helpers/threads_helper'
|
6
|
+
require_relative './user/crm/crm'
|
7
|
+
require_relative './user/content/content'
|
8
|
+
require_relative './user/marketing/marketing'
|
9
|
+
require_relative './user/ecommerce/ecommerce'
|
10
|
+
require_relative './user/config/config'
|
11
|
+
require_relative './user/profile/profile'
|
12
|
+
require_relative './user/helpers/helpers'
|
13
|
+
require_relative './user/contacts/contacts'
|
14
|
+
|
15
|
+
module Cxf
|
16
|
+
##
|
17
|
+
# == User context API
|
18
|
+
# User class contains functions that needs an API key and a session token as authentication
|
19
|
+
# == Usage example
|
20
|
+
# Initialize
|
21
|
+
# client = Cxf::User.new(cxf_url, api_key)
|
22
|
+
# Call any function
|
23
|
+
# client.get_contacts
|
24
|
+
# == Single resource options
|
25
|
+
# * +include+ - [String] include a relationship
|
26
|
+
# * +attributes+ - [Boolean] attach attributes to response
|
27
|
+
# * +tags+ - [Boolean] attach tags to response
|
28
|
+
# * +taxonomies+ - [Boolean] attach categories to response
|
29
|
+
# == Resource collections options
|
30
|
+
# * +search+ - [String] filter by a search word
|
31
|
+
# * +scopes+ - [String] filter by a scope
|
32
|
+
# * +filters+ - [String] filter by where clauses
|
33
|
+
# * +jfilters+ - [String] filter using complex condition objects (this filter use mongo queries)
|
34
|
+
# * +afilters+ - [String] filter using complex condition objects (this filter use postgresql queries)
|
35
|
+
# * +rfilters+ - [String] filter using complex condition objects from relationships
|
36
|
+
# * +dfilters+ - [String] filter using conditions based on dates
|
37
|
+
# * +fields+ - [String] indicates the columns that will be selected
|
38
|
+
# * +sort+ - [String] indicates the columns that will be selected
|
39
|
+
|
40
|
+
class User
|
41
|
+
include CRM
|
42
|
+
include Content
|
43
|
+
include Marketing
|
44
|
+
include Ecommerce
|
45
|
+
include Config
|
46
|
+
include Profile
|
47
|
+
include Helpers
|
48
|
+
include Contacts
|
49
|
+
include CxfHelper
|
50
|
+
include ThreadsHelper
|
51
|
+
|
52
|
+
attr_reader :client
|
53
|
+
|
54
|
+
def initialize(host, api_key, session_token = nil, refresh_token = nil, debug = false, timeouts = {})
|
55
|
+
@client = Cxf::Client.new(
|
56
|
+
host,
|
57
|
+
api_key,
|
58
|
+
'user',
|
59
|
+
session_token,
|
60
|
+
refresh_token,
|
61
|
+
nil,
|
62
|
+
nil,
|
63
|
+
debug,
|
64
|
+
timeouts
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
def login(email, password)
|
69
|
+
data = { email: email, password: password }
|
70
|
+
response = @client.raw('post', '/users/login', nil, data.to_json, '/api/v1', { no_content_type: true })
|
71
|
+
# @client.session_token = response['api_token'] if response.key? 'api_token'
|
72
|
+
if response.key? 'data' and response['data'].key? 'access_token'
|
73
|
+
@client.session_token = response['data']['access_token']
|
74
|
+
@client.refresh_token = response['data']['refresh_token']
|
75
|
+
end
|
76
|
+
response
|
77
|
+
end
|
78
|
+
|
79
|
+
def magic_link_login(token)
|
80
|
+
@client.raw('get', "/users/magic-link-login/#{token}", nil, nil, '/api/v1')
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# === Send magic link to user
|
85
|
+
def send_magic_link(email, redirect_url = '', life_time = 24)
|
86
|
+
data = {
|
87
|
+
email: email,
|
88
|
+
redirectUrl: redirect_url,
|
89
|
+
lifeTime: life_time
|
90
|
+
}
|
91
|
+
@client.raw('post', '/users/magic-link', nil, { data: data }, '/api/v1')
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_client
|
95
|
+
@client
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|