Class: CircuitApi::Resources::Conversation

Inherits:
Base
  • Object
show all
Defined in:
lib/circuit_api/resources/conversation.rb

Constant Summary collapse

DIRECT =
'DIRECT'.freeze
GROUP =
'GROUP'.freeze
COMMUNITY =
'COMMUNITY'.freeze
LARGE =
'LARGE'.freeze

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#all, #create, #delete, #delete_all, #find, #initialize, #update

Constructor Details

This class inherits a constructor from CircuitApi::Resources::Base

Instance Method Details

#api_resourceObject



9
10
11
# File 'lib/circuit_api/resources/conversation.rb', line 9

def api_resource
  'conversations'
end

#create_direct(participant) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/circuit_api/resources/conversation.rb', line 13

def create_direct(participant)
  result = nil

  begin
    result = connection("#{api_resource}/direct", participant: participant).post
  rescue CircuitApi::HttpError => e
    raise unless e.error_code.to_i == 409

    result = JSON.parse(e.error_body)
  end

  response_to_object(result)
end