cxf 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70de20a783868a1123abc60270bc196593592593e7fa8c64df844190b80b534a
4
- data.tar.gz: b7d630be4143207435a458704e07225a38d655c9ad69a5dcd1e645591c54b70e
3
+ metadata.gz: 749f2ca43fc84fc4dfc3fe5248bb51aa5634bc01d7def8840078326f5098ff2c
4
+ data.tar.gz: de5b0d7063346d7389b282321b36d2af03b4a36ed24d6f6640ac6d08b0782446
5
5
  SHA512:
6
- metadata.gz: ac3d86ac3f771fe039a11d8b2e16665c00d018918014acec644c91f3dc24b5368270392ab45d09e588212b49527b59b1b5610fe4f3ded7036016ac7a7b485b04
7
- data.tar.gz: 681adb1f34a99cbee2c3bbef1bef98ce1bc6354afea6b9318a188faa4157b2d681993dce63f201cb242470923bcae315df18737168caa5753a06b6908f845ed0
6
+ metadata.gz: 482019323db909196ba74a904a0c3f23c7751d9221b0ecac27d95032eb63c6db98f133c4d6c87836d91c7254bb5a1bf036d58f63b15f5c992e9cb7d794847884
7
+ data.tar.gz: a53ec9b81c34d612008b23e146006bb224b4b2c731e51064e6d7ff3ab0074f3d8cb5abdbf100090c4c62dc50fb1ed14fccf12b00d313225d21f263114b18883d
data/lib/client.rb CHANGED
@@ -13,7 +13,7 @@ module Cxf
13
13
  include CxfHelper
14
14
 
15
15
  attr_reader :host, :mode, :api_key, :scope, :base_url
16
- attr_accessor :session_token, :refresh_token, :contact_token_id, :session_token_expires_at, :refresh_token_expires_at
16
+ attr_accessor :session_token, :refresh_token, :contact_token_id, :session_token_expires_at, :refresh_token_expires_at, :user_agent
17
17
 
18
18
  def initialize(
19
19
  host,
@@ -36,6 +36,7 @@ module Cxf
36
36
  @contact_token_id = contact_token_id
37
37
  @visit_id = visit_id
38
38
  @debug = debug
39
+ @user_agent = nil
39
40
 
40
41
  config = read_config_file('sdk') || {}
41
42
 
@@ -360,6 +361,7 @@ module Cxf
360
361
  h['ContactToken'] = @contact_token_id if @contact_token_id
361
362
  h['Visit-Id'] = @visit_id if @visit_id
362
363
  h['Authorization'] = "Bearer #{@session_token}" if @session_token
364
+ h['User-Agent'] = @user_agent if @user_agent
363
365
 
364
366
  if headers
365
367
  headers.each do |k, v|
data/lib/contact.rb CHANGED
@@ -37,6 +37,7 @@ module Cxf
37
37
  refresh_token = nil,
38
38
  contact_token_id = nil,
39
39
  debug = false,
40
+ user_agent = nil,
40
41
  timeouts = {}
41
42
  )
42
43
  @contact_v1_url = '/api/contact/v1'
@@ -51,6 +52,8 @@ module Cxf
51
52
  debug,
52
53
  timeouts
53
54
  )
55
+
56
+ @client.user_agent = user_agent
54
57
  end
55
58
 
56
59
  ### V1/CONTACTS ###
@@ -45,13 +45,15 @@ module CxfClients
45
45
  # Initialize cxf pub client, credentials taken from cxf_config.yml.erb file
46
46
  visit_id = cookies[:cxf_visit_id]
47
47
  contact_token_id = cookies[:cxf_contact_id]
48
+ user_agent = request.user_agent
48
49
 
49
50
  @cxf_pub = Cxf::Pub.new(
50
51
  @host,
51
52
  @api_key,
52
53
  contact_token_id,
53
54
  visit_id,
54
- @debug
55
+ @debug,
56
+ user_agent
55
57
  )
56
58
  end
57
59
 
@@ -63,13 +65,15 @@ module CxfClients
63
65
  contact_session_token = cookies[:cxf_contact_session_token]
64
66
  contact_refresh_token = cookies[:cxf_contact_refresh_token]
65
67
  contact_token_id = cookies[:cxf_contact_id]
68
+ user_agent = request.user_agent
66
69
  @cxf_contact = Cxf::Contact.new(
67
70
  @host,
68
71
  @api_key,
69
72
  contact_session_token,
70
73
  contact_refresh_token,
71
74
  contact_token_id,
72
- @debug
75
+ @debug,
76
+ user_agent
73
77
  )
74
78
  end
75
79
 
@@ -80,12 +84,14 @@ module CxfClients
80
84
  # Initialize cxf user client
81
85
  user_session_token = cookies[:cxf_user_session_token]
82
86
  user_refresh_token = cookies[:cxf_user_refresh_token]
87
+ user_agent = request.user_agent
83
88
  @cxf_user = Cxf::User.new(
84
89
  @host,
85
90
  @api_key,
86
91
  user_session_token,
87
92
  user_refresh_token,
88
- @debug
93
+ @debug,
94
+ user_agent
89
95
  )
90
96
  end
91
97
 
@@ -94,11 +100,14 @@ module CxfClients
94
100
  # Initialize the service account client
95
101
  def set_cxf_service_account_client
96
102
  # Initialize service account client
103
+ user_agent = request.user_agent
97
104
  @cxf_service_account = Cxf::User.new(
98
105
  @host,
99
106
  @api_key,
100
107
  @api_key,
101
- @debug
108
+ @api_key,
109
+ @debug,
110
+ user_agent
102
111
  )
103
112
  end
104
113
  end
@@ -25,8 +25,7 @@ module ProxyControllersMethods
25
25
  'host' => host,
26
26
  'ApiKey' => @api_key.to_s,
27
27
  'Content-Type' => 'application/json',
28
- 'Accept' => 'application/json',
29
- 'SDK' => 'true',
28
+ 'Accept' => 'application/json'
30
29
  }
31
30
 
32
31
  if %w[contact user].include? controller_type
data/lib/pub.rb CHANGED
@@ -87,6 +87,7 @@ module Cxf
87
87
  contact_token_id = nil,
88
88
  visit_id = nil,
89
89
  debug = false,
90
+ user_agent = nil,
90
91
  timeouts = {}
91
92
  )
92
93
  @client = Cxf::Client.new(
@@ -99,6 +100,8 @@ module Cxf
99
100
  debug,
100
101
  timeouts
101
102
  )
103
+
104
+ @client.user_agent = user_agent
102
105
  end
103
106
 
104
107
  ##
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+ module ContentBundles
3
+ # === Get content bundle.
4
+ # Get a collection of content bundle.
5
+ #
6
+ # ==== Parameters
7
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
8
+ # use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
9
+ #
10
+ # ==== First Example
11
+ # @data = @cxf_user.get_content_bundles
12
+ #
13
+ # ==== Second Example
14
+ # options = {
15
+ # fields: 'id, slug'
16
+ # }
17
+ # @data = @cxf_user.get_content_bundles(options)
18
+ #
19
+ # ==== Third Example
20
+ # options = {
21
+ # fields: 'id, slug'
22
+ # }
23
+ # @data = @cxf_user.get_content_bundles(options, true)
24
+ def get_content_bundles(options = nil, use_post = true)
25
+ get_query_results('/content/content-bundles', options, use_post)
26
+ end
27
+
28
+ # === Get content bundle.
29
+ # Get a content bundle info.
30
+ #
31
+ # ==== Parameters
32
+ # id:: (Integer) -- content bundle id.
33
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
34
+ #
35
+ # ==== First Example
36
+ # @data = @cxf_user.get_content_bundle(1)
37
+ #
38
+ # ==== Second Example
39
+ # options = {
40
+ # fields: 'id, slug'
41
+ # }
42
+ # @data = @cxf_user.get_content_bundle(1, options)
43
+ def get_content_bundle(id, options = nil)
44
+ @client.raw('get', "/content/content-bundles/#{id}", options)
45
+ end
46
+
47
+ # === Create content bundle.
48
+ # Create a content bundle with data.
49
+ #
50
+ # ==== Parameters
51
+ # data:: (Hash) -- Data to be submitted.
52
+ #
53
+ # ==== Example
54
+ # data = {
55
+ # user_id: 1,
56
+ # slug: "new-content bundle",
57
+ # content bundle_template_id: 1
58
+ # }
59
+ #
60
+ # options = { fields: 'id,slug' }
61
+ #
62
+ # @data = @cxf_user.create_content_bundle(data, options)
63
+ def create_content_bundle(data, options = nil)
64
+ @client.raw('post', '/content/content-bundles', options, data_transform(data))
65
+ end
66
+
67
+ # === Update content bundle.
68
+ # Update a content bundle info.
69
+ #
70
+ # ==== Parameters
71
+ # id:: (Integer) -- content bundle id.
72
+ # data:: (Hash) -- Data to be submitted.
73
+ #
74
+ # ==== Example
75
+ # data = {
76
+ # user_id: 1,
77
+ # slug: 'new-content bundle'
78
+ # }
79
+ # @data = @cxf_user.update_content_bundle(5, data)
80
+ def update_content_bundle(id, data, options = nil)
81
+ @client.raw('put', "/content/content-bundles/#{id}", options, data_transform(data))
82
+ end
83
+
84
+ # === Delete content bundle.
85
+ # Delete a content bundle.
86
+ #
87
+ # ==== Parameters
88
+ # id:: (Integer) -- content bundle id.
89
+ #
90
+ # ==== Example
91
+ # @data = @cxf_user.delete_content_bundle(6)
92
+ def delete_content_bundle(id)
93
+ @client.raw('delete', "/content/content-bundles/#{id}")
94
+ end
95
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+ module ContentPrints
3
+ # === Get content print.
4
+ # Get a collection of content print.
5
+ #
6
+ # ==== Parameters
7
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
8
+ # use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
9
+ #
10
+ # ==== First Example
11
+ # @data = @cxf_user.get_content_prints
12
+ #
13
+ # ==== Second Example
14
+ # options = {
15
+ # fields: 'id, slug'
16
+ # }
17
+ # @data = @cxf_user.get_content_prints(options)
18
+ #
19
+ # ==== Third Example
20
+ # options = {
21
+ # fields: 'id, slug'
22
+ # }
23
+ # @data = @cxf_user.get_content_prints(options, true)
24
+ def get_content_prints(options = nil, use_post = true)
25
+ get_query_results('/content/content-prints', options, use_post)
26
+ end
27
+
28
+ # === Get content print.
29
+ # Get a content print info.
30
+ #
31
+ # ==== Parameters
32
+ # id:: (Integer) -- content print id.
33
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
34
+ #
35
+ # ==== First Example
36
+ # @data = @cxf_user.get_content_print(1)
37
+ #
38
+ # ==== Second Example
39
+ # options = {
40
+ # fields: 'id, slug'
41
+ # }
42
+ # @data = @cxf_user.get_content_print(1, options)
43
+ def get_content_print(id, options = nil)
44
+ @client.raw('get', "/content/content-prints/#{id}", options)
45
+ end
46
+
47
+ # === Create content print.
48
+ # Create a content print with data.
49
+ #
50
+ # ==== Parameters
51
+ # data:: (Hash) -- Data to be submitted.
52
+ #
53
+ # ==== Example
54
+ # data = {
55
+ # user_id: 1,
56
+ # slug: "new-content print",
57
+ # content print_template_id: 1
58
+ # }
59
+ #
60
+ # options = { fields: 'id,slug' }
61
+ #
62
+ # @data = @cxf_user.create_content_print(data, options)
63
+ def create_content_print(data, options = nil)
64
+ @client.raw('post', '/content/content-prints', options, data_transform(data))
65
+ end
66
+
67
+ # === Update content print.
68
+ # Update a content print info.
69
+ #
70
+ # ==== Parameters
71
+ # id:: (Integer) -- content print id.
72
+ # data:: (Hash) -- Data to be submitted.
73
+ #
74
+ # ==== Example
75
+ # data = {
76
+ # user_id: 1,
77
+ # slug: 'new-content print'
78
+ # }
79
+ # @data = @cxf_user.update_content_print(5, data)
80
+ def update_content_print(id, data, options = nil)
81
+ @client.raw('put', "/content/content-prints/#{id}", options, data_transform(data))
82
+ end
83
+
84
+ # === Delete content print.
85
+ # Delete a content print.
86
+ #
87
+ # ==== Parameters
88
+ # id:: (Integer) -- content print id.
89
+ #
90
+ # ==== Example
91
+ # @data = @cxf_user.delete_content_print(6)
92
+ def delete_content_print(id)
93
+ @client.raw('delete', "/content/content-prints/#{id}")
94
+ end
95
+ end
data/lib/user.rb CHANGED
@@ -51,7 +51,7 @@ module Cxf
51
51
 
52
52
  attr_reader :client
53
53
 
54
- def initialize(host, api_key, session_token = nil, refresh_token = nil, debug = false, timeouts = {})
54
+ def initialize(host, api_key, session_token = nil, refresh_token = nil, debug = false, user_agent = nil, timeouts = {})
55
55
  @client = Cxf::Client.new(
56
56
  host,
57
57
  api_key,
@@ -61,8 +61,10 @@ module Cxf
61
61
  nil,
62
62
  nil,
63
63
  debug,
64
- timeouts
64
+ timeouts,
65
65
  )
66
+
67
+ @client.user_agent = user_agent
66
68
  end
67
69
 
68
70
  def login(email, password)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cxf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Gomez Garcia, Omar Mora, Luis Payan, Oscar Castillo, Fabian Garcia
@@ -174,6 +174,8 @@ files:
174
174
  - lib/user/content/block_templates.rb
175
175
  - lib/user/content/blocks.rb
176
176
  - lib/user/content/content.rb
177
+ - lib/user/content/content_bundles.rb
178
+ - lib/user/content/content_prints.rb
177
179
  - lib/user/content/instances.rb
178
180
  - lib/user/content/print_versions.rb
179
181
  - lib/user/content/stories.rb
@@ -220,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  - !ruby/object:Gem::Version
221
223
  version: '0'
222
224
  requirements: []
223
- rubygems_version: 3.5.16
225
+ rubygems_version: 3.5.18
224
226
  signing_key:
225
227
  specification_version: 4
226
- summary: Mints gem allows to connect your Rails App to MINTS.CLOUD
228
+ summary: CXF gem allows to connect your Rails App to the Customer Experience Framework.
227
229
  test_files: []