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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c59f2b34d3226a591a2e7b358c146fcda3e34a7f1912f1af5173d209c133b844
4
- data.tar.gz: c8241aa6a47ccd5e7eee7c810c30a317b7838276d0df2a82edc8cec491640550
3
+ metadata.gz: 62f9e9ce0879806f27c696bbc1cb6b4ff630514ab114366ecff65ea93c773bab
4
+ data.tar.gz: 549ddc4c9c2528376a10c3d97f3afdb156445c285a974a58aa50d1e5ab96c933
5
5
  SHA512:
6
- metadata.gz: 10c2f6f72035b392ffcdd091dbfb9eeffafa14df59ba018dda0cbbb61a9c54bd3c95546f58de1b1824e40d5fbd0624f633c50fa0adb014b7f9196b535a73c2cb
7
- data.tar.gz: 5656d2333176e36ebece062faef0a440c56bda52366fc12894414302d80614d70a0d9e127e73b54db92fda96def802855e34b5eb5b02bac9e64fdb9d422c4276
6
+ metadata.gz: 4a3bdf7d94045358aed489de6d360a35f5ae8772b35e455045fc532d9867de533d282f47738b7b01dbb7d37a00701988a2945caf358c0b1a298293a41fc05d98
7
+ data.tar.gz: e05554fcdeff2061edf7f374b786115e11d95616eb65f4d8790ad2a435bde9efbd83bb71c1fc512e64c33861787ee794d5c407659d5a31ecbf3065c95eaf6ac9
@@ -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://www.circuit.com/'.freeze
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
 
@@ -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
- result = connection(
10
- api_resource.sub(':id', conversation_id),
11
- params
12
- ).post
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,12 @@
1
1
  module CircuitApi
2
2
  module Resources
3
3
  class Presence < Base
4
+ AVAILABLE = 'AVAILABLE'.freeze
5
+ OFFLINE = 'OFFLINE'.freeze
6
+ BUSY = 'BUSY'.freeze
7
+ DND = 'DND'.freeze
8
+ AWAY = 'AWAY'.freeze
9
+
4
10
  def api_resource
5
11
  'users'
6
12
  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
@@ -72,7 +72,7 @@ module CircuitApi
72
72
  CircuitApi::HttpError
73
73
  end
74
74
 
75
- raise error_class.new(response.code, response.body)
75
+ raise error_class.new(response.code, response.body, uri)
76
76
  end
77
77
  end
78
78
  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}. Error: #{error_body}"
12
+ "HTTP #{error_code} - URI: #{uri}.\n Error: #{error_body}"
12
13
  end
13
14
  end
14
15
 
@@ -1,3 +1,3 @@
1
1
  module CircuitApi
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.12'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuit-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Pochet