Class: VoiceML::MessagingV1ServicesResource

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

Overview

Operations on /v1/Services at the messaging host.

create / list / fetch / delete reuse the shared path; update (POST /v1/Services/{sid}) is unique to Messaging Service.

Constant Summary collapse

SERVICE_FIELDS =
{
  'FriendlyName' => :friendly_name,
  'InboundRequestUrl' => :inbound_request_url,
  'InboundMethod' => :inbound_method,
  'FallbackUrl' => :fallback_url,
  'FallbackMethod' => :fallback_method,
  'StatusCallback' => :status_callback,
  'StickySender' => :sticky_sender,
  'MmsConverter' => :mms_converter,
  'SmartEncoding' => :smart_encoding,
  'ScanMessageContent' => :scan_message_content,
  'FallbackToLongCode' => :fallback_to_long_code,
  'AreaCodeGeomatch' => :area_code_geomatch,
  'SynchronousValidation' => :synchronous_validation,
  'ValidityPeriod' => :validity_period,
  'Usecase' => :usecase,
  'UseInboundWebhookOnNumber' => :use_inbound_webhook_on_number
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ MessagingV1ServicesResource

Returns a new instance of MessagingV1ServicesResource.



42
43
44
# File 'lib/voiceml/resources/messaging_v1.rb', line 42

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(friendly_name:, **kwargs) ⇒ Object



46
47
48
49
50
51
# File 'lib/voiceml/resources/messaging_v1.rb', line 46

def create(friendly_name:, **kwargs)
  kwargs[:friendly_name] = friendly_name
  MessagingService.from_hash(
    @transport.request(:post, '/v1/Services', form: build_form(kwargs))
  )
end

#delete(sid) ⇒ Object



69
70
71
72
# File 'lib/voiceml/resources/messaging_v1.rb', line 69

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

#fetch(sid) ⇒ Object



59
60
61
# File 'lib/voiceml/resources/messaging_v1.rb', line 59

def fetch(sid)
  MessagingService.from_hash(@transport.request(:get, "/v1/Services/#{sid}"))
end

#list(page_size: nil) ⇒ Object



53
54
55
56
57
# File 'lib/voiceml/resources/messaging_v1.rb', line 53

def list(page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  MessagingServiceList.new(@transport.request(:get, '/v1/Services', params: params))
end

#update(sid, **kwargs) ⇒ Object



63
64
65
66
67
# File 'lib/voiceml/resources/messaging_v1.rb', line 63

def update(sid, **kwargs)
  MessagingService.from_hash(
    @transport.request(:post, "/v1/Services/#{sid}", form: build_form(kwargs))
  )
end