Class: VoiceML::ConversationsV1ConfigurationResource

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/resources/conversations_v1.rb

Overview

============================================================================

/v1/Configuration (singleton) + nested /Webhooks (singleton) + /Addresses (CRUD)

Constant Summary collapse

CONFIG_FIELDS =
{
  'DefaultChatServiceSid' => :default_chat_service_sid,
  'DefaultMessagingServiceSid' => :default_messaging_service_sid,
  'DefaultInactiveTimer' => :default_inactive_timer,
  'DefaultClosedTimer' => :default_closed_timer
}.freeze
WEBHOOK_FIELDS =
{
  'Method' => :method,
  'Filters' => :filters,
  'PreWebhookUrl' => :pre_webhook_url,
  'PostWebhookUrl' => :post_webhook_url,
  'Target' => :target
}.freeze
ADDRESS_FIELDS =
{
  'Type' => :type,
  'Address' => :address,
  'FriendlyName' => :friendly_name,
  'AutoCreation.Enabled' => :auto_creation_enabled,
  'AutoCreation.Type' => :auto_creation_type,
  'AutoCreation.WebhookUrl' => :auto_creation_webhook_url,
  'AddressCountry' => :address_country
}.freeze
ADDRESS_UPDATE_FIELDS =
{
  'FriendlyName' => :friendly_name,
  'AutoCreation.Enabled' => :auto_creation_enabled,
  'AutoCreation.Type' => :auto_creation_type,
  'AutoCreation.WebhookUrl' => :auto_creation_webhook_url
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ ConversationsV1ConfigurationResource

Returns a new instance of ConversationsV1ConfigurationResource.



485
486
487
# File 'lib/voiceml/resources/conversations_v1.rb', line 485

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create_address(type:, address:, **kwargs) ⇒ Object



520
521
522
523
524
525
526
# File 'lib/voiceml/resources/conversations_v1.rb', line 520

def create_address(type:, address:, **kwargs)
  kwargs[:type] = type
  kwargs[:address] = address
  ConversationsV1ConfigAddress.from_hash(
    @transport.request(:post, '/v1/Configuration/Addresses', form: build_form(ADDRESS_FIELDS, kwargs))
  )
end

#delete_address(sid) ⇒ Object



538
539
540
541
# File 'lib/voiceml/resources/conversations_v1.rb', line 538

def delete_address(sid)
  @transport.request(:delete, "/v1/Configuration/Addresses/#{sid}")
  nil
end

#fetchObject

--- Configuration singleton ---



490
491
492
# File 'lib/voiceml/resources/conversations_v1.rb', line 490

def fetch
  ConversationsV1Configuration.from_hash(@transport.request(:get, '/v1/Configuration'))
end

#fetch_address(sid) ⇒ Object



528
529
530
# File 'lib/voiceml/resources/conversations_v1.rb', line 528

def fetch_address(sid)
  ConversationsV1ConfigAddress.from_hash(@transport.request(:get, "/v1/Configuration/Addresses/#{sid}"))
end

#fetch_webhooksObject

--- Webhooks singleton ---



501
502
503
# File 'lib/voiceml/resources/conversations_v1.rb', line 501

def fetch_webhooks
  ConversationsV1ConfigurationWebhook.from_hash(@transport.request(:get, '/v1/Configuration/Webhooks'))
end

#list_addresses(page_size: nil) ⇒ Object

--- Addresses CRUD ---



512
513
514
515
516
517
518
# File 'lib/voiceml/resources/conversations_v1.rb', line 512

def list_addresses(page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ConfigAddressList.new(
    @transport.request(:get, '/v1/Configuration/Addresses', params: params)
  )
end

#update(**kwargs) ⇒ Object



494
495
496
497
498
# File 'lib/voiceml/resources/conversations_v1.rb', line 494

def update(**kwargs)
  ConversationsV1Configuration.from_hash(
    @transport.request(:post, '/v1/Configuration', form: build_form(CONFIG_FIELDS, kwargs))
  )
end

#update_address(sid, **kwargs) ⇒ Object



532
533
534
535
536
# File 'lib/voiceml/resources/conversations_v1.rb', line 532

def update_address(sid, **kwargs)
  ConversationsV1ConfigAddress.from_hash(
    @transport.request(:post, "/v1/Configuration/Addresses/#{sid}", form: build_form(ADDRESS_UPDATE_FIELDS, kwargs))
  )
end

#update_webhooks(**kwargs) ⇒ Object



505
506
507
508
509
# File 'lib/voiceml/resources/conversations_v1.rb', line 505

def update_webhooks(**kwargs)
  ConversationsV1ConfigurationWebhook.from_hash(
    @transport.request(:post, '/v1/Configuration/Webhooks', form: build_form(WEBHOOK_FIELDS, kwargs))
  )
end