circuit-api 0.0.7 → 0.0.12
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 +4 -4
- data/lib/circuit_api.rb +1 -1
- data/lib/circuit_api/client.rb +4 -2
- data/lib/circuit_api/resources/message.rb +7 -4
- data/lib/circuit_api/resources/presence.rb +6 -0
- data/lib/circuit_api/resources/webhook.rb +5 -0
- data/lib/circuit_api/utils/connection.rb +1 -1
- data/lib/circuit_api/utils/errors.rb +4 -3
- data/lib/circuit_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62f9e9ce0879806f27c696bbc1cb6b4ff630514ab114366ecff65ea93c773bab
|
4
|
+
data.tar.gz: 549ddc4c9c2528376a10c3d97f3afdb156445c285a974a58aa50d1e5ab96c933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a3bdf7d94045358aed489de6d360a35f5ae8772b35e455045fc532d9867de533d282f47738b7b01dbb7d37a00701988a2945caf358c0b1a298293a41fc05d98
|
7
|
+
data.tar.gz: e05554fcdeff2061edf7f374b786115e11d95616eb65f4d8790ad2a435bde9efbd83bb71c1fc512e64c33861787ee794d5c407659d5a31ecbf3065c95eaf6ac9
|
data/lib/circuit_api.rb
CHANGED
@@ -21,7 +21,7 @@ require 'circuit_api/resources/user'
|
|
21
21
|
require 'circuit_api/resources/webhook'
|
22
22
|
|
23
23
|
module CircuitApi
|
24
|
-
API_BASE_URL = 'https://
|
24
|
+
API_BASE_URL = 'https://eu.yourcircuit.com/'.freeze
|
25
25
|
API_SANDBOX_BASE_URL = 'https://circuitsandbox.net/'.freeze
|
26
26
|
API_PATH_BASE = 'rest/v2/'.freeze
|
27
27
|
|
data/lib/circuit_api/client.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module CircuitApi
|
2
2
|
class Client
|
3
|
-
attr_accessor :client_id, :client_secret, :sandbox, :token
|
3
|
+
attr_accessor :client_id, :client_secret, :sandbox, :instance_url, :token
|
4
4
|
|
5
|
-
def initialize(client_id: nil, client_secret: nil, sandbox: nil)
|
5
|
+
def initialize(client_id: nil, client_secret: nil, sandbox: nil, instance_url: nil)
|
6
6
|
@client_id = client_id
|
7
7
|
@client_secret = client_secret
|
8
8
|
@sandbox = sandbox
|
9
|
+
@instance_url = instance_url
|
9
10
|
end
|
10
11
|
|
11
12
|
def connect(token)
|
@@ -14,6 +15,7 @@ module CircuitApi
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def base_url
|
18
|
+
return instance_url if instance_url
|
17
19
|
return CircuitApi::API_SANDBOX_BASE_URL if sandbox
|
18
20
|
|
19
21
|
CircuitApi::API_BASE_URL
|
@@ -6,10 +6,13 @@ module CircuitApi
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def create(conversation_id, params)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
path = api_resource.sub(':id', conversation_id)
|
10
|
+
|
11
|
+
if CircuitApi::Utils::Object.present?(params[:item_id])
|
12
|
+
path = "#{path}/#{params.delete(:item_id)}"
|
13
|
+
end
|
14
|
+
|
15
|
+
result = connection(path, params).post
|
13
16
|
response_to_object(result)
|
14
17
|
end
|
15
18
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module CircuitApi
|
2
2
|
module Resources
|
3
3
|
class Webhook < Base
|
4
|
+
CONVERSATION_CREATE = 'CONVERSATION.CREATE'.freeze
|
5
|
+
CONVERSATION_UPDATE 'CONVERSATION.UPDATE'.freeze
|
6
|
+
CONVERSATION_ADD_ITEM = 'CONVERSATION.ADD_ITEM'.freeze
|
7
|
+
CONVERSATION_UPDATE_ITEM = 'CONVERSATION.UPDATE_ITEM'.freeze
|
8
|
+
|
4
9
|
def api_resource
|
5
10
|
'webhooks'
|
6
11
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module CircuitApi
|
2
2
|
class HttpError < StandardError
|
3
|
-
attr_reader :error_code, :error_body
|
3
|
+
attr_reader :error_code, :error_body, :uri
|
4
4
|
|
5
|
-
def initialize(code, body)
|
5
|
+
def initialize(code, body, uri)
|
6
6
|
@error_code = code
|
7
7
|
@error_body = body
|
8
|
+
@uri = uri
|
8
9
|
end
|
9
10
|
|
10
11
|
def message
|
11
|
-
"HTTP #{error_code}
|
12
|
+
"HTTP #{error_code} - URI: #{uri}.\n Error: #{error_body}"
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
data/lib/circuit_api/version.rb
CHANGED