Class: Plugzapi::Connections
- Inherits:
-
Object
- Object
- Plugzapi::Connections
- Defined in:
- lib/plugzapi/connections.rb
Overview
This main class is for connections with the PlugZapi API. The other classes that will integrate with endpoints need to inherit from Connections.
Direct Known Subclasses
Disconnect, GetQrcode, InstanceStatus, Restart, RestoreSession, SendMessage, ValidatePhone
Instance Attribute Summary collapse
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
The call method will invoke response and return the API request’s response.
-
#initialize(instance_id, token) ⇒ Connections
constructor
A new instance of Connections.
Constructor Details
#initialize(instance_id, token) ⇒ Connections
Returns a new instance of Connections.
13 14 15 16 |
# File 'lib/plugzapi/connections.rb', line 13 def initialize(instance_id, token) @instance_id = instance_id @token = token end |
Instance Attribute Details
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
7 8 9 |
# File 'lib/plugzapi/connections.rb', line 7 def instance_id @instance_id end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/plugzapi/connections.rb', line 7 def token @token end |
Class Method Details
.perform(instance_id:, token:) ⇒ Object
9 10 11 |
# File 'lib/plugzapi/connections.rb', line 9 def self.perform(instance_id:, token:) new(instance_id, token).call end |
Instance Method Details
#call ⇒ Object
The call method will invoke response and return the API request’s response.
19 20 21 22 23 24 25 |
# File 'lib/plugzapi/connections.rb', line 19 def call parsed_response = JSON.parse(response.body).transform_keys{ |key| key.to_sym } parsed_response[:status] = response.status parsed_response end |