Class: Warb::TemplateDispatcher

Inherits:
Dispatcher show all
Defined in:
lib/warb/template_dispatcher.rb

Instance Method Summary collapse

Methods inherited from Dispatcher

#dispatch, #initialize

Constructor Details

This class inherits a constructor from Warb::Dispatcher

Instance Method Details

#create(**args) ⇒ Object



5
6
7
8
# File 'lib/warb/template_dispatcher.rb', line 5

def create(**args)
  template = Resources::Template.new(**args)
  @client.post('message_templates', template.creation_payload, endpoint_prefix: :business_id)
end

#delete(template_name) ⇒ Object



10
11
12
# File 'lib/warb/template_dispatcher.rb', line 10

def delete(template_name)
  @client.delete('message_templates', { name: template_name }, endpoint_prefix: :business_id).body
end

#list(**args) ⇒ Object



14
15
16
17
18
19
# File 'lib/warb/template_dispatcher.rb', line 14

def list(**args)
  filter = args.slice(:limit, :fields, :after, :before)
  filter[:fields] = filter[:fields].join(',') if filter[:fields].is_a?(Array)

  @client.get('message_templates', endpoint_prefix: :business_id, data: filter).body
end