oeh-client 2.2.1 → 2.2.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 +4 -4
- metadata +1 -30
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/README.md +0 -73
- data/Rakefile +0 -9
- data/lib/oehclient/config/space.rb +0 -114
- data/lib/oehclient/config/space_manager.rb +0 -55
- data/lib/oehclient/config.rb +0 -11
- data/lib/oehclient/data/node.rb +0 -66
- data/lib/oehclient/data/structure.rb +0 -82
- data/lib/oehclient/data.rb +0 -10
- data/lib/oehclient/exception.rb +0 -64
- data/lib/oehclient/helper.rb +0 -97
- data/lib/oehclient/meta/entity.rb +0 -97
- data/lib/oehclient/meta/interaction.rb +0 -14
- data/lib/oehclient/meta/session.rb +0 -36
- data/lib/oehclient/meta/touchpoint.rb +0 -36
- data/lib/oehclient/meta/workspace.rb +0 -58
- data/lib/oehclient/meta/workspace_entity.rb +0 -13
- data/lib/oehclient/meta.rb +0 -14
- data/lib/oehclient/realtime/interaction.rb +0 -355
- data/lib/oehclient/realtime/optimization.rb +0 -55
- data/lib/oehclient/realtime/response.rb +0 -74
- data/lib/oehclient/realtime.rb +0 -11
- data/lib/oehclient/version.rb +0 -3
- data/oeh-client.gemspec +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bec0ddd14a97b575b75493774289c2bba409a2d
|
4
|
+
data.tar.gz: 32090d1adabc23a2dffe22e92cc1f57feeaa3bcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a477d4f83d54c24268550567fb1582060c065e30efd2e5b976e98d743c7db79522d721c4505446ff7226d2e512eff031ccf2e02c22dbd32de81ae35ea77abedd
|
7
|
+
data.tar.gz: 997695f476c2f872011288d98803d05a0fa93a3c45c562a49721fea33701fcb99d93602e93df32f56fc27e2e164eebdc219c5e904c2e2ff7f04da9bbb686ac30
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oeh-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Balliet
|
@@ -174,40 +174,11 @@ executables: []
|
|
174
174
|
extensions: []
|
175
175
|
extra_rdoc_files: []
|
176
176
|
files:
|
177
|
-
- ".gitignore"
|
178
|
-
- ".rspec"
|
179
|
-
- ".travis.yml"
|
180
|
-
- CODE_OF_CONDUCT.md
|
181
|
-
- Gemfile
|
182
|
-
- LICENSE.txt
|
183
|
-
- README.md
|
184
|
-
- Rakefile
|
185
177
|
- bin/console
|
186
178
|
- bin/setup
|
187
179
|
- lib/oeh-client.rb
|
188
180
|
- lib/oeh_client.rb
|
189
181
|
- lib/oehclient.rb
|
190
|
-
- lib/oehclient/config.rb
|
191
|
-
- lib/oehclient/config/space.rb
|
192
|
-
- lib/oehclient/config/space_manager.rb
|
193
|
-
- lib/oehclient/data.rb
|
194
|
-
- lib/oehclient/data/node.rb
|
195
|
-
- lib/oehclient/data/structure.rb
|
196
|
-
- lib/oehclient/exception.rb
|
197
|
-
- lib/oehclient/helper.rb
|
198
|
-
- lib/oehclient/meta.rb
|
199
|
-
- lib/oehclient/meta/entity.rb
|
200
|
-
- lib/oehclient/meta/interaction.rb
|
201
|
-
- lib/oehclient/meta/session.rb
|
202
|
-
- lib/oehclient/meta/touchpoint.rb
|
203
|
-
- lib/oehclient/meta/workspace.rb
|
204
|
-
- lib/oehclient/meta/workspace_entity.rb
|
205
|
-
- lib/oehclient/realtime.rb
|
206
|
-
- lib/oehclient/realtime/interaction.rb
|
207
|
-
- lib/oehclient/realtime/optimization.rb
|
208
|
-
- lib/oehclient/realtime/response.rb
|
209
|
-
- lib/oehclient/version.rb
|
210
|
-
- oeh-client.gemspec
|
211
182
|
homepage: https://rubygems.org/gems/oeh-client
|
212
183
|
licenses:
|
213
184
|
- MIT
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 Jason Balliet
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# OEHClient
|
2
|
-
|
3
|
-
ONE Engagement Hub (OEH) is the premier customer engagement platform offered by Thunderhead, Inc. The OEHClient ('oeh-client') gem is a series of wrapper classes that allow your ruby/rails applicaitons to easily support integration with the platform.
|
4
|
-
|
5
|
-
## Feature Description
|
6
|
-
|
7
|
-
OEHClient exposes the key features of the ONE Engagement Hub (OEH) system through some simplified classes. The client interface allows you to:
|
8
|
-
|
9
|
-
* Register multiple spaces (OEH Configurations) to allow a single application to interact with each of your company configurations
|
10
|
-
|
11
|
-
* Post customer and anoymous interactions to the ONE Engagement Hub (OEH) server
|
12
|
-
|
13
|
-
* Manage and expose personalized assets and response handlers for optimized interactions
|
14
|
-
|
15
|
-
* Fetch structure data from the ONE Engagement Hub (OEH) in realtime
|
16
|
-
|
17
|
-
## Installation
|
18
|
-
|
19
|
-
Add this line to your application's Gemfile:
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
gem 'oeh-client'
|
23
|
-
```
|
24
|
-
|
25
|
-
And then execute:
|
26
|
-
|
27
|
-
$ bundle install
|
28
|
-
|
29
|
-
Or install it yourself as:
|
30
|
-
|
31
|
-
$ gem install oeh-client
|
32
|
-
|
33
|
-
## Usage
|
34
|
-
|
35
|
-
Each OEH instance can contain one ore more 'spaces', which contain separate application configurations. Each space is provided a unique key that identifies it within the existing SaaS environment. To access the space, you first need to register the space details with the space manager singleton as follows:
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
|
39
|
-
space_parameters = {
|
40
|
-
:site_key => "YOUR_SITE_KEY",
|
41
|
-
:host => "YOUR_THINSTANCE_SERVER_NAME"
|
42
|
-
:api_key => "YOUR_API_KEY",
|
43
|
-
:shared_secret => "YOUR_SHARED_SECRET_KEY",
|
44
|
-
:username => "CONFIGURED_USERNAME",
|
45
|
-
:meta_password => "LOGIN_PASSWORD_FOR_USERNAME"
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
OEHClient::Config::SpaceManager.instance.register_space(space_parameters)
|
50
|
-
|
51
|
-
```
|
52
|
-
|
53
|
-
As needed, you can register multiple spaces for the same instances to support integration with a number of spaces within your application.
|
54
|
-
|
55
|
-
### Interactions
|
56
|
-
|
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
|
-
|
59
|
-
```ruby
|
60
|
-
customer_interaction = OEHClient::Realtime::Interaction.post("YOUR_TARGET_SITE_KEY", "TOUCHPOINT_INTERACTION_URI")
|
61
|
-
```
|
62
|
-
The post method will return an instance of the OE
|
63
|
-
|
64
|
-
|
65
|
-
## Contributing
|
66
|
-
|
67
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/oeh-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
68
|
-
|
69
|
-
|
70
|
-
## License
|
71
|
-
|
72
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
73
|
-
|
data/Rakefile
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'rest-client'
|
3
|
-
|
4
|
-
class OEHClient::Config::Space
|
5
|
-
|
6
|
-
###
|
7
|
-
### ------------- Constants
|
8
|
-
###
|
9
|
-
|
10
|
-
|
11
|
-
###
|
12
|
-
### ------------- Attributes
|
13
|
-
###
|
14
|
-
|
15
|
-
attr_accessor :site_key, # The ONE Site KEY Value
|
16
|
-
:host, # The name of the HOST machine on thunderhead.com (ONEDEMO, EU2, NA4, etc..)
|
17
|
-
:api_key, # The API key provided in the ONE SETTINGS interface
|
18
|
-
:shared_secret, # The shared secret value provided in the ONE SETTINGS interface
|
19
|
-
:username, # The fully-qualified username configured for access to the space
|
20
|
-
:meta_password, # The password needed to access meta-data from the OEH server
|
21
|
-
:workspace # The ONE workspace related to the current space
|
22
|
-
|
23
|
-
###
|
24
|
-
### ------------- Class Methods
|
25
|
-
###
|
26
|
-
|
27
|
-
|
28
|
-
# create builds a new instance of the Site class, populats the attributes using the properties HASH provided
|
29
|
-
# and returns an instance of the class.
|
30
|
-
def self.create(properties={})
|
31
|
-
|
32
|
-
# create a new instance of the OHEClient::Space class
|
33
|
-
space_instance = OEHClient::Config::Space.new()
|
34
|
-
|
35
|
-
# assign all attributes from the passed properties hash
|
36
|
-
space_instance.site_key = properties[:site_key] if (properties.has_key?(:site_key))
|
37
|
-
space_instance.host = properties[:host] if (properties.has_key?(:host))
|
38
|
-
space_instance.api_key = properties[:api_key] if (properties.has_key?(:api_key))
|
39
|
-
space_instance.shared_secret = properties[:shared_secret] if (properties.has_key?(:shared_secret))
|
40
|
-
space_instance.username = properties[:username] if (properties.has_key?(:username))
|
41
|
-
space_instance.meta_password = properties[:meta_password] if (properties.has_key?(:meta_password))
|
42
|
-
|
43
|
-
# return the instance of the OEHClient::Site Class
|
44
|
-
space_instance
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
###
|
50
|
-
### ------------- Instance Methods
|
51
|
-
###
|
52
|
-
|
53
|
-
|
54
|
-
# token is the method used to generate a new OAuth::AccessToken object based on the configuration of
|
55
|
-
# the related space
|
56
|
-
def token()
|
57
|
-
|
58
|
-
# raise the OEHClient::InvalidSpaceException the current instance is not valid
|
59
|
-
raise OEHClient::Exception::InvalidSpaceConfigException unless is_valid?
|
60
|
-
|
61
|
-
# Create the consumer and access token
|
62
|
-
oauth_consumer = OAuth::Consumer.new("#{@api_key}!#{@username}",
|
63
|
-
@shared_secret,
|
64
|
-
{:site => "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}",
|
65
|
-
:scheme => :header})
|
66
|
-
# return the access token
|
67
|
-
return(OAuth::AccessToken.new(oauth_consumer))
|
68
|
-
|
69
|
-
end
|
70
|
-
# return a new instance of the OAuth::Consumer using the details of the space
|
71
|
-
def oauth_consumer()
|
72
|
-
OAuth::Consumer.new("#{@api_key}!#{@username}",
|
73
|
-
@shared_secret,
|
74
|
-
{:site => "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}",
|
75
|
-
:scheme => :header})
|
76
|
-
end
|
77
|
-
|
78
|
-
# is_valid determines if the current class has values for all the attributes. Each attribute is
|
79
|
-
# required with a non-nul / non-blank value to be considered valid
|
80
|
-
def is_valid?()
|
81
|
-
((!@site_key.nil? && !@site_key.empty?) && (!@host.nil? && !@host.empty?) &&
|
82
|
-
(!@api_key.nil? && !@api_key.empty?) && (!@shared_secret.nil? && !@shared_secret.empty?) &&
|
83
|
-
(!@username.nil? && !@username.empty?))
|
84
|
-
end
|
85
|
-
|
86
|
-
# determines if the space configuration appears to be valid for access to the raw meta-data entities.
|
87
|
-
# The method expects the standard valid attributes from is_valid? as well as the meta_password
|
88
|
-
# attribute
|
89
|
-
def meta_access?()
|
90
|
-
self.is_valid? && (!@meta_password.blank?)
|
91
|
-
end
|
92
|
-
|
93
|
-
# return the hash that
|
94
|
-
def meta_credentials()
|
95
|
-
{:username => @username, :password => @meta_password, :rememberMe => "false"}
|
96
|
-
end # def meta_credentials
|
97
|
-
# return the URL for the posting a login request
|
98
|
-
def login_url()
|
99
|
-
"#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}/one/idm_login"
|
100
|
-
end # def login_url
|
101
|
-
# return the URL for posting a logout request
|
102
|
-
def logout_url()
|
103
|
-
"#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}/one/logout"
|
104
|
-
end
|
105
|
-
|
106
|
-
# retrieve the workspace meta-data object from the thinstance in realtime
|
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
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
|
-
class OEHClient::Config::SpaceManager
|
4
|
-
include Singleton
|
5
|
-
|
6
|
-
|
7
|
-
attr_accessor :spaces
|
8
|
-
|
9
|
-
# Constructor. Initialize the spaces collection as a new hash
|
10
|
-
def initialize
|
11
|
-
@spaces = Hash.new
|
12
|
-
end
|
13
|
-
|
14
|
-
# register_space is a wrapper method that converts the passed Hash object to an instance of the
|
15
|
-
# OEHClient::Config::Space object, which is passed to the register method
|
16
|
-
def register_space(space_config={})
|
17
|
-
|
18
|
-
# Pass a new instance of the space object to the register_space method
|
19
|
-
register(OEHClient::Config::Space.create(space_config))
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
# get_space returns the instance of the OEHClient::Config::Space
|
24
|
-
def get(site_key)
|
25
|
-
|
26
|
-
# raise the OEHClient::Exception::InvalidSpaceException if the space has not been registered
|
27
|
-
raise OEHClient::Exception::InvalidSpaceException unless (@spaces.has_key?(site_key))
|
28
|
-
|
29
|
-
# return the space configuration instance
|
30
|
-
@spaces[site_key]
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
# register adds the instance of the OEHClient::Config::Space object to the spaces hash, using the
|
37
|
-
# site_key value as the hash KEY
|
38
|
-
def register(space_instance)
|
39
|
-
|
40
|
-
# Raise OEHClient::Exception::InvalidSpaceException if the space instance is NOT valie
|
41
|
-
raise OEHClient::Exception::InvalidSpaceConfigException unless (space_instance.is_valid?)
|
42
|
-
# Raise the OEHClient::Exception::InvalidSpaceObjectException if the space_instance object is not
|
43
|
-
# the proper type of object (OEHClient::Config::Space)
|
44
|
-
raise OEHClient::Exception::InvalidSpaceObjectException unless (space_instance.kind_of?(OEHClient::Config::Space))
|
45
|
-
|
46
|
-
# Assign the space instance to the spaces collection
|
47
|
-
@spaces[space_instance.site_key] = space_instance
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
data/lib/oehclient/config.rb
DELETED
data/lib/oehclient/data/node.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
|
2
|
-
class OEHClient::Data::Node
|
3
|
-
|
4
|
-
attr_accessor :nodes
|
5
|
-
|
6
|
-
def initialize(data)
|
7
|
-
|
8
|
-
# Raise an exception if the data passed is not already a hash
|
9
|
-
|
10
|
-
# based on the type of object that is passed, create the proper attribute accessor
|
11
|
-
# to allow easy access to data. For example, a simple value in the structure called
|
12
|
-
# firstName will be represented in the object as my_structure.first_name. Simple
|
13
|
-
# object are represented as related node classes. For example a Preference node with
|
14
|
-
# an attribute of nonSmokingRoom will be represented as my_structure.preference.non_smoking_room
|
15
|
-
data.each do | key, value |
|
16
|
-
(value.kind_of?(Array) ? add_collection(key, value) : add_attribute(key, value))
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
# return the names of each of the attributes of the current nodes of the structure
|
22
|
-
def attribute_names()
|
23
|
-
name_collection = Array.new
|
24
|
-
instance_variable_names.each do | structure_attribute |
|
25
|
-
structure_attribute.slice!(0)
|
26
|
-
name_collection << structure_attribute
|
27
|
-
end
|
28
|
-
name_collection
|
29
|
-
end # def attribute_names
|
30
|
-
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# add_collection dynamically create an attr_accessor as an array of Oeh::Structure::Node
|
35
|
-
# classes related to the current instance of the object.
|
36
|
-
def add_collection(name, value_collection)
|
37
|
-
|
38
|
-
# initialize the array object that will act as the value of the attribute
|
39
|
-
node_collection = []
|
40
|
-
|
41
|
-
# for each hash in the array, add a new structure node
|
42
|
-
value_collection.each do | structure_node |
|
43
|
-
node_collection << OEHClient::Data::Structure.new(structure_node)
|
44
|
-
end
|
45
|
-
# add the arry of node objects to the accessor
|
46
|
-
add_attribute(name, node_collection)
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
# add_attribute dynamically creates an attr_accessor for the passed key_value pair either
|
51
|
-
# as a simple value attribute or as an instance of another Node class
|
52
|
-
def add_attribute(name, value)
|
53
|
-
|
54
|
-
# generate a ruby-friendly attribute accessor based on the name of the
|
55
|
-
# structure attribute
|
56
|
-
accessor_name = name.underscore
|
57
|
-
accessor_name.gsub!(/( )/, '_') if (accessor_name.match(/\s/))
|
58
|
-
# create the accessor in the current class and set the value based on the type
|
59
|
-
# of object that represents the value
|
60
|
-
self.class.send(:attr_accessor, accessor_name)
|
61
|
-
instance_variable_set("@#{accessor_name}", (value.kind_of?(Hash) ? OEHClient::Data::Node.new(value) : value))
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
class OEHClient::Data::Structure < OEHClient::Data::Node
|
2
|
-
|
3
|
-
API_PROFILES = "/profiles"
|
4
|
-
|
5
|
-
LABEL_CUSTOMER_KEY = "Customer Key"
|
6
|
-
LABEL_SITE_KEY = "Site Key"
|
7
|
-
LABEL_API_NAME = "API Name"
|
8
|
-
|
9
|
-
#
|
10
|
-
# Class Methods
|
11
|
-
#
|
12
|
-
|
13
|
-
# fetch makes the request to OEH for the structure and returns an instance of the structure
|
14
|
-
# based on the data in the configured structure
|
15
|
-
def self.fetch(parameters={})
|
16
|
-
|
17
|
-
# force the parameters empty hash if needed
|
18
|
-
parameters ||= Hash.new
|
19
|
-
|
20
|
-
# validate the parameters. The implementation expects a Hash object
|
21
|
-
if (!parameters.empty?)
|
22
|
-
# implementation expects a Hash that contains the Customer Key (:ck),
|
23
|
-
# Site Key (:sk), and API Name (:api) because they are required to get
|
24
|
-
# structure from OEH
|
25
|
-
if ((parameters.has_key?(:ck) || parameters.has_key?(:tid)) && parameters.has_key?(:sk) && parameters.has_key?(:api))
|
26
|
-
|
27
|
-
oeh_params = {:sk => parameters[:sk]}
|
28
|
-
|
29
|
-
# set the values based on passed parameters
|
30
|
-
oeh_params.merge!({:ck => parameters[:ck]}) if (parameters.has_key?(:ck))
|
31
|
-
oeh_params.merge!({:keyname => parameters[:keyname]}) if (parameters.has_key?(:keyname))
|
32
|
-
oeh_params.merge!({:tid => parameters[:tid]}) if (parameters.has_key?(:tid))
|
33
|
-
|
34
|
-
# grab the API Name
|
35
|
-
api_name = parameters[:api]
|
36
|
-
|
37
|
-
# set the space based on the site key value that was passed
|
38
|
-
@space = OEHClient::Config::SpaceManager.instance.get(parameters[:sk]) if (parameters.has_key?(:sk))
|
39
|
-
|
40
|
-
# Use the OEHClient object to call OEH profiles API and create an instance
|
41
|
-
# of this class (OEHClient::Data::Structure) as the return value
|
42
|
-
response = OEHClient.get(self.request_url(api_name),
|
43
|
-
@space.oauth_consumer,
|
44
|
-
:params => oeh_params)
|
45
|
-
# dynamically map the response object to a new OEHClient::Data::Structure class
|
46
|
-
OEHClient::Data::Structure.new(response[:body])
|
47
|
-
|
48
|
-
else
|
49
|
-
|
50
|
-
# If the calling application passed a parameter Hash, but is missing key attributes,
|
51
|
-
# raise the Oeh::Exception::MissingParameterException with the name of each
|
52
|
-
# parameter
|
53
|
-
missing_parameters = []
|
54
|
-
|
55
|
-
missing_parameters << LABEL_CUSTOMER_KEY unless (parameters.has_key?(:ck))
|
56
|
-
missing_parameters << LABEL_SITE_KEY unless (parameters.has_key?(:sk))
|
57
|
-
missing_parameters << LABEL_API_NAME unless (parameters.has_key?(:api))
|
58
|
-
|
59
|
-
# raise the OEHClient::Exception::MIssingParameterException using the list of missing parameter
|
60
|
-
# labels that have been added to the collection
|
61
|
-
raise OEHClient::Exception::MissingParameterException.new(missing_parameters)
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
else
|
66
|
-
|
67
|
-
# if the parameters object is NIL then raise the OEHClient::Exception::MissingParameterException,
|
68
|
-
# passing the full set of expected parameter names
|
69
|
-
raise OEHClient::Exception::MissingParameterException.new([LABEL_CUSTOMER_KEY, LABEL_SITE_KEY, LABEL_API_NAME])
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
# request_url returns the fully-qualified URL to return a given structure
|
77
|
-
def self.request_url(api_name)
|
78
|
-
"#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@space.host}#{OEHClient::Helper::Request::ONE_URI_PART}#{OEHClient::Helper::Request::API_URI_PART}#{OEHClient::Helper::Request::API_VERSION}#{API_PROFILES}/#{api_name}"
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
end
|
data/lib/oehclient/data.rb
DELETED
data/lib/oehclient/exception.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module OEHClient
|
2
|
-
|
3
|
-
module Exception
|
4
|
-
|
5
|
-
# Used when an invalid OAuth consumer is detected as part of the client-side API calls
|
6
|
-
class InvalidConsumerException < ::Exception
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
# InvalidSpaceConfigException is used when a OEHClient::Space instance is missing one or more
|
11
|
-
# of the key data attributes
|
12
|
-
class InvalidSpaceConfigException < ::Exception
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# InvalidSpaceException is used when a space is not configured
|
17
|
-
class InvalidSpaceException < ::Exception
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
# InvalideSpaceObjectException is used when a method expects a OEHClient::Config::Space object and
|
22
|
-
# the object passed is not of the same type
|
23
|
-
class InvalidSpaceObjectException < ::Exception
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
# HTTPRequestException is used to manage any REST error code that is returned by the OEH
|
28
|
-
# server
|
29
|
-
class HTTPRequestException < ::Exception
|
30
|
-
|
31
|
-
attr_accessor :http_code
|
32
|
-
|
33
|
-
# override the constructor to add the code value to exception class
|
34
|
-
def initialize(msg, code)
|
35
|
-
super(msg)
|
36
|
-
@http_code = code
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
# Missing ParameterException is used to identify the list of parameters that are required, but missing
|
42
|
-
# by a key method
|
43
|
-
class MissingParameterException < ::Exception
|
44
|
-
|
45
|
-
def initialize(parameter_list)
|
46
|
-
|
47
|
-
super("Missing the required parameters #{parameter_list.join(', ')}")
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
class IncorrectParameterTypeException < ::Exception
|
53
|
-
|
54
|
-
|
55
|
-
def initialize(expected_kind, passed_kind)
|
56
|
-
|
57
|
-
super("Incorrect Parameter Type. Expected #{expected_kind} but received #{passed_kind}")
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|