Sha256: 5a920d2754a651b505f19c3e022505e802cabe49a4af532a2ae405aa03245748

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Mailersend
  # SMS Webhook endpoint from MailerSend API.
  class SMSWebhooks
    attr_accessor :client,
                  :page,
                  :limit,
                  :sms_webhook_id,
                  :settings

    def initialize(client = Mailersend::Client.new)
      @client = client
      @page = page
      @limit = limit
      @sms_webhook_id = sms_webhook_id
      @settings = []
    end

    def list(sms_number_id:)
      hash = {
        'sms_number_id' => sms_number_id
      }
      client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/sms-webhooks',
                                       query: URI.encode_www_form(hash)))
    end

    def get_sms_webhook_route(sms_webhook_id:)
      client.http.get("#{MAILERSEND_API_URL}/sms-webhooks/#{sms_webhook_id}")
    end

    def add_sms_webhook_route
      client.http.post("#{MAILERSEND_API_URL}/sms-webhooks", json: @settings)
    end

    def update_sms_webhook_route(sms_webhook_id:)
      client.http.put("#{MAILERSEND_API_URL}/sms-webhooks/#{sms_webhook_id}", json: @settings)
    end

    def delete_sms_webhook_route(sms_webhook_id:)
      client.http.delete("#{MAILERSEND_API_URL}/sms-webhooks/#{sms_webhook_id}")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailersend-ruby-3.0.0 lib/mailersend/sms_webhooks/sms_webhooks.rb
mailersend-ruby-2.0.3 lib/mailersend/sms_webhooks/sms_webhooks.rb
mailersend-ruby-2.0.2 lib/mailersend/sms_webhooks/sms_webhooks.rb