oeh-client 0.3.4 → 1.1.0

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
  SHA1:
3
- metadata.gz: 7c1becb519a0be3ffdb8cd3f9845292c91a826cd
4
- data.tar.gz: 9fb57347bea09ff50996e298b46b7a0638a99d37
3
+ metadata.gz: 8d5b67302ac27817b6fe0c224cff58885a9b1e9b
4
+ data.tar.gz: ddbcca89c7b88e49e4a328275dfdcd2a5689f0bd
5
5
  SHA512:
6
- metadata.gz: 3af352f19d4faeaaaac88662428ccd2d36ea85f54bd1e8640cac522ebe03a6ea7dfa40686e1c5037ee4091bf4def9cabef8ce59d7696232fdfa23b2465707779
7
- data.tar.gz: 47786c288281f258a234f4b31a9f38f8f2d0ff2f8e61f972b6c58c8c24268a9b10fb4e5b080df6560eec8017a5fe3c9cbfa48fae805ad89d99e16ed9a6280b03
6
+ metadata.gz: 0489e56ed2006b20e92bc242a7adccb3f5503391e0096926e11e0e45af79a14f7879559024b3a135b8fd1afdb2f799f140fee26bbd4e97c48f0077f6025370c4
7
+ data.tar.gz: 5d4b72a0ab88bca1e7c9be7db538afb42954c953db0f30135f4868d67795471bc296bfa5375c9c8b1e7c193bf06216a0084efd0b39120fa01334fa750972ad75
data/README.md CHANGED
@@ -57,7 +57,7 @@ As needed, you can register multiple spaces for the same instances to support in
57
57
  Interactions are the key elements of the customer experience. Interactions represent the back-and-forth between the customer and your organization. You can post an interaction simply:
58
58
 
59
59
  ```ruby
60
- customer_interaction = OEHClient::Interaction::Interaction.post("YOUR_TARGET_SITE_KEY", "TOUCHPOINT_INTERACTION_URI")
60
+ customer_interaction = OEHClient::Realtime::Interaction.post("YOUR_TARGET_SITE_KEY", "TOUCHPOINT_INTERACTION_URI")
61
61
  ```
62
62
  The post method will return an instance of the OE
63
63
 
@@ -18,7 +18,7 @@ class OEHClient::Config::Space
18
18
  :shared_secret, # The shared secret value provided in the ONE SETTINGS interface
19
19
  :username, # The fully-qualified username configured for access to the space
20
20
  :meta_password, # The password needed to access meta-data from the OEH server
21
- :cookies # The cookies returned from an OEH API request
21
+ :workspace # The ONE workspace related to the current space
22
22
 
23
23
  ###
24
24
  ### ------------- Class Methods
@@ -103,36 +103,12 @@ class OEHClient::Config::Space
103
103
  "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}#{OEHClient::Helper::Request::THUNDERHEAD_DOMAIN}/one/logout"
104
104
  end
105
105
 
106
- # logon to the OEH thinstance with the existing credentials
107
- def login()
108
- # post the login request
109
- response = OEHClient.post(login_url, nil, :payload => meta_credentials)
110
- # store the cookies if they are returned in the response
111
- @cookies = response[:cookies] if (response.has_key?(:cookies))
112
- end
113
-
114
- # logout of the OEH thinstance and remove the current cookie references
115
- def logout()
116
- # construct a header object, merging cookies (if present) wit the default JSON header
117
- header = Hash.new
118
- header.merge!(:cookies => @cookies) unless (@cookies.blank?)
119
- header.merge!(OEHClient::Helper::Request.default_JSON_header)
120
- # post the logout request
121
- OEHClient.post(logout_url, nil, :header => header)
122
- # remove the cookies if the logout is posted successfully
123
- @cookies = nil
124
- end
125
-
126
106
  # retrieve the workspace meta-data object from the thinstance in realtime
127
- def workspace()
128
- # if the cookies are currently NIL then login using the existing credentials
129
- login() if (@cookies.nil?)
130
- # get the workspace object using the site key, the host value, and the exisitng cookies
131
- workspace_instance = OEHClient::Meta::Workspace.fetch(@site_key, @host, :cookies => @cookies)
132
- # assign the current space to the workspace instance
133
- workspace_instance.space = self
134
- # return the workspace instance object
135
- workspace_instance
107
+ def get_workspace()
108
+ # create an active session with ONE
109
+ workspace = OEHClient::Meta::Session.attach(self).workspace(site_key) if (workspace.nil?)
110
+ # return the active workspace object
111
+ workspace
136
112
  end
137
113
 
138
114
  end
@@ -1,44 +1,88 @@
1
- class OEHClient::Meta::Entity
1
+ module OEHClient::Meta::Entity
2
2
 
3
3
  ###
4
4
  ### ------------- Constants
5
5
  ###
6
6
 
7
- ###
8
- ### ------------- Attributes
9
- ###
10
- attr_accessor :space # The configured OEHClient::Config::Space object that represents the OEH workspace
7
+ ONE_PARAM_DATA = "data"
8
+ ONE_PARAM_SUCCESS = "success"
9
+ ONE_PARAM_ID = "id"
10
+ ONE_PARAM_NAME = "name"
11
+ ONE_PARAM_CREATED_ON = "createdDate"
12
+ ONE_PARAM_CREATED_BY = "createdBy"
11
13
 
14
+ ONE_PARAM_ITEMS = "items"
12
15
 
13
16
  ###
14
- ### ------------- Class Methods
17
+ ### ------------- Class Attributes
15
18
  ###
16
19
 
17
- def self.create()
18
- end # def self.create
19
-
20
- def self.find(*args)
20
+ def entity_uri_stem=(uri_stem)
21
+ @entity_stem = uri_stem
22
+ end
21
23
 
22
- options = args.extract_options!
24
+ def entity_uri_stem
25
+ @entity_stem
26
+ end
23
27
 
24
- case args.first
25
- when :first then find_initial(options)
26
- when :last then find_last(options)
27
- when :all then find_every(options)
28
- else find_from_id(args, options)
29
- end
28
+ def session=(session_instance)
29
+ @session = session_instance
30
+ end
30
31
 
32
+ def session
33
+ @session
31
34
  end
32
35
 
33
- def self.fetch(space, entity_type)
36
+ ###
37
+ ### ------------- Helper Class Methods
38
+ ###
34
39
 
35
- url = "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{space.host}#{OEHClient::Helper::Request::THUNDERHEAD_DOMAIN}/one/services/api/#{entity_type.downcase.pluralize}"
40
+ def create()
41
+ end # def self.create
36
42
 
37
- header = (!space.cookies.nil? ? {:cookies => space.cookies}.merge!(OEHClient::Helper::Request.default_JSON_header()) : OEHClient::Helper::Request.default_JSON_header())
43
+ def find_by_name(active_session, name, **args)
44
+ get(active_session, {:name => ONE_PARAM_NAME, :value => name}, args)
45
+ end
38
46
 
39
- response = OEHClient.get(url, nil, :header => header)
47
+ ###
48
+ ### ------------- Core Class Methods
49
+ ###
40
50
 
41
- end
51
+ def get_collection(active_session, **args)
52
+ # store the active session object for future use
53
+ self.session = active_session if (session.nil?)
54
+ # get the list of args
55
+ entity_uri = (args.has_key?(:space)) ? "workspaces/#{args[:space]}/#{entity_uri_stem}" : "#{entity_uri_stem}"
56
+ # construct the URL for retrieving the entity
57
+ url = "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{self.session.space.host}#{OEHClient::Helper::Request::THUNDERHEAD_DOMAIN}/one/services/api/#{entity_uri}"
58
+ # set the header information
59
+ header = (!self.session.cookies.nil? ? {:cookies => self.session.cookies}.merge!(OEHClient::Helper::Request.default_JSON_header()) : OEHClient::Helper::Request.default_JSON_header())
60
+ # construct the request params using the header and params (if passed)
61
+ request_params = {:header => header}
62
+ request_params.merge!({:params => args[:params]}) if (args.has_key?(:params))
63
+ # GET the data
64
+ collection_response = OEHClient.get(url, nil, request_params)
65
+ # return the data object for valid requests or a blank array otherwise
66
+ ((collection_response.has_key?(:body) && collection_response[:body][ONE_PARAM_SUCCESS]) ? (collection_response[:body][ONE_PARAM_DATA].is_a?(Hash) ? collection_response[:body][ONE_PARAM_DATA][ONE_PARAM_ITEMS] : collection_response[:body][ONE_PARAM_DATA]) : [] )
67
+ end # def get_collection
68
+
69
+ def get(active_session, attribute_nvp, **args)
70
+ # store the active session object for future use
71
+ session = active_session if (session.nil?)
72
+ # initialize the entity instance as a blank hash
73
+ entity_instance = Hash.new
74
+ # Get the collection of objects requested
75
+ get_collection(session, **args).each do | collection_instance |
76
+ # find the matching entry and assign the entity instance
77
+ entity_instance = collection_instance if (collection_instance[attribute_nvp[:name]].casecmp(attribute_nvp[:value]) == 0)
78
+ end # Each OEHClient::Meta::Entity.get_collection
79
+ # return the copy of the entity instance data
80
+ entity_instance
81
+ end # def get
82
+
83
+ ###
84
+ ### ------------- Instance Attributes
85
+ ###
42
86
 
43
87
  ###
44
88
  ### ------------- Instance Methods
@@ -50,21 +94,4 @@ class OEHClient::Meta::Entity
50
94
 
51
95
  protected
52
96
 
53
-
54
- def self.find_initial(options)
55
-
56
- end
57
-
58
- def self.find_last(options)
59
-
60
- end
61
-
62
- def self_find_every(options)
63
- end
64
-
65
- def self.find_from_id(args, options)
66
-
67
- end
68
-
69
-
70
97
  end
@@ -0,0 +1,14 @@
1
+ class OEHClient::Meta::Interaction < OEHClient::Data::Node
2
+ include OEHClient::Meta::WorkspaceEntity
3
+
4
+ self.entity_uri_stem = "pageCfg/pages"
5
+
6
+
7
+ def self.create(workspace, data)
8
+ interaction_instance = OEHClient::Meta::Interaction.new(data)
9
+ interaction_instance.workspace = workspace
10
+
11
+ interaction_instance
12
+ end
13
+
14
+ end
@@ -0,0 +1,36 @@
1
+ class OEHClient::Meta::Session
2
+
3
+ attr_accessor :cookies, :space
4
+
5
+ def self.attach(space)
6
+ # post the login request
7
+ response = OEHClient.post(space.login_url, nil, :payload => space.meta_credentials)
8
+ # create a new session object
9
+ session_instance = OEHClient::Meta::Session.new()
10
+ # assign the space object
11
+ session_instance.space = space
12
+ # store the cookies if they are returned in the response
13
+ session_instance.cookies = response[:cookies] if (response.has_key?(:cookies))
14
+ # return the session instance
15
+ session_instance
16
+ end
17
+
18
+ def detach()
19
+ # construct a header object, merging cookies (if present) wit the default JSON header
20
+ header = Hash.new
21
+ header.merge!(:cookies => @cookies) unless (@cookies.blank?)
22
+ header.merge!(OEHClient::Helper::Request.default_JSON_header)
23
+ # post the logout request
24
+ OEHClient.post(@space.logout_url, nil, :header => header)
25
+ # remove the cookies if the logout is posted successfully
26
+ @cookies = nil
27
+ end
28
+
29
+ # retrieve the workspace meta-data object from the thinstance in realtime
30
+ def workspace(site_key)
31
+ # get the workspace object using the site key, the host value, and the exisitng cookies
32
+ OEHClient::Meta::Workspace.find_by_key(self, site_key)
33
+ end
34
+
35
+
36
+ end
@@ -0,0 +1,36 @@
1
+ class OEHClient::Meta::Touchpoint < OEHClient::Data::Node
2
+ include OEHClient::Meta::WorkspaceEntity
3
+
4
+ # tell the workspace entity module how to reference within ONE
5
+ self.entity_uri_stem = "touchpoints"
6
+
7
+ # create a new instance of the class using the data set and assig the workspace
8
+ def self.create(workspace, data)
9
+ # create from the past data structure
10
+ touchpoint_instance = OEHClient::Meta::Touchpoint.new(data)
11
+ # assign the local workspace object
12
+ touchpoint_instance.workspace = workspace
13
+ # return the instance
14
+ touchpoint_instance
15
+ end # self.create
16
+
17
+ # retrieve the full collection of touchpoints from the curent workspace
18
+ def interactions()
19
+ # initialize the collection array
20
+ interaction_collection = Array.new
21
+ # retrieve the collection from ONE using the workspace reference and current touchpoint
22
+ OEHClient::Meta::Interaction.get_collection(self.class.session, space: workspace.id, params: {:site => id}).each do | interaction_item |
23
+ # create the instance of the interaction and add it to the collection
24
+ interaction_collection << OEHClient::Meta::Interaction.create(workspace, interaction_item)
25
+ end
26
+ # return the collection to calling process
27
+ interaction_collection
28
+ end # end def interactions
29
+
30
+ # retrieve a single touchpoint from the current workspace based on the name
31
+ def interaction(interaction_name)
32
+ # create and return the instance of an interaction based on the name, current workspace, and current touchpoint
33
+ OEHClient::Meta::Interaction.create(workspace, OEHClient::Meta::Interaction.find_by_name(self.class.session, interaction_name, space: workspace.id, params: {:site => id}))
34
+ end # def interaction
35
+
36
+ end # class OEHClient::Meta::Touchpoint
@@ -1,82 +1,58 @@
1
- class OEHClient::Meta::Workspace
1
+ class OEHClient::Meta::Workspace < OEHClient::Data::Node
2
+ extend OEHClient::Meta::Entity
3
+
4
+ # set the ONE entity URI Stem for workspace requests
5
+ self.entity_uri_stem = "workspaces"
2
6
 
3
7
  ###
4
8
  ### ------------- Constants
5
9
  ###
6
10
 
7
- ONE_PARAM_DATA = "data"
8
- ONE_PARAM_NAME = "name"
9
- ONE_PARAM_SITE_KEY = "siteKey"
10
- ONE_PARAM_ID = "id"
11
- ONE_PARAM_CREATED_ON = "createdDate"
12
- ONE_PARAM_CREATED_BY = "createdBy"
13
- ONE_PARAM_CONTROL_GROUP = "controlGroup"
14
- ONE_PARAM_ADMIN_ROLE = "adminRole"
11
+ ONE_WORKSPACE_SITE_KEY = "siteKey"
12
+
15
13
 
16
14
  ###
17
15
  ### ------------- Attributes
18
16
  ###
19
- attr_accessor :name, # The name of the workspace
20
- :id, # The internal ID of the workspace
21
- :created_on, # The date and time the workspace was created
22
- :created_by, # The user that created the workspace
23
- :control_group, # The percentage of the control groupd setting
24
- :admin_role, # boolean value that determins if the current user is identified
25
- # as an admin of the workspace
26
- :space # The related OEHClient::Config::Space object
27
-
28
-
17
+
29
18
  ###
30
19
  ### ------------- Class Methods
31
20
  ###
32
21
 
33
- def self.create()
34
- end # def self.create
35
-
36
- def self.fetch(site_key, host, *args)
37
- # retrieved the passed options from the SPLAT
38
- options = (args.length > 0 ? args[0] : Hash.new)
22
+ def self.find_by_key(active_session, site_key, **args)
39
23
  # default the workspace instance NIL
40
24
  workspace_instance = nil
41
- # construnct the URL for getting the workspaces from the current thinstance
42
- url = "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{host}#{OEHClient::Helper::Request::THUNDERHEAD_DOMAIN}/one/services/api/workspaces"
43
- # construct a header using the space cookies or just with the default JSON header
44
- header = (options.has_key?(:cookies) ? {:cookies => options[:cookies]}.merge!(OEHClient::Helper::Request.default_JSON_header()) : OEHClient::Helper::Request.default_JSON_header())
45
25
  # get the list of workspaces from the thinstance
46
- response = OEHClient.get(url, nil, :header => header)
47
- # constinue only if we have a :body component of the resposne
48
- if (response.has_key?(:body))
49
- # for each fo the workspaces, grab the individual data
50
- response[:body][ONE_PARAM_DATA].each do | workspace_data |
51
- # look for workspace that maches the passed site key
52
- unless (workspace_data[ONE_PARAM_SITE_KEY].casecmp(site_key) == 0)
53
- # convert the the workspace instance into a NEW instance of the OEHClient::Meta::Workspace class
54
- workspace_instance = OEHClient::Meta::Workspace.new
55
- # map all the attributes of the workspace data to the new OEHClient::Meta::Workspace
56
- # object
57
- workspace_instance.name = workspace_data[ONE_PARAM_NAME]
58
- workspace_instance.id = workspace_data[ONE_PARAM_ID]
59
- workspace_instance.created_on = Time.at(workspace_data[ONE_PARAM_CREATED_ON]/1000)
60
- workspace_instance.created_by = workspace_data[ONE_PARAM_CREATED_BY][ONE_PARAM_NAME]
61
- workspace_instance.control_group = workspace_data[ONE_PARAM_CONTROL_GROUP]
62
- workspace_instance.admin_role = workspace_data[ONE_PARAM_ADMIN_ROLE]
63
- # break out of the look since we found our workspace data
64
- break
65
- end # unless
66
- end # do each data element
67
- end # if response has body
68
- # return the workspace instance
69
- workspace_instance
70
- end # def self.fetch
26
+ workspace_data = get(active_session, {:name => ONE_WORKSPACE_SITE_KEY, :value => site_key}, **args)
27
+ unless (workspace_data.blank?)
28
+ # convert the the workspace instance into a NEW instance of the OEHClient::Meta::Workspace instance
29
+ workspace_instance = OEHClient::Meta::Workspace.new(workspace_data)
30
+ # set the session object
31
+ # workspace_instance.session = session
32
+ # return the workspace instance
33
+ workspace_instance
34
+ end # unless workspace_data.blank?
35
+ end # def self.find_by_key
71
36
 
72
37
 
73
38
  ###
74
39
  ### ------------- Instance Methods
75
40
  ###
76
41
 
42
+ # retrieve the full collection of touchpoints from the curent workspace
77
43
  def touchpoints()
78
-
44
+ touchpoint_collection = Array.new
45
+ OEHClient::Meta::Touchpoint.get_collection(self.class.session, space: id).each do | touchpoint_item |
46
+ touchpoint_collection << OEHClient::Meta::Touchpoint.create(self, touchpoint_item)
47
+ end
48
+ touchpoint_collection
49
+ end
50
+
51
+ # retrieve a single touchpoint from the current workspace based on the name
52
+ def touchpoint(touchpoint_name)
53
+ OEHClient::Meta::Touchpoint.create(self, OEHClient::Meta::Touchpoint.find_by_name(self.class.session, touchpoint_name, space: id))
79
54
  end
80
55
 
81
56
 
57
+
82
58
  end
@@ -0,0 +1,13 @@
1
+ module OEHClient::Meta::WorkspaceEntity
2
+
3
+ def self.included base
4
+ base.send :include, InstanceMethods
5
+ base.send :extend, OEHClient::Meta::Entity
6
+ end
7
+
8
+ module InstanceMethods
9
+
10
+ attr_accessor :workspace
11
+ end
12
+
13
+ end
@@ -7,5 +7,8 @@ module OEHClient
7
7
  end
8
8
 
9
9
  require File.dirname(__FILE__) + '/meta/entity'
10
+ require File.dirname(__FILE__) + '/meta/workspace_entity'
11
+ require File.dirname(__FILE__) + '/meta/session'
10
12
  require File.dirname(__FILE__) + '/meta/workspace'
11
- #require File.dirname(__FILE__) + '/meta/touchpoint'
13
+ require File.dirname(__FILE__) + '/meta/touchpoint'
14
+ require File.dirname(__FILE__) + '/meta/interaction'
@@ -1,6 +1,6 @@
1
1
  require 'base64'
2
2
 
3
- class OEHClient::Interaction::Interaction
3
+ class OEHClient::Realtime::Interaction
4
4
 
5
5
  #
6
6
  # -------[ CONSTANTS ]
@@ -70,13 +70,13 @@ class OEHClient::Interaction::Interaction
70
70
 
71
71
 
72
72
  # create a new interaction using all attributes pass
73
- new_interaction = OEHClient::Interaction::Interaction.new(attributes)
73
+ new_interaction = OEHClient::Realtime::Interaction.new(attributes)
74
74
  # Send the interaction for processing and return the instance of the interaction class
75
75
  new_interaction.send(properties)
76
76
 
77
77
  end
78
78
 
79
- # class-level wrapper to create a new instance of the OEHClient::Interaction::Interaction class, call the
79
+ # class-level wrapper to create a new instance of the OEHClient::Realtime::Interaction class, call the
80
80
  # send_update method, and return the resulting instance of the same class
81
81
  def update(site_key, uri, properties={}, tid=nil, customer_key=nil)
82
82
 
@@ -92,7 +92,7 @@ class OEHClient::Interaction::Interaction
92
92
  attributes.merge!(:ck => customer_key) if (!customer_key.nil? && !customer_key.empty?)
93
93
 
94
94
  # create a new interaction using all parameters pass
95
- new_interaction = OEHClient::Interaction::Interaction.new(attributes)
95
+ new_interaction = OEHClient::Realtime::Interaction.new(attributes)
96
96
  # send the update and return the current object
97
97
  new_interaction.send_update(properties)
98
98
 
@@ -136,7 +136,7 @@ class OEHClient::Interaction::Interaction
136
136
  end
137
137
 
138
138
  # send_new posts a new interaction using the existing instance data, but for a different touchpoint
139
- # URI. The method returns a new instance of the OEHClient::Interaction::Interaction class
139
+ # URI. The method returns a new instance of the OEHClient::Realtime::Interaction class
140
140
  def send_new(uri, timestamp=nil, parameters={})
141
141
  # raise the MissingParameterException when one (or more) of the miminal parameters are missing
142
142
  raise OEHClient::Exception::MissingParameterException.new(missing_minimal_parameters) unless (minimal_parameters?)
@@ -148,7 +148,7 @@ class OEHClient::Interaction::Interaction
148
148
  # create a new interaction using all parameters from the existing other than the new touchpoint
149
149
  # URI and timestamp of the current Interaction instance. The method can be used to submit new
150
150
  # requests for the same customer, tid, & session
151
- new_interaction = OEHClient::Interaction::Interaction.new({
151
+ new_interaction = OEHClient::Realtime::Interaction.new({
152
152
  :uri => uri,
153
153
  :ck => @customer_key,
154
154
  :tid => @tid,
@@ -188,6 +188,8 @@ class OEHClient::Interaction::Interaction
188
188
  # send_realtime posts a new interaction occuring at the moment (in realtime). The response attributes
189
189
  # are mapped to the current instance attributes for all valid requests
190
190
  def send_realtime(properties={})
191
+ # Put timestamp in the header if it has been provides
192
+ properties[:header] = {'X-ONE-Timestamp' => @timestamp}.merge!(OEHClient::Helper::Request.default_JSON_header()) unless (@timestamp.nil?)
191
193
  # POST the realtime interaction method
192
194
  response = send_request(OEHClient::Helper::Request::POST_METHOD, realtime_url, properties)
193
195
  # map the response message to the current instance attributes
@@ -207,12 +209,16 @@ class OEHClient::Interaction::Interaction
207
209
  # set the URL parameters for the site_key and the tid, of the value exists
208
210
  url_parameters = {:sk => @space.site_key}
209
211
  url_parameters.merge!({:tid => @tid}) unless (@tid.blank?)
210
- url_parameters.merge!({:timestamp => @timestamp}) unless (@timestamp.nil?)
212
+ #url_parameters.merge!({:timestamp => @timestamp}) unless (@timestamp.nil?)
213
+
214
+ send_args = {:params => url_parameters, :payload => ActiveSupport::JSON.encode(request_data(properties))}
215
+ send_args[:header] = properties[:header] if (!properties.nil? && properties.has_key?(:header))
216
+
211
217
  # send the POST or PUT methond along with the arguments to the OEHClient class
212
218
  OEHClient.send(method.downcase.to_sym,
213
219
  url,
214
220
  @space.oauth_consumer,
215
- {:params => url_parameters, :payload => ActiveSupport::JSON.encode(request_data(properties))})
221
+ send_args)
216
222
 
217
223
  end
218
224
 
@@ -226,32 +232,32 @@ class OEHClient::Interaction::Interaction
226
232
  @tid = body[ONE_PARAM_TID] if (@tid.nil? || (!@tid.blank? && @tid != body[ONE_PARAM_TID]))
227
233
  @session = body[ONE_PARAM_SESSION] if @session.nil?
228
234
 
229
- # capture the optimizations returned from the request and map it to the OEHClient::Interaction::Optimization
235
+ # capture the optimizations returned from the request and map it to the OEHClient::Realtime::Optimization
230
236
  # class
231
237
 
232
238
  # initialize the optimizations collection if it is null
233
239
  @optimizations ||= Array.new
234
- # map each of the optimizations to the OEHClient::Interaction::Optmization class
240
+ # map each of the optimizations to the OEHClient::Realtime::Optmization class
235
241
  body[ONE_RESPONSE_OPTIMIZATIONS].each do | response_optimization |
236
242
  # decode the data of the optimization
237
243
  optimization_data = ActiveSupport::JSON.decode(Base64.decode64(response_optimization[ONE_RESPONSE_OPTIMIZATION_DATA]))
238
244
  # get the actions for each optimization
239
245
  optimization_data[ONE_RESPONSE_ACTIONS].each do | one_action |
240
- @optimizations << OEHClient::Interaction::Optimization.create(self, one_action)
246
+ @optimizations << OEHClient::Realtime::Optimization.create(self, one_action)
241
247
  end
242
248
  end
243
249
 
244
250
  # store the cookies passed back by the system
245
251
  @cookies = response[:cookies]
246
252
 
247
- # capture the trackers returned from the request and mpt it to the OEHClient::Interaction::Tracker
253
+ # capture the trackers returned from the request and mpt it to the OEHClient::Realtime::Tracker
248
254
  # class
249
- # TODO: Create OEHClient::Interaction::Tracker class
255
+ # TODO: Create OEHClient::Realtime::Tracker class
250
256
  @trackers = body[ONE_RESPONSE_TRACKERS]
251
257
 
252
- # capture the capture points returned from the request and map it to the OEHClient::Interaction::Capture
258
+ # capture the capture points returned from the request and map it to the OEHClient::Realtime::Capture
253
259
  # class
254
- # TODO: Create OEHClient::Interaction::Capture class
260
+ # TODO: Create OEHClient::Realtime::Capture class
255
261
  @captures = body[ONE_RESPONSE_CAPTURES]
256
262
 
257
263
 
@@ -266,7 +272,7 @@ class OEHClient::Interaction::Interaction
266
272
  end
267
273
 
268
274
  # missing_minimal_parameters returns an array of the minimal attributes that are missing from the current
269
- # instance of OEHClient::Interaction::Interaction class
275
+ # instance of OEHClient::Realtime::Interaction class
270
276
  def missing_minimal_parameters
271
277
 
272
278
  missing_parameters = []
@@ -306,17 +312,19 @@ class OEHClient::Interaction::Interaction
306
312
 
307
313
  # merge in the different parts of the request data if the values currently exist within
308
314
  # the instance of the class
309
- parameters.merge!({ONE_PARAM_URI => @uri}) if (!@uri.nil? && @uri.length > 0)
315
+ parameters.merge!({ONE_PARAM_URI => @uri}) if (!@uri.nil? && @uri.length > 0)
316
+
317
+ #parameters.merge!({"customerKeyName" => "customerkey", ONE_PARAM_CK => @customer_key}) if (!@customer_key.nil? && @customer_key.length > 0)
318
+ parameters.merge!({"customerKey" => @customer_key}) if (!@customer_key.nil? && @customer_key.length > 0)
310
319
 
311
- parameters.merge!({ONE_PARAM_CK => @customer_key}) if (!@customer_key.nil? && @customer_key.length > 0)
312
320
 
313
- parameters.merge!({ONE_PARAM_SESSION => @session}) if (!@session.nil? && @session.length > 0)
314
- parameters.merge!({ONE_PARAM_TS => @timestamp}) if (!@timestamp.nil?)
321
+ parameters.merge!({ONE_PARAM_SESSION => @session}) if (!@session.nil? && @session.length > 0)
322
+ #parameters.merge!({ONE_PARAM_TS => @timestamp}) if (!@timestamp.nil?)
315
323
 
316
324
  # for each of the properties hash entry, build a name/value pair in the properties collection
317
325
  properties = Array.new
318
326
  passed_properties.each do | key, value |
319
- properties << {ONE_PROPERTIES_NAME => key.to_s, ONE_PROPERTIES_VALUE => value}
327
+ properties << {ONE_PROPERTIES_NAME => key.to_s, ONE_PROPERTIES_VALUE => value} unless (key == :header)
320
328
  end
321
329
  # merge the properties (name / value) connections if there are additonal values to pass
322
330
  parameters.merge!({ONE_PARAM_PROPERTIES => properties}) if (properties.length > 0)
@@ -1,7 +1,7 @@
1
1
  require 'base64'
2
2
  require 'cgi'
3
3
 
4
- class OEHClient::Interaction::Optimization
4
+ class OEHClient::Realtime::Optimization
5
5
 
6
6
  # HASH keys based on the response data
7
7
  OPT_RESPONSE_NAME = "name"
@@ -27,8 +27,8 @@ class OEHClient::Interaction::Optimization
27
27
 
28
28
  one_asset = properties[OPT_RESPONSE_ASSET]
29
29
 
30
- # create a new instance of the OEHClient::Interaction::Optimization class
31
- optimization_instance = OEHClient::Interaction::Optimization.new()
30
+ # create a new instance of the OEHClient::Realtime::Optimization class
31
+ optimization_instance = OEHClient::Realtime::Optimization.new()
32
32
 
33
33
  # assign all data attributes based on the properties object that is passed
34
34
  optimization_instance.name = properties[OPT_RESPONSE_NAME] if (properties.has_key?(OPT_RESPONSE_NAME))
@@ -40,7 +40,7 @@ class OEHClient::Interaction::Optimization
40
40
  # map each of the respones to the response object
41
41
  optimization_instance.responses ||= Array.new
42
42
  one_asset[OPT_RESPONSE_RESPONSES].each do | asset_response |
43
- optimization_instance.responses << OEHClient::Interaction::Response.create(optimization_instance, asset_response)
43
+ optimization_instance.responses << OEHClient::Realtime::Response.create(optimization_instance, asset_response)
44
44
  end
45
45
  # set the parent interaction object
46
46
  optimization_instance.interaction = interaction
@@ -1,5 +1,5 @@
1
1
 
2
- class OEHClient::Interaction::Response
2
+ class OEHClient::Realtime::Response
3
3
 
4
4
  # HASH keys based on the response data
5
5
  OPT_RESPONSE_CODE = "code"
@@ -28,8 +28,8 @@ class OEHClient::Interaction::Response
28
28
 
29
29
  def self.create(optimization, properties={})
30
30
 
31
- # create a new instance of the OEHClient::Interaction::Optimization class
32
- response_instance = OEHClient::Interaction::Response.new()
31
+ # create a new instance of the OEHClient::Realtime::Optimization class
32
+ response_instance = OEHClient::Realtime::Response.new()
33
33
 
34
34
  # assign all data attributes based on the properties object that is passed
35
35
  response_instance.code = properties[OPT_RESPONSE_CODE] if (properties.has_key?(OPT_RESPONSE_CODE))
@@ -0,0 +1,10 @@
1
+ module OEHClient
2
+
3
+ module Realtime
4
+ end
5
+
6
+ end
7
+
8
+ require File.dirname(__FILE__) + '/realtime/interaction'
9
+ require File.dirname(__FILE__) + '/realtime/optimization'
10
+ require File.dirname(__FILE__) + '/realtime/response'
@@ -1,3 +1,3 @@
1
1
  module OEHClient
2
- VERSION = "0.3.4"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/oehclient.rb CHANGED
@@ -9,7 +9,7 @@ require File.dirname(__FILE__) + '/oehclient/helper'
9
9
  require File.dirname(__FILE__) + '/oehclient/exception'
10
10
  require File.dirname(__FILE__) + '/oehclient/config'
11
11
 
12
- require File.dirname(__FILE__) + '/oehclient/interaction'
12
+ require File.dirname(__FILE__) + '/oehclient/realtime'
13
13
  require File.dirname(__FILE__) + '/oehclient/data'
14
14
  require File.dirname(__FILE__) + '/oehclient/meta'
15
15
 
@@ -53,7 +53,7 @@ module OEHClient
53
53
  header = (options.has_key?(:header) ? options[:header] : OEHClient::Helper::Request.default_JSON_header())
54
54
  # merge parameters into the header if they are passed
55
55
  header.merge!(:params => options[:params] ) if (options.has_key?(:params))
56
-
56
+ #puts("URL: #{url} ; Header: #{header}")
57
57
  # send the GET request, manage the returned response, and return the body of the response to the
58
58
  # calling method
59
59
  RestClient.get(url, header) { | response, request, result | OEHClient::Helper::Response.handle(response)}
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oeh-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Balliet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: oauth
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: uuidtools
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: activesupport
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 4.2.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 4.2.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: railties
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: 4.2.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 4.2.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rest-client
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: A simple set of classes that allow access to Interactions, Documents,
@@ -144,9 +144,9 @@ executables: []
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - .gitignore
148
- - .rspec
149
- - .travis.yml
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
150
150
  - CODE_OF_CONDUCT.md
151
151
  - Gemfile
152
152
  - LICENSE.txt
@@ -165,13 +165,17 @@ files:
165
165
  - lib/oehclient/data/structure.rb
166
166
  - lib/oehclient/exception.rb
167
167
  - lib/oehclient/helper.rb
168
- - lib/oehclient/interaction.rb
169
- - lib/oehclient/interaction/interaction.rb
170
- - lib/oehclient/interaction/optimization.rb
171
- - lib/oehclient/interaction/response.rb
172
168
  - lib/oehclient/meta.rb
173
169
  - lib/oehclient/meta/entity.rb
170
+ - lib/oehclient/meta/interaction.rb
171
+ - lib/oehclient/meta/session.rb
172
+ - lib/oehclient/meta/touchpoint.rb
174
173
  - lib/oehclient/meta/workspace.rb
174
+ - lib/oehclient/meta/workspace_entity.rb
175
+ - lib/oehclient/realtime.rb
176
+ - lib/oehclient/realtime/interaction.rb
177
+ - lib/oehclient/realtime/optimization.rb
178
+ - lib/oehclient/realtime/response.rb
175
179
  - lib/oehclient/version.rb
176
180
  - oeh-client.gemspec
177
181
  homepage: https://rubygems.org/gems/oeh-client
@@ -184,17 +188,17 @@ require_paths:
184
188
  - lib
185
189
  required_ruby_version: !ruby/object:Gem::Requirement
186
190
  requirements:
187
- - - '>='
191
+ - - ">="
188
192
  - !ruby/object:Gem::Version
189
193
  version: '0'
190
194
  required_rubygems_version: !ruby/object:Gem::Requirement
191
195
  requirements:
192
- - - '>='
196
+ - - ">="
193
197
  - !ruby/object:Gem::Version
194
198
  version: '0'
195
199
  requirements: []
196
200
  rubyforge_project:
197
- rubygems_version: 2.5.1
201
+ rubygems_version: 2.6.6
198
202
  signing_key:
199
203
  specification_version: 4
200
204
  summary: Simple class-based client for integration to ONE Engagement Hub
@@ -1,10 +0,0 @@
1
- module OEHClient
2
-
3
- module Interaction
4
- end
5
-
6
- end
7
-
8
- require File.dirname(__FILE__) + '/interaction/interaction'
9
- require File.dirname(__FILE__) + '/interaction/optimization'
10
- require File.dirname(__FILE__) + '/interaction/response'