Sha256: dbef04ea205482fc8a6d71c5aa7713b451733c0e936dcf87b8f91d6ea6d6cfde

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Mailersend
  # SMS Number endpoint from MailerSend API.
  class SMSNumber
    attr_accessor :client,
                  :paused,
                  :page,
                  :limit,
                  :sms_number_id

    def initialize(client = Mailersend::Client.new)
      @client = client
      @paused = paused
      @page = page
      @limit = limit
      @sms_number_id = sms_number_id
    end

    def list(page: nil, limit: nil)
      hash = {
        'page' => page,
        'limit' => limit
      }

      client.http.get(URI::HTTPS.build(host: API_BASE_HOST, path: '/v1/sms-numbers',
                                       query: URI.encode_www_form(hash)))
    end

    def get(sms_number_id:)
      client.http.get("#{API_URL}/sms-numbers/#{sms_number_id}")
    end

    def update(sms_number_id:, paused: nil)
      hash = {
        'paused' => paused
      }
      client.http.put("#{API_URL}/sms-numbers/#{sms_number_id}", json: hash.compact)
    end

    def delete(sms_number_id:)
      client.http.delete("#{API_URL}/sms-numbers/#{sms_number_id}")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mailersend-ruby-2.0.1 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-2.0.0 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.6.0 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.5.2 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.5.1 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.5.0 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.4.0 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.3.2 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.3.1 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.3.0 lib/mailersend/sms_number/sms_number.rb
mailersend-ruby-1.2.0 lib/mailersend/sms_number/sms_number.rb