amdapi 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/amdapi/client.rb +8 -2
- data/lib/amdapi/objects/call.rb +10 -7
- data/lib/amdapi/resources/delete_call.rb +1 -1
- data/lib/amdapi/version.rb +1 -1
- metadata +2 -3
- data/lib/amdapi/object.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbd9f23840131da241e9ff30a543dfb06afe30ded4f6934680dd626be37e9fc6
|
4
|
+
data.tar.gz: 7bc7084c9faa2168dda6a3b9231b1a6172b6e2efd418ef5d1da97ed1f9a47752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16aa76e44a8952926cda38b8788f1860599f729e1b7f6a69a36a4ba79ef5efd08d4ddbc808b12136e6cd0bcffd1dc04694d5efff789972daa8c47b98e3dbaffb
|
7
|
+
data.tar.gz: bb7988b203d055fc85e69d4b05c23a4e7ef9edef08e922c3488abb86d5ac37be3f98136f3efe0c6f3f04fa8df6e0022bcc334ca8473f88b03a4c2157619ac8ba
|
data/README.md
CHANGED
@@ -23,6 +23,8 @@ Or install it yourself as:
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
```ruby
|
26
|
+
require 'amdapi'
|
27
|
+
|
26
28
|
## initialize the Amdapi client
|
27
29
|
client = Amdapi::Client.new(client_id: ENV["client_id"], client_secret: ENV["client_secret"])
|
28
30
|
|
@@ -33,8 +35,8 @@ client.find(call_uuid)
|
|
33
35
|
client.all(params: search_params_hash) # based on the filters you have provided
|
34
36
|
client.all # will get the first page of the calls linked to your entreprise
|
35
37
|
|
36
|
-
##
|
37
|
-
client.
|
38
|
+
## Analyze a call (create the call info in our DB + analyse asyncronously the audio)
|
39
|
+
client.analyze(params: call_params_hash, file: audio_file)
|
38
40
|
|
39
41
|
## Delete a specific audio (this includes delete the call in our Database + the audio)
|
40
42
|
client.delete(call_uuid)
|
data/lib/amdapi/client.rb
CHANGED
@@ -8,7 +8,7 @@ require "json"
|
|
8
8
|
module Amdapi
|
9
9
|
class Client
|
10
10
|
BASE_URL = "https://auth.api-amdapi.com"
|
11
|
-
attr_reader :client_id, :client_secret, :
|
11
|
+
attr_reader :client_id, :client_secret, :adapter
|
12
12
|
|
13
13
|
def initialize(client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil)
|
14
14
|
@client_id = client_id
|
@@ -26,6 +26,10 @@ module Amdapi
|
|
26
26
|
"#<Amdapi::Client>"
|
27
27
|
end
|
28
28
|
|
29
|
+
def compare_token(new_token)
|
30
|
+
new_token == token
|
31
|
+
end
|
32
|
+
|
29
33
|
def find(call_uuid)
|
30
34
|
GetCall.new(call_uuid, token, adapter, @stubs).find
|
31
35
|
end
|
@@ -34,7 +38,7 @@ module Amdapi
|
|
34
38
|
GetCall.new(token, adapter, @stubs).all(params)
|
35
39
|
end
|
36
40
|
|
37
|
-
def
|
41
|
+
def analyze(params:, file:)
|
38
42
|
raise ParamsError unless ParamsValidator.new(params).valid?
|
39
43
|
|
40
44
|
PostCall.new(token, params, file, adapter, @stubs).create
|
@@ -46,6 +50,8 @@ module Amdapi
|
|
46
50
|
|
47
51
|
private
|
48
52
|
|
53
|
+
attr_reader :token
|
54
|
+
|
49
55
|
def generate_token
|
50
56
|
response = connection.post("/oauth2/token") do |req|
|
51
57
|
req.headers = headers
|
data/lib/amdapi/objects/call.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Amdapi
|
4
|
-
class Call
|
5
|
-
attr_reader :call_uuid
|
4
|
+
class Call
|
5
|
+
attr_reader :call_uuid, :client_id, :agent_id, :customer_id, :call_info
|
6
6
|
|
7
7
|
def initialize(attr = {}, call_uuid: "", token: "")
|
8
|
-
super(attr)
|
9
8
|
@call_uuid = call_uuid
|
10
9
|
@token = token
|
10
|
+
@client_id = attr["client_id"]
|
11
|
+
@agent_id = attr["agent_id"]
|
12
|
+
@customer_id = attr["customer_id"]
|
13
|
+
@call_info = attr["call_info"]
|
11
14
|
end
|
12
15
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
def inspect
|
17
|
+
"#<Amdapi::Client call_uuid=#{call_uuid} client_id=#{client_id || client_id.inspect} " \
|
18
|
+
"agent_id=#{agent_id || agent_id.inspect} " \
|
19
|
+
"customer_id=#{customer_id || customer_id.inspect}>"
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
data/lib/amdapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amdapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martfed
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -102,7 +102,6 @@ files:
|
|
102
102
|
- lib/amdapi/client.rb
|
103
103
|
- lib/amdapi/collection.rb
|
104
104
|
- lib/amdapi/error.rb
|
105
|
-
- lib/amdapi/object.rb
|
106
105
|
- lib/amdapi/objects/call.rb
|
107
106
|
- lib/amdapi/resource.rb
|
108
107
|
- lib/amdapi/resources/delete_call.rb
|
data/lib/amdapi/object.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "ostruct"
|
4
|
-
|
5
|
-
module Amdapi
|
6
|
-
class Object
|
7
|
-
def initialize(attr)
|
8
|
-
@attributes = OpenStruct.new(attr)
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(method, *args, &block)
|
12
|
-
attribute = @attributes.send(method, *args, &block)
|
13
|
-
attribute.is_a?(Hash) ? Object.new(attribute) : attribute
|
14
|
-
end
|
15
|
-
|
16
|
-
def respond_to_missing?(method, include_private = false)
|
17
|
-
true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|