amdapi 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 252c0c7d2629267ff18319cff6a043df535b4c60b6883ad0d449436111540768
4
- data.tar.gz: d7f8451a47e9464c82b30f7cc3cec4954571c49e398ec95a4c45e6e0e7fe1d38
3
+ metadata.gz: cbd9f23840131da241e9ff30a543dfb06afe30ded4f6934680dd626be37e9fc6
4
+ data.tar.gz: 7bc7084c9faa2168dda6a3b9231b1a6172b6e2efd418ef5d1da97ed1f9a47752
5
5
  SHA512:
6
- metadata.gz: 3e8dd22f689de82a1f04137784f66ace7c011e975698cbf6272b5613c88630ac8630c4a9b89a8f689381f7f563cdcfaecb2c67b9c74bba37ced9055288291da0
7
- data.tar.gz: 9a8575f1cac0cadcd14e69eaaefa00d74ecee591ebe9c59fdefaf704068fb85d18cf50ff16d87c836a1c533da6074fc954e7d0eb555271d7f36cda4b7a30154d
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
- ## Analize a call (create the call info in our DB + analyse asyncronously the audio)
37
- client.analize(params: call_params_hash, file: audio_file)
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, :token, :adapter
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 analize(params:, file:)
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
@@ -1,19 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amdapi
4
- class Call < Object
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 refetch(adapter: Faraday.default_adapter, stubs: nil)
14
- response = GetCall.new(call_uuid, @token, adapter, stubs).find
15
- @attributes = OpenStruct.new(response)
16
- true
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
@@ -13,7 +13,7 @@ module Amdapi
13
13
  response = delete_call(call_uuid, headers: headers)
14
14
  raise CallNotFoundError if response.status == 404
15
15
 
16
- JSON.parse(response.body)
16
+ JSON.parse(response.body)["success"]
17
17
  end
18
18
 
19
19
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amdapi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
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-03-26 00:00:00.000000000 Z
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