incontact_client 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/.env +9 -0
- data/.gitignore +20 -0
- data/.travis.yml +7 -0
- data/Gemfile +3 -0
- data/README.md +41 -0
- data/Rakefile +12 -0
- data/docs/agent_sessions.md +33 -0
- data/docs/agents.md +54 -0
- data/docs/api.md +12 -0
- data/docs/contacts.md +62 -0
- data/incontact_client.gemspec +31 -0
- data/lib/incontact_client.rb +31 -0
- data/lib/incontact_client/agent_sessions.rb +16 -0
- data/lib/incontact_client/agents.rb +11 -0
- data/lib/incontact_client/api.rb +39 -0
- data/lib/incontact_client/api_test.rb +31 -0
- data/lib/incontact_client/connection.rb +108 -0
- data/lib/incontact_client/contacts.rb +7 -0
- data/lib/incontact_client/error.rb +20 -0
- data/lib/incontact_client/models/agent.rb +6 -0
- data/lib/incontact_client/models/contact.rb +6 -0
- data/lib/incontact_client/models/token.rb +9 -0
- data/lib/incontact_client/resources.rb +7 -0
- data/lib/incontact_client/responses/agent_response.rb +11 -0
- data/lib/incontact_client/responses/agent_session_response.rb +6 -0
- data/lib/incontact_client/responses/contact_response.rb +11 -0
- data/lib/incontact_client/token_authenticated_resource.rb +10 -0
- data/lib/incontact_client/tokens.rb +49 -0
- data/lib/incontact_client/version.rb +3 -0
- metadata +199 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 84377ebde8c6ffb71a41543c5513db5e8346f51e
|
4
|
+
data.tar.gz: 8fcf308b9495afd2f56653092c2443ea08c9a824
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5b2a65caabd1618354f7f5bef28b1eeb5a2ed97b21cd9ba3ae4d7d4e38fb99dd50669643ce6088e2858b29da9cf0c55ff7261c1e02c46483822ecd76b04e094
|
7
|
+
data.tar.gz: 699f0e7f1bac9c21677bcc03587cd9fb11450bd0ec556e318f1dd26e772dd7ba65df82ff7aa07b5c3f8da6dad387a4de5bdcbef05774899c16b4aeaf70fe6dec
|
data/.env
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Used in tests
|
2
|
+
|
3
|
+
export INCONTACT_TOKEN_URL=https://api.incontact.com/InContactAuthorizationServer/token
|
4
|
+
export INCONTACT_APP_NAME=dashboard
|
5
|
+
export INCONTACT_VENDOR_NAME=VeryGoodBusinessCo
|
6
|
+
export INCONTACT_BUSINESS_UNIT_NUMBER=123456
|
7
|
+
export INCONTACT_SCOPE="AdminApi RealTimeApi"
|
8
|
+
export INCONTACT_PASSWORD=Apple123!
|
9
|
+
export INCONTACT_USERNAME=dashboard@verygoodbusiness.com
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# InContactClient [](https://travis-ci.org/customink/incontact_client)
|
2
|
+
|
3
|
+
This gem is a library for accessing [InContact's API](https://developer.incontact.com/API)
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'incontact_client'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
## Configuration
|
17
|
+
|
18
|
+
The following environmental variables need to be defined. They will be used to set all configurations for the client
|
19
|
+
without the need to customize a YAML config file. An example configuration:
|
20
|
+
|
21
|
+
export INCONTACT_TOKEN_URL=https://api.incontact.com/InContactAuthorizationServer/token
|
22
|
+
export INCONTACT_APP_NAME=dashboard
|
23
|
+
export INCONTACT_VENDOR_NAME=VeryGoodBusinessCo
|
24
|
+
export INCONTACT_BUSINESS_UNIT_NUMBER=123456
|
25
|
+
export INCONTACT_SCOPE="AdminApi RealTimeApi" # Scope used for tokens. Leaving this blank will set scope to all APIs
|
26
|
+
export INCONTACT_USERNAME=dashboard@verygoodbusiness.com # Admin user who can access all data
|
27
|
+
export INCONTACT_PASSWORD=Apple123!
|
28
|
+
|
29
|
+
It is recommended to use [dotenv](https://github.com/bkeepers/dotenv) to set
|
30
|
+
your ENV variables.
|
31
|
+
|
32
|
+
## Documentation
|
33
|
+
|
34
|
+
[Api](docs/api.md)
|
35
|
+
|
36
|
+
[Agents](docs/agents.md)
|
37
|
+
|
38
|
+
[Agent Sessions](docs/agent_sessions.md)
|
39
|
+
|
40
|
+
[Contacts](docs/contacts.md)
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
### Agent Sessions
|
2
|
+
|
3
|
+
You can access agent session data using the `InContactClient::Api#agent_session` method.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
api = InContactClient::Api.new
|
7
|
+
agent_sessions = api.agent_sessions # => #<InContactClient::AgentSessions> instance
|
8
|
+
```
|
9
|
+
|
10
|
+
To join a session:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
# Pass in the Agent ID
|
14
|
+
# Returns an InContactClient::Responses::AgentSessionRespose
|
15
|
+
|
16
|
+
agent_session_response = agent_sessions.join_agent_session(1234567) # => {
|
17
|
+
# "session_id" => 12346
|
18
|
+
# }
|
19
|
+
agent_session_response.session_id # => 123456
|
20
|
+
```
|
21
|
+
|
22
|
+
To mask and unmask a call:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
# Pass in session ID and contact ID
|
26
|
+
|
27
|
+
session_id = 1234567
|
28
|
+
contact_id = 7564313
|
29
|
+
|
30
|
+
agent_sessions.mask_call(session_id, contact_id) # => nil
|
31
|
+
|
32
|
+
agent_session.unmask_call(session_id, contact_id) # => nil
|
33
|
+
```
|
data/docs/agents.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
### Agents
|
2
|
+
|
3
|
+
You can access agent data using the `InContactClient::Api#agents` method.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
api = InContactClient::Api.new
|
7
|
+
agents = api.agents # => #<InContactClient::Agents> instance
|
8
|
+
```
|
9
|
+
|
10
|
+
To get all agents:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
# Returns an InContactClient::Responses::AgentResponse
|
14
|
+
|
15
|
+
agent_response = agents.all # => {
|
16
|
+
# "business_unit_id" => 123467,
|
17
|
+
# "last_poll_time" => "2017-04-25T19:12:22.117Z",
|
18
|
+
# "total_records" => 1000,
|
19
|
+
# "agents" => [...]
|
20
|
+
# }
|
21
|
+
|
22
|
+
agent_response.total_records # => 1000
|
23
|
+
agent_response.agents # Returns Array of agent data
|
24
|
+
```
|
25
|
+
|
26
|
+
To find one agent:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# Returns an InContactClient::Responses::AgentResponse
|
30
|
+
|
31
|
+
agent_response = agents.find(1234567) # => {
|
32
|
+
# "business_unit_id" => 4592889,
|
33
|
+
# "last_poll_time" => "2017-04-21T18:12:32.120Z",
|
34
|
+
# "agents" => [...]
|
35
|
+
# }
|
36
|
+
|
37
|
+
# Returns the agents data
|
38
|
+
# See InContact API for available data
|
39
|
+
# The InContact APT returns data with keys in CamelCase
|
40
|
+
agent = agent_response.agents.first # => {
|
41
|
+
# "agent_id" => 1234567
|
42
|
+
# "user_name" => "billsmith@business.com"
|
43
|
+
# "first_name" => "Bill"
|
44
|
+
# "last_name" => "Smith"
|
45
|
+
# "email_adress" => "billsmith@business.com"
|
46
|
+
# "is_active" => true
|
47
|
+
# ...
|
48
|
+
# }
|
49
|
+
|
50
|
+
agent["first_name"] # => "Bill"
|
51
|
+
|
52
|
+
# The model is an OpenStruct, so this will also work
|
53
|
+
agent.first_name # => "Bill"
|
54
|
+
```
|
data/docs/api.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
### Api
|
2
|
+
|
3
|
+
The `InContactClient::Api` class will be the main source to use the API.
|
4
|
+
|
5
|
+
To set up:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
InContactClient::Api.new
|
9
|
+
```
|
10
|
+
|
11
|
+
That's it! This will automatically get a token for use in the API. Check the
|
12
|
+
other docs for how to get specific data.
|
data/docs/contacts.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
### Contacts
|
2
|
+
|
3
|
+
You can access contact data using the `InContactClient::Api#contacts method`
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
api = InContactClient::Api.new
|
7
|
+
contacts = api.contacts # => #<InContactClient::Contacts> instance
|
8
|
+
```
|
9
|
+
|
10
|
+
To get active Contacts:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
# Returns an InContactClient::Responses::ContactResponse
|
14
|
+
|
15
|
+
contact_response = contacts.active # => {
|
16
|
+
# "result_set" => {
|
17
|
+
# "business_unit_id" => "4592889",
|
18
|
+
# "last_poll_time" => "2017-04-21T18:13:13.600Z",
|
19
|
+
# "active_contacts" => [...]
|
20
|
+
# }
|
21
|
+
# }
|
22
|
+
|
23
|
+
# The active_contacts method contains array of contact data
|
24
|
+
# See InContact API for all available data
|
25
|
+
|
26
|
+
contact_response.active_contacts # => [
|
27
|
+
# {
|
28
|
+
# "agent_id" => "1234568",
|
29
|
+
# "campaign_id" => "111111",
|
30
|
+
# "campaign_name" => "Test",
|
31
|
+
# "contact_dd" => "111111111",
|
32
|
+
# "contact_start" => "2017-04-21T18:12:53.123Z",
|
33
|
+
# "first_name" => "Bill",
|
34
|
+
# "last_name" => "Smith",
|
35
|
+
# "media_type_name" => "Call",
|
36
|
+
# ...
|
37
|
+
# },
|
38
|
+
# {
|
39
|
+
# "agent_id" => "1234569",
|
40
|
+
# "campaign_id" => "111112",
|
41
|
+
# "campaign_name" => "Test",
|
42
|
+
# "contact_id" => "111111112",
|
43
|
+
# "contact_start" => "2017-04-21T18:12:53.123Z",
|
44
|
+
# "first_name" => "Joe",
|
45
|
+
# "last_name" => "Johnson",
|
46
|
+
# "media_type_name" => "Call",
|
47
|
+
# ...
|
48
|
+
# },
|
49
|
+
# ...
|
50
|
+
# ]
|
51
|
+
|
52
|
+
# Getting some data
|
53
|
+
|
54
|
+
|
55
|
+
contact = contact_response.active_contacts.first
|
56
|
+
contact["first_name"] # => "Bill"
|
57
|
+
|
58
|
+
# The model is an OpenStruct, so this will also work
|
59
|
+
contact.first_name # => "Bill"
|
60
|
+
```
|
61
|
+
|
62
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "incontact_client/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "incontact_client"
|
8
|
+
spec.version = InContactClient::VERSION
|
9
|
+
spec.authors = ["Brian Tennity"]
|
10
|
+
spec.email = ["btennity@customink.com"]
|
11
|
+
spec.description = "A Ruby gem to access the InContact API"
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/customink/incontact_client"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "faraday"
|
23
|
+
spec.add_dependency "faraday_middleware"
|
24
|
+
spec.add_dependency "retryable"
|
25
|
+
spec.add_dependency "activesupport"
|
26
|
+
spec.add_development_dependency "dotenv"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "minitest"
|
29
|
+
spec.add_development_dependency "webmock"
|
30
|
+
spec.add_development_dependency "rake"
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "active_support/all"
|
2
|
+
require "retryable"
|
3
|
+
require "faraday"
|
4
|
+
require "faraday_middleware"
|
5
|
+
require "incontact_client/error"
|
6
|
+
require "incontact_client/version"
|
7
|
+
require "ostruct"
|
8
|
+
|
9
|
+
module InContactClient
|
10
|
+
autoload :Api, "incontact_client/api"
|
11
|
+
autoload :Tokens, "incontact_client/tokens"
|
12
|
+
autoload :Connection, "incontact_client/connection"
|
13
|
+
autoload :TokenAuthenticatedResource, "incontact_client/token_authenticated_resource"
|
14
|
+
autoload :Agents, "incontact_client/agents"
|
15
|
+
autoload :Contacts, "incontact_client/contacts"
|
16
|
+
autoload :AgentSessions, "incontact_client/agent_sessions"
|
17
|
+
autoload :Resources, "incontact_client/resources"
|
18
|
+
|
19
|
+
module Models
|
20
|
+
autoload :Token, "incontact_client/models/token"
|
21
|
+
autoload :Agent, "incontact_client/models/agent"
|
22
|
+
autoload :Contact, "incontact_client/models/contact"
|
23
|
+
autoload :AgentSession, "incontact_client/models/agent_session"
|
24
|
+
end
|
25
|
+
|
26
|
+
module Responses
|
27
|
+
autoload :ContactResponse, "incontact_client/responses/contact_response"
|
28
|
+
autoload :AgentResponse, "incontact_client/responses/agent_response"
|
29
|
+
autoload :AgentSessionResponse, "incontact_client/responses/agent_session_response"
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module InContactClient
|
2
|
+
class AgentSessions < TokenAuthenticatedResource
|
3
|
+
def join_agent_session(agent_id)
|
4
|
+
agent_request_data = { "asAgentId" => agent_id }
|
5
|
+
connection.post("agent-sessions/join", agent_request_data)
|
6
|
+
end
|
7
|
+
|
8
|
+
def mask_call(session_id, contact_id)
|
9
|
+
connection.post("agent-sessions/#{session_id}/interactions/#{contact_id}/mask")
|
10
|
+
end
|
11
|
+
|
12
|
+
def unmask_call(session_id, contact_id)
|
13
|
+
connection.post("agent-sessions/#{session_id}/interactions/#{contact_id}/unmask")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module InContactClient
|
2
|
+
class Api
|
3
|
+
attr_reader :token
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@token = InContactClient::Tokens.get
|
7
|
+
end
|
8
|
+
|
9
|
+
def agents
|
10
|
+
@agents ||= create_resource(InContactClient::Resources::AGENTS)
|
11
|
+
end
|
12
|
+
|
13
|
+
def contacts
|
14
|
+
@contacts ||= create_resource(InContactClient::Resources::CONTACTS)
|
15
|
+
end
|
16
|
+
|
17
|
+
def agent_sessions
|
18
|
+
@agent_sessions ||= create_resource(InContactClient::Resources::AGENT_SESSIONS)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def create_resource(resource)
|
24
|
+
resource_model = "InContactClient::#{resource}".constantize
|
25
|
+
data_model = "InContactClient::Responses::#{resource.singularize}Response".constantize
|
26
|
+
connection = create_connection(data_model)
|
27
|
+
|
28
|
+
resource_model.new(connection)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_connection(data_model)
|
32
|
+
url = token.resource_server_base_uri
|
33
|
+
authorization = token.authorization
|
34
|
+
options = { default_data_model: data_model }
|
35
|
+
|
36
|
+
InContactClient::Connection.new(url, authorization, options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module InContactClient
|
2
|
+
class ApiTest < TestCase
|
3
|
+
before do
|
4
|
+
mock_request(:post, "", 200, "token", body, ENV["INCONTACT_TOKEN_URL"])
|
5
|
+
end
|
6
|
+
|
7
|
+
let(:api) { InContactClient::Api.new }
|
8
|
+
|
9
|
+
it "will get a token on initialization" do
|
10
|
+
api.token.wont_be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#agents" do
|
14
|
+
it "will return an agent resource class" do
|
15
|
+
api.agents.must_be_kind_of InContactClient::Agents
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#agent_sessions" do
|
20
|
+
it "will return an agent session resource class" do
|
21
|
+
api.agents.must_be_kind_of InContactClient::AgentSessions
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#agents" do
|
26
|
+
it "will return a contact resource class" do
|
27
|
+
api.agents.must_be_kind_of InContactClient::Contacts
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module InContactClient
|
2
|
+
class Connection
|
3
|
+
TIMEOUT = 60
|
4
|
+
OPEN_TIMEOUT = 10
|
5
|
+
MAX_TRIES = 2
|
6
|
+
RETRY_SLEEP = 1
|
7
|
+
API_PATH_PREFIX = "services/v8.0/"
|
8
|
+
|
9
|
+
attr_reader :url
|
10
|
+
attr_reader :authorization
|
11
|
+
attr_reader :default_data_model
|
12
|
+
|
13
|
+
def initialize(url, authorization, options = {})
|
14
|
+
@url = url
|
15
|
+
@authorization = authorization
|
16
|
+
@default_data_model = options[:default_data_model] || OpenStruct
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(path, params = {})
|
20
|
+
request :get, path, params
|
21
|
+
end
|
22
|
+
|
23
|
+
def post(path, payload = "", params = {})
|
24
|
+
request :post, path, params, payload
|
25
|
+
end
|
26
|
+
|
27
|
+
def request(type, path, params = {}, body=nil)
|
28
|
+
timeout_override = params.delete :timeout
|
29
|
+
open_timeout_override = params.delete :open_timeout
|
30
|
+
data_model_override = params.delete :data_model_override
|
31
|
+
response = Retryable.retryable(retryable_options(params)) do
|
32
|
+
request_with_exception_handling do
|
33
|
+
connection.send(type) do |req|
|
34
|
+
req.path = API_PATH_PREFIX + path unless path.blank?
|
35
|
+
req.options[:timeout] = timeout_override || TIMEOUT
|
36
|
+
req.options[:open_timeout] = open_timeout_override || OPEN_TIMEOUT
|
37
|
+
req.params = params
|
38
|
+
req.body = body.to_json unless body.blank?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
raise_response_errors(response)
|
43
|
+
parse_response(response, data_model_override)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def retryable_options(options)
|
49
|
+
{}.tap do |retry_options|
|
50
|
+
retry_options[:tries] = options.delete(:max_tries) || MAX_TRIES
|
51
|
+
retry_options[:sleep] = options.delete(:retry_sleep) || RETRY_SLEEP
|
52
|
+
retry_options[:on] = [ConnectionError]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def request_with_exception_handling
|
57
|
+
yield
|
58
|
+
rescue => exception
|
59
|
+
raise ConnectionError, exception
|
60
|
+
end
|
61
|
+
|
62
|
+
def raise_response_errors(response)
|
63
|
+
return if response.success?
|
64
|
+
error_messages = response.body.respond_to?(:exception_message) &&
|
65
|
+
response.body.errors.present? ? response.body.errors.join("\n") : ""
|
66
|
+
case response.status
|
67
|
+
when 404
|
68
|
+
raise ResourceNotFound.new(error_messages, response)
|
69
|
+
when 400...600
|
70
|
+
raise Error.new(error_messages, response)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def connection
|
75
|
+
@connection ||= create_connection
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_connection
|
79
|
+
Faraday.new(url: url) do |faraday|
|
80
|
+
faraday.headers["Accept-Encoding"] = "none"
|
81
|
+
faraday.headers["Content-Type"] = "application/json; charset=utf-8"
|
82
|
+
faraday.headers["Authorization"] = authorization
|
83
|
+
faraday.use FaradayMiddleware::ParseJson
|
84
|
+
faraday.adapter Faraday.default_adapter
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def parse_response(response, data_model_override)
|
89
|
+
data = response.body
|
90
|
+
map_response_item_to_model(data, data_model_override)
|
91
|
+
end
|
92
|
+
|
93
|
+
def data_model(item)
|
94
|
+
klass = name.demodulize.underscore.singularize.classify
|
95
|
+
"InContactClient::Responses::#{klass}Response".constantize rescue nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def map_response_item_to_model(item, data_model_override)
|
99
|
+
return item if item.blank? || data_model_override.is_a?(FalseClass)
|
100
|
+
|
101
|
+
# Change keys to snake case
|
102
|
+
item.deep_transform_keys! { |key| key.underscore }
|
103
|
+
data_model_klass = data_model_override || default_data_model
|
104
|
+
return item if data_model_klass.nil?
|
105
|
+
data_model_klass.new(item)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module InContactClient
|
2
|
+
class Error < StandardError
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def initialize(exception, response = nil)
|
6
|
+
@response = response
|
7
|
+
if exception.instance_of? Faraday::Error::ClientError
|
8
|
+
super exception.message
|
9
|
+
elsif exception.is_a? String
|
10
|
+
super exception
|
11
|
+
else
|
12
|
+
super "Unknown exception: #{exception.message}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class ConnectionError < Error ; end
|
18
|
+
class ResourceError < Error ; end
|
19
|
+
class ResourceNotFound < ResourceError ; end
|
20
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
3
|
+
module InContactClient
|
4
|
+
class Tokens
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def get
|
8
|
+
Connection.new(url, authorization, token_options).post(path, token_request_data)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def url
|
14
|
+
ENV["INCONTACT_TOKEN_URL"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
""
|
19
|
+
end
|
20
|
+
|
21
|
+
def token_request_data
|
22
|
+
{
|
23
|
+
grant_type: "password",
|
24
|
+
username: ENV["INCONTACT_USERNAME"],
|
25
|
+
password: ENV["INCONTACT_PASSWORD"],
|
26
|
+
scope: ENV["INCONTACT_SCOPE"]
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def token_options
|
31
|
+
{
|
32
|
+
default_data_model: InContactClient::Models::Token
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def authorization
|
37
|
+
"basic #{encoded_auth_string}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def auth_string
|
41
|
+
"#{ENV["INCONTACT_APP_NAME"]}@#{ENV["INCONTACT_VENDOR_NAME"]}:#{ENV["INCONTACT_BUSINESS_UNIT_NUMBER"]}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def encoded_auth_string
|
45
|
+
Base64.encode64(auth_string).chomp
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: incontact_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Tennity
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: retryable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: A Ruby gem to access the InContact API
|
140
|
+
email:
|
141
|
+
- btennity@customink.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".env"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".travis.yml"
|
149
|
+
- Gemfile
|
150
|
+
- README.md
|
151
|
+
- Rakefile
|
152
|
+
- docs/agent_sessions.md
|
153
|
+
- docs/agents.md
|
154
|
+
- docs/api.md
|
155
|
+
- docs/contacts.md
|
156
|
+
- incontact_client.gemspec
|
157
|
+
- lib/incontact_client.rb
|
158
|
+
- lib/incontact_client/agent_sessions.rb
|
159
|
+
- lib/incontact_client/agents.rb
|
160
|
+
- lib/incontact_client/api.rb
|
161
|
+
- lib/incontact_client/api_test.rb
|
162
|
+
- lib/incontact_client/connection.rb
|
163
|
+
- lib/incontact_client/contacts.rb
|
164
|
+
- lib/incontact_client/error.rb
|
165
|
+
- lib/incontact_client/models/agent.rb
|
166
|
+
- lib/incontact_client/models/contact.rb
|
167
|
+
- lib/incontact_client/models/token.rb
|
168
|
+
- lib/incontact_client/resources.rb
|
169
|
+
- lib/incontact_client/responses/agent_response.rb
|
170
|
+
- lib/incontact_client/responses/agent_session_response.rb
|
171
|
+
- lib/incontact_client/responses/contact_response.rb
|
172
|
+
- lib/incontact_client/token_authenticated_resource.rb
|
173
|
+
- lib/incontact_client/tokens.rb
|
174
|
+
- lib/incontact_client/version.rb
|
175
|
+
homepage: https://github.com/customink/incontact_client
|
176
|
+
licenses:
|
177
|
+
- MIT
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.4.5
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: A Ruby gem to access the InContact API
|
199
|
+
test_files: []
|