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,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StoryTemplates
|
4
|
+
##
|
5
|
+
# == Story Template
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get support data of story template.
|
9
|
+
# Get support data used in a story template.
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# id:: (Integer) -- Story template id.
|
13
|
+
#
|
14
|
+
# ==== Example
|
15
|
+
# @data = @cxf_user.get_story_template_support_data(1)
|
16
|
+
def get_story_template_support_data(id)
|
17
|
+
@client.raw('get', "/content/story-templates/support-data/stories/#{id}")
|
18
|
+
end
|
19
|
+
|
20
|
+
# === Get support data of story templates.
|
21
|
+
# Get support data used in story templates.
|
22
|
+
#
|
23
|
+
# ==== Example
|
24
|
+
# @data = @cxf_user.get_story_templates_support_data
|
25
|
+
def get_story_templates_support_data
|
26
|
+
@client.raw('get', '/content/story-templates/support-data')
|
27
|
+
end
|
28
|
+
|
29
|
+
# === Get story templates.
|
30
|
+
# Get a collection of story templates.
|
31
|
+
#
|
32
|
+
# ==== Parameters
|
33
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
34
|
+
#
|
35
|
+
# ==== First Example
|
36
|
+
# @data = @cxf_user.get_story_templates
|
37
|
+
#
|
38
|
+
# ==== Second Example
|
39
|
+
# options = {
|
40
|
+
# fields: 'id, title'
|
41
|
+
# }
|
42
|
+
# @data = @cxf_user.get_story_templates(options)
|
43
|
+
def get_story_templates(options = nil)
|
44
|
+
@client.raw('get', '/content/story-templates', options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# === Get story template.
|
48
|
+
# Get a story template info.
|
49
|
+
#
|
50
|
+
# ==== Parameters
|
51
|
+
# id:: (Integer) -- Story template id.
|
52
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
53
|
+
#
|
54
|
+
# ==== First Example
|
55
|
+
# @data = @cxf_user.get_story_template(2)
|
56
|
+
#
|
57
|
+
# ==== Second Example
|
58
|
+
# options = {
|
59
|
+
# fields: 'title'
|
60
|
+
# }
|
61
|
+
# @data = @cxf_user.get_story_template(1, options)
|
62
|
+
def get_story_template(id, options = nil)
|
63
|
+
@client.raw('get', "/content/story-templates/#{id}", options)
|
64
|
+
end
|
65
|
+
|
66
|
+
# === Create story template.
|
67
|
+
# Create a story template with data.
|
68
|
+
#
|
69
|
+
# ==== Parameters
|
70
|
+
# data:: (Hash) -- Data to be submitted.
|
71
|
+
#
|
72
|
+
# ==== Example
|
73
|
+
# data = {
|
74
|
+
# title: 'New Story Template',
|
75
|
+
# slug: 'new-story-template-slug'
|
76
|
+
# }
|
77
|
+
# @data = @cxf_user.create_story_template(data)
|
78
|
+
def create_story_template(data, options = nil)
|
79
|
+
@client.raw('post', '/content/story-templates', options, data_transform(data))
|
80
|
+
end
|
81
|
+
|
82
|
+
# === Update story template.
|
83
|
+
# Update a story template info.
|
84
|
+
#
|
85
|
+
# ==== Parameters
|
86
|
+
# id:: (Integer) -- Story template id.
|
87
|
+
# data:: (Hash) -- Data to be submitted.
|
88
|
+
#
|
89
|
+
# ==== Example
|
90
|
+
# data = {
|
91
|
+
# title: 'New Story Template Modified'
|
92
|
+
# }
|
93
|
+
# @data = @cxf_user.update_story_template(3, data)
|
94
|
+
def update_story_template(id, data)
|
95
|
+
@client.raw('put', "/content/story-templates/#{id}", nil, data_transform(data))
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Templates
|
4
|
+
# === Get templates.
|
5
|
+
# Get a collection of templates.
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
9
|
+
#
|
10
|
+
# ==== First Example
|
11
|
+
# @data = @cxf_user.get_templates
|
12
|
+
#
|
13
|
+
# ==== Second Example
|
14
|
+
# options = {
|
15
|
+
# fields: 'id, title'
|
16
|
+
# }
|
17
|
+
# @data = @cxf_user.get_templates(options)
|
18
|
+
def get_templates(options = nil)
|
19
|
+
@client.raw('get', '/content/templates', options)
|
20
|
+
end
|
21
|
+
|
22
|
+
# === Get template.
|
23
|
+
# Get a template info.
|
24
|
+
#
|
25
|
+
# ==== Parameters
|
26
|
+
# id:: (Integer) -- template id.
|
27
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
28
|
+
#
|
29
|
+
# ==== First Example
|
30
|
+
# @data = @cxf_user.get_template(2)
|
31
|
+
#
|
32
|
+
# ==== Second Example
|
33
|
+
# options = {
|
34
|
+
# fields: 'title'
|
35
|
+
# }
|
36
|
+
# @data = @cxf_user.get_template(1, options)
|
37
|
+
def get_template(id, options = nil)
|
38
|
+
@client.raw('get', "/content/templates/#{id}", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# === Create template.
|
42
|
+
# Create a template with data.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# data:: (Hash) -- Data to be submitted.
|
46
|
+
#
|
47
|
+
# ==== Example
|
48
|
+
# data = {
|
49
|
+
# title: 'New Template',
|
50
|
+
# slug: 'new/template-slug'
|
51
|
+
# }
|
52
|
+
# @data = @cxf_user.create_template(data)
|
53
|
+
def create_template(data, options = nil)
|
54
|
+
@client.raw('post', '/content/templates', options, data_transform(data))
|
55
|
+
end
|
56
|
+
|
57
|
+
# === Update template.
|
58
|
+
# Update a template info.
|
59
|
+
#
|
60
|
+
# ==== Parameters
|
61
|
+
# id:: (Integer) -- template id.
|
62
|
+
# data:: (Hash) -- Data to be submitted.
|
63
|
+
#
|
64
|
+
# ==== Example
|
65
|
+
# data = {
|
66
|
+
# title: 'New Template Modified'
|
67
|
+
# }
|
68
|
+
# @data = @cxf_user.update_template(3, data)
|
69
|
+
def update_template(id, data)
|
70
|
+
@client.raw('put', "/content/templates/#{id}", nil, data_transform(data))
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Companies
|
4
|
+
##
|
5
|
+
# == Companies
|
6
|
+
#
|
7
|
+
|
8
|
+
##
|
9
|
+
# === Get companies support data.
|
10
|
+
# Get support data of companies.
|
11
|
+
#
|
12
|
+
# ==== Example
|
13
|
+
# @data = @cxf_user.get_companies_support_data
|
14
|
+
def get_companies_support_data
|
15
|
+
@client.raw('get', '/crm/companies/support-data')
|
16
|
+
end
|
17
|
+
|
18
|
+
# === Get companies.
|
19
|
+
# Get a collection of companies.
|
20
|
+
#
|
21
|
+
# ==== Parameters
|
22
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
23
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
24
|
+
#
|
25
|
+
# ==== First Example
|
26
|
+
# @data = @cxf_user.get_companies
|
27
|
+
#
|
28
|
+
# ==== Second Example
|
29
|
+
# options = { fields: 'id, title', sort: '-id' }
|
30
|
+
# @data = @cxf_user.get_companies(options)
|
31
|
+
#
|
32
|
+
# ==== Third Example
|
33
|
+
# options = { fields: 'id, title', sort: '-id' }
|
34
|
+
# @data = @cxf_user.get_companies(options, false)
|
35
|
+
def get_companies(options = nil, use_post = true)
|
36
|
+
get_query_results('/crm/companies', options, use_post)
|
37
|
+
end
|
38
|
+
|
39
|
+
# === Get company.
|
40
|
+
# Get a company info.
|
41
|
+
#
|
42
|
+
# ==== Parameters
|
43
|
+
# id:: (Integer) -- Company id.
|
44
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
45
|
+
#
|
46
|
+
# ==== First Example
|
47
|
+
# @data = @cxf_user.get_company(21)
|
48
|
+
#
|
49
|
+
# ==== Second Example
|
50
|
+
# options = { fields: 'id, title' }
|
51
|
+
# @data = @cxf_user.get_company(21, options)
|
52
|
+
def get_company(id, options = nil)
|
53
|
+
@client.raw('get', "/crm/companies/#{id}", options)
|
54
|
+
end
|
55
|
+
|
56
|
+
# === Create company.
|
57
|
+
# Create a company with data.
|
58
|
+
#
|
59
|
+
# ==== Parameters
|
60
|
+
# data:: (Hash) -- Data to be submitted.
|
61
|
+
#
|
62
|
+
# ==== Example
|
63
|
+
# data = {
|
64
|
+
# title: 'Company Title',
|
65
|
+
# alias: 'Alias',
|
66
|
+
# website: 'www.company.example.com',
|
67
|
+
# street1: 'Company St',
|
68
|
+
# city: 'Company City',
|
69
|
+
# region: 'Company Region',
|
70
|
+
# postal_code: '12345',
|
71
|
+
# country_id: 144,
|
72
|
+
# tax_identifier: nil
|
73
|
+
# }
|
74
|
+
# @data = @cxf_user.create_company(data)
|
75
|
+
def create_company(data, options = nil)
|
76
|
+
@client.raw('post', '/crm/companies/', options, data_transform(data))
|
77
|
+
end
|
78
|
+
|
79
|
+
# === Update company.
|
80
|
+
# Update a company info.
|
81
|
+
#
|
82
|
+
# ==== Parameters
|
83
|
+
# id:: (Integer) -- Company id.
|
84
|
+
# data:: (Hash) -- Data to be submitted.
|
85
|
+
#
|
86
|
+
# ==== Example
|
87
|
+
# data = {
|
88
|
+
# title: 'Company Title Modified'
|
89
|
+
# }
|
90
|
+
# @data = @cxf_user.update_company(23, data)
|
91
|
+
def update_company(id, data, options = nil)
|
92
|
+
@client.raw('put', "/crm/companies/#{id}", options, data_transform(data))
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# == Companies Bulk Actions
|
97
|
+
#
|
98
|
+
|
99
|
+
# === Delete Companies.
|
100
|
+
# Delete a group of companies.
|
101
|
+
#
|
102
|
+
# ==== Parameters
|
103
|
+
# data:: (Hash) -- Data to be submitted.
|
104
|
+
#
|
105
|
+
# ==== Example
|
106
|
+
# data = { ids: %w[21 22] }
|
107
|
+
# @data = @cxf_user.delete_companies(data)
|
108
|
+
def delete_companies(data)
|
109
|
+
@client.raw('delete', '/crm/companies/delete', nil, data_transform(data))
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,294 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Contacts
|
4
|
+
##
|
5
|
+
# == Contacts
|
6
|
+
#
|
7
|
+
|
8
|
+
##
|
9
|
+
# === Get contacts support data.
|
10
|
+
#
|
11
|
+
# ==== Example
|
12
|
+
# @data = @cxf_user.get_contacts_support_data
|
13
|
+
def get_contacts_support_data
|
14
|
+
@client.raw('get', '/crm/contacts/support-data')
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# === Get online activity.
|
19
|
+
# Get online activity of a contact.
|
20
|
+
#
|
21
|
+
# ==== Parameters
|
22
|
+
# id:: (Integer) -- Contact id.
|
23
|
+
#
|
24
|
+
# ==== Example
|
25
|
+
# @data = @cxf_user.get_online_activity(5)
|
26
|
+
def get_online_activity(id)
|
27
|
+
@client.raw('get', "/crm/contacts/#{id}/online-activity")
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# === Get contacts.
|
32
|
+
# Get a collection of contacts.
|
33
|
+
#
|
34
|
+
# ==== Parameters
|
35
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
36
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
37
|
+
#
|
38
|
+
# ==== First Example
|
39
|
+
# @data = @cxf_user.get_contacts
|
40
|
+
#
|
41
|
+
# ==== Second Example
|
42
|
+
# options = {
|
43
|
+
# sort: 'id',
|
44
|
+
# 'fields[contacts]': 'id, email'
|
45
|
+
# }
|
46
|
+
# @data = @cxf_user.get_contacts(options)
|
47
|
+
#
|
48
|
+
# ==== Third Example
|
49
|
+
# options = {
|
50
|
+
# sort: 'id',
|
51
|
+
# 'fields[contacts]': 'id, email'
|
52
|
+
# }
|
53
|
+
# @data = @cxf_user.get_contacts(options, true)
|
54
|
+
def get_contacts(options = nil, use_post = true)
|
55
|
+
get_query_results('/crm/contacts', options, use_post)
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# === Get contact.
|
60
|
+
# Get a contact data.
|
61
|
+
#
|
62
|
+
# ==== Parameters
|
63
|
+
# id:: (Integer) -- Contact id.
|
64
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
65
|
+
#
|
66
|
+
# ==== First Example
|
67
|
+
# @data = @cxf_user.get_contact(5)
|
68
|
+
#
|
69
|
+
# ==== Second Example
|
70
|
+
# options = {
|
71
|
+
# sort: 'id',
|
72
|
+
# 'fields[contacts]': 'id, email'
|
73
|
+
# }
|
74
|
+
# @data = @cxf_user.get_contact(5, options)
|
75
|
+
def get_contact(id, options = nil)
|
76
|
+
@client.raw('get', "/crm/contacts/#{id}", options)
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# === Create contact.
|
81
|
+
# Create a contact with data.
|
82
|
+
#
|
83
|
+
# ==== Parameters
|
84
|
+
# data:: (Hash) -- Data to be submitted.
|
85
|
+
#
|
86
|
+
# ==== Example
|
87
|
+
# data = {
|
88
|
+
# email: 'email@example.com',
|
89
|
+
# given_name: 'Given Name',
|
90
|
+
# last_name: 'Last Name',
|
91
|
+
# password: '123456'
|
92
|
+
# }
|
93
|
+
# @data = @cxf_user.create_contact(data)
|
94
|
+
def create_contact(data, options = nil)
|
95
|
+
@client.raw('post', '/crm/contacts', options, data_transform(data))
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# === Update contact.
|
100
|
+
# Update contact data.
|
101
|
+
#
|
102
|
+
# ==== Parameters
|
103
|
+
# id:: (Integer) -- Contact id.
|
104
|
+
# data:: (Hash) -- Data to be submitted.
|
105
|
+
#
|
106
|
+
# ==== Example
|
107
|
+
# data = {
|
108
|
+
# email: 'email_modified@example.com',
|
109
|
+
# company_id: 3
|
110
|
+
# }
|
111
|
+
# @data = @cxf_user.update_contact(65, data)
|
112
|
+
def update_contact(id, data, options = nil)
|
113
|
+
@client.raw('put', "/crm/contacts/#{id}", options, data_transform(data))
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# === Get contact deals.
|
118
|
+
# Get a collection of deals of a contact.
|
119
|
+
#
|
120
|
+
# ==== Parameters
|
121
|
+
# contact_id:: (Integer) -- Contact id.
|
122
|
+
#
|
123
|
+
# ==== Example
|
124
|
+
# @data = @cxf_user.get_contact_deal(5)
|
125
|
+
def get_contact_deal(contact_id)
|
126
|
+
@client.raw('get', "/crm/contacts/#{contact_id}/deals")
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# === Create contact deal.
|
131
|
+
# Create a contact deal with data.
|
132
|
+
#
|
133
|
+
# ==== Parameters
|
134
|
+
# contact_id:: (Integer) -- Contact id.
|
135
|
+
# data:: (Hash) -- Data to be submitted.
|
136
|
+
#
|
137
|
+
# ==== Example
|
138
|
+
# data = { deal_id: 6 }
|
139
|
+
# @data = @cxf_user.create_contact_deal(5, data.to_json)
|
140
|
+
def create_contact_deal(contact_id, data)
|
141
|
+
@client.raw('post', "/crm/contacts/#{contact_id}/deals", nil, data)
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# === Delete contact deal.
|
146
|
+
# Delete a contact deal with data.
|
147
|
+
#
|
148
|
+
# ==== Parameters
|
149
|
+
# contact_id:: (Integer) -- Contact id.
|
150
|
+
# deal_id:: (Integer) -- Deal id.
|
151
|
+
#
|
152
|
+
# ==== Example
|
153
|
+
# @data = @cxf_user.delete_contact_deal(5, 100)
|
154
|
+
def delete_contact_deal(contact_id, deal_id)
|
155
|
+
@client.raw('delete', "/crm/contacts/#{contact_id}/deals/#{deal_id}")
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# === Get contact user.
|
160
|
+
# Get user data of a contact.
|
161
|
+
#
|
162
|
+
# ==== Parameters
|
163
|
+
# TODO: Replace Resource collection options url
|
164
|
+
# contact_id:: (Integer) -- Contact id.
|
165
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
166
|
+
#
|
167
|
+
# ==== Example
|
168
|
+
# @data = @cxf_user.get_contact_user(66)
|
169
|
+
def get_contact_user(contact_id)
|
170
|
+
@client.raw('get', "/crm/contacts/#{contact_id}/users")
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# === Create contact user.
|
175
|
+
# Relate a contact with an user.
|
176
|
+
#
|
177
|
+
# ==== Parameters
|
178
|
+
# contact_id:: (Integer) -- Contact id.
|
179
|
+
# data:: (Hash) -- Data to be submitted.
|
180
|
+
#
|
181
|
+
# ==== Example
|
182
|
+
# data = { user_id: 9 }
|
183
|
+
# @data = @cxf_user.create_contact_user(66, data.to_json)
|
184
|
+
def create_contact_user(contact_id, data)
|
185
|
+
@client.raw('post', "/crm/contacts/#{contact_id}/users", nil, data)
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# === Delete contact user.
|
190
|
+
# Delete a relationship between a contact and an user.
|
191
|
+
#
|
192
|
+
# ==== Parameters
|
193
|
+
# contact_id:: (Integer) -- Contact id.
|
194
|
+
# id:: (Integer) -- User id.
|
195
|
+
#
|
196
|
+
# ==== Example
|
197
|
+
# @data = @cxf_user.delete_contact_user(153, 9)
|
198
|
+
def delete_contact_user(contact_id, id)
|
199
|
+
@client.raw('delete', "/crm/contacts/#{contact_id}/users/#{id}")
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
# === Get contact segments.
|
204
|
+
# Get segments of a contact.
|
205
|
+
#
|
206
|
+
# ==== Parameters
|
207
|
+
# contact_id:: (Integer) -- Contact id.
|
208
|
+
#
|
209
|
+
# ==== Example
|
210
|
+
# @data = @cxf_user.get_contact_segments(1)
|
211
|
+
def get_contact_segments(contact_id)
|
212
|
+
@client.raw('get', "/crm/contacts/#{contact_id}/segments")
|
213
|
+
end
|
214
|
+
|
215
|
+
##
|
216
|
+
# === Get contact submissions.
|
217
|
+
# Get submissions of a contact.
|
218
|
+
#
|
219
|
+
# ==== Parameters
|
220
|
+
# contact_id:: (Integer) -- Contact id.
|
221
|
+
#
|
222
|
+
# ==== Example
|
223
|
+
# @data = @cxf_user.get_contact_submissions(146)
|
224
|
+
def get_contact_submissions(contact_id)
|
225
|
+
@client.raw('get', "/crm/contacts/#{contact_id}/submissions")
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# === Get contact tags.
|
230
|
+
# Get tags of a contact.
|
231
|
+
#
|
232
|
+
# ==== Parameters
|
233
|
+
# contact_id:: (Integer) -- Contact id.
|
234
|
+
#
|
235
|
+
# ==== Example
|
236
|
+
# @data = @cxf_user.get_contact_tags(1)
|
237
|
+
def get_contact_tags(contact_id)
|
238
|
+
@client.raw('get', "/crm/contacts/#{contact_id}/tags")
|
239
|
+
end
|
240
|
+
|
241
|
+
##
|
242
|
+
# === Create contact merge.
|
243
|
+
# Merge contacts.
|
244
|
+
#
|
245
|
+
# ==== Parameters
|
246
|
+
# id:: (Integer) -- Contact id.
|
247
|
+
# data:: (Hash) -- Data to be submitted. It contains ids to be merged.
|
248
|
+
#
|
249
|
+
# ==== Example
|
250
|
+
# data = { mergeContactIds: [152] }
|
251
|
+
# @data = @cxf_user.merge_contacts(151, data)
|
252
|
+
def merge_contacts(id, data)
|
253
|
+
@client.raw('post', "/crm/contacts/#{id}/merge", nil, data_transform(data))
|
254
|
+
end
|
255
|
+
|
256
|
+
##
|
257
|
+
# === Send magic links.
|
258
|
+
# Send magic links to contacts.
|
259
|
+
#
|
260
|
+
# ==== Parameters
|
261
|
+
# data:: (Hash) -- Data to be submitted.
|
262
|
+
#
|
263
|
+
# ==== Example
|
264
|
+
# data = {
|
265
|
+
# contacts: %w[email_1@example.com email_2@example.com email_3@example.com],
|
266
|
+
# templateId: 2,
|
267
|
+
# redirectUrl: "",
|
268
|
+
# lifeTime: 1440,
|
269
|
+
# maxVisits: 3
|
270
|
+
# }
|
271
|
+
# @data = @cxf_user.send_magic_links(data)
|
272
|
+
def send_magic_links(data)
|
273
|
+
@client.raw('post', '/crm/contacts/send-magic-link', nil, data_transform(data))
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
# == Contacts Bulk Actions
|
278
|
+
#
|
279
|
+
|
280
|
+
##
|
281
|
+
# === Delete contacts.
|
282
|
+
# Delete different contacts.
|
283
|
+
#
|
284
|
+
# ==== Parameters
|
285
|
+
# data:: (Hash) -- Data to be submitted.
|
286
|
+
#
|
287
|
+
# ==== Example
|
288
|
+
# data = { ids": %w[67 68 69] }
|
289
|
+
# @data = @cxf_user.delete_contacts(data)
|
290
|
+
def delete_contacts(data)
|
291
|
+
# TODO: ContactController.delete need a success output
|
292
|
+
@client.raw('delete', '/crm/contacts/delete', nil, data_transform(data))
|
293
|
+
end
|
294
|
+
end
|
data/lib/user/crm/crm.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './item_prices'
|
4
|
+
require_relative './locations'
|
5
|
+
require_relative './price_lists'
|
6
|
+
require_relative './product_templates'
|
7
|
+
require_relative './product_variations'
|
8
|
+
require_relative './products'
|
9
|
+
require_relative './product_versions'
|
10
|
+
require_relative './skus'
|
11
|
+
require_relative './taxes'
|
12
|
+
require_relative './variant_options'
|
13
|
+
require_relative './variant_values'
|
14
|
+
require_relative './vouchers'
|
15
|
+
|
16
|
+
module Ecommerce
|
17
|
+
include ItemPrices
|
18
|
+
include Locations
|
19
|
+
include PriceList
|
20
|
+
include ProductTemplates
|
21
|
+
include ProductVariations
|
22
|
+
include Products
|
23
|
+
include ProductVersions
|
24
|
+
include Skus
|
25
|
+
include Taxes
|
26
|
+
include VariantOptions
|
27
|
+
include VariantValues
|
28
|
+
include Vouchers
|
29
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ItemPrices
|
4
|
+
##
|
5
|
+
# == Item Prices
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get item prices.
|
9
|
+
# Get a collection of item prices.
|
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_item_prices
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = { fields: 'price_cents' }
|
19
|
+
# @data = @cxf_user.get_item_prices(options)
|
20
|
+
def get_item_prices(options = nil)
|
21
|
+
@client.raw('get', '/ecommerce/item-prices', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# === Get item price.
|
25
|
+
# Get a item price info.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# id:: (Integer) -- Item price 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_item_price(1)
|
33
|
+
#
|
34
|
+
# ==== Second Example
|
35
|
+
# options = { fields: 'price_cents' }
|
36
|
+
# @data = @cxf_user.get_item_price(1, options)
|
37
|
+
def get_item_price(id, options = nil)
|
38
|
+
@client.raw('get', "/ecommerce/item-prices/#{id}", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# === Create item price.
|
42
|
+
# Create a item price with data.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# data:: (Hash) -- Data to be submitted.
|
46
|
+
#
|
47
|
+
# ==== Example
|
48
|
+
# data = {
|
49
|
+
# price_list: [
|
50
|
+
# { id: 1 },
|
51
|
+
# { id: 2 }
|
52
|
+
# ],
|
53
|
+
# price_list_id: 1,
|
54
|
+
# title: 'New Item Price'
|
55
|
+
# }
|
56
|
+
# @data = @cxf_user.create_item_price(data)
|
57
|
+
def create_item_price(data)
|
58
|
+
# FIXME: Api send sku_id as null and DB doesnt allow that.
|
59
|
+
@client.raw('post', '/ecommerce/item-prices', nil, data_transform(data))
|
60
|
+
end
|
61
|
+
|
62
|
+
# === Update item price.
|
63
|
+
# Update a item price info.
|
64
|
+
#
|
65
|
+
# ==== Parameters
|
66
|
+
# id:: (Integer) -- Order item price id.
|
67
|
+
# data:: (Hash) -- Data to be submitted.
|
68
|
+
#
|
69
|
+
# ==== Example
|
70
|
+
# data = {
|
71
|
+
# price: 12345
|
72
|
+
# }
|
73
|
+
# @data = @cxf_user.update_item_price(1, data)
|
74
|
+
def update_item_price(id, data)
|
75
|
+
@client.raw('put', "/ecommerce/item-prices/#{id}", nil, data_transform(data))
|
76
|
+
end
|
77
|
+
|
78
|
+
# === Delete item price.
|
79
|
+
# Delete a item price.
|
80
|
+
#
|
81
|
+
# ==== Parameters
|
82
|
+
# id:: (Integer) -- Item price id.
|
83
|
+
#
|
84
|
+
# ==== Example
|
85
|
+
# @data = @cxf_user.delete_item_price(803)
|
86
|
+
def delete_item_price(id)
|
87
|
+
@client.raw('delete', "/ecommerce/item-prices/#{id}")
|
88
|
+
end
|
89
|
+
end
|