Class: Amdapi::Client
- Inherits:
-
Object
- Object
- Amdapi::Client
- Defined in:
- lib/amdapi/client.rb
Constant Summary collapse
- BASE_URL =
"https://auth.api-amdapi.com"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
Instance Method Summary collapse
- #all(params: {}) ⇒ Object
- #analyze(params:, file:) ⇒ Object
- #compare_token(new_token) ⇒ Object
- #delete(call_uuid) ⇒ Object
- #find(call_uuid) ⇒ Object
- #generate_new_token ⇒ Object
-
#initialize(client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
Constructor Details
#initialize(client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 |
# File 'lib/amdapi/client.rb', line 13 def initialize(client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil) @client_id = client_id @client_secret = client_secret @adapter = adapter @stubs = stubs @token = generate_token end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
11 12 13 |
# File 'lib/amdapi/client.rb', line 11 def adapter @adapter end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
11 12 13 |
# File 'lib/amdapi/client.rb', line 11 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
11 12 13 |
# File 'lib/amdapi/client.rb', line 11 def client_secret @client_secret end |
Instance Method Details
#all(params: {}) ⇒ Object
37 38 39 |
# File 'lib/amdapi/client.rb', line 37 def all(params: {}) GetCall.new(token, adapter, @stubs).all(params) end |
#analyze(params:, file:) ⇒ Object
41 42 43 44 45 |
# File 'lib/amdapi/client.rb', line 41 def analyze(params:, file:) raise ParamsError unless ParamsValidator.new(params).valid? PostCall.new(token, params, file, adapter, @stubs).create end |
#compare_token(new_token) ⇒ Object
29 30 31 |
# File 'lib/amdapi/client.rb', line 29 def compare_token(new_token) new_token == token end |
#delete(call_uuid) ⇒ Object
47 48 49 |
# File 'lib/amdapi/client.rb', line 47 def delete(call_uuid) DeleteCall.new(token, call_uuid, adapter, @stubs).delete end |
#find(call_uuid) ⇒ Object
33 34 35 |
# File 'lib/amdapi/client.rb', line 33 def find(call_uuid) GetCall.new(call_uuid, token, adapter, @stubs).find end |
#generate_new_token ⇒ Object
21 22 23 |
# File 'lib/amdapi/client.rb', line 21 def generate_new_token @token = generate_token end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/amdapi/client.rb', line 25 def inspect "#<Amdapi::Client>" end |